-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add certificated
signfile.pfx
to test NuGet
and DotNetNuGet
- Loading branch information
Showing
7 changed files
with
356 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using NUnit.Framework; | ||
using System.IO; | ||
using System; | ||
using Nuke.Local.Tools.DotNet; | ||
using Nuke.Common.Tooling; | ||
using Nuke.Local.Tools.NuGet; | ||
using System.Linq; | ||
|
||
namespace Nuke.NuGetKeyVaultSignTool | ||
{ | ||
public class DotNetNuGetTests | ||
{ | ||
public static void DefaultConsole(OutputType type, string output) | ||
{ | ||
if (type == OutputType.Std) | ||
Console.WriteLine(output); | ||
else | ||
Console.WriteLine(output); | ||
} | ||
|
||
[TestCase("Files/package.nupkg")] | ||
public void SignPackage(string fileName) | ||
{ | ||
// Copy File to temp folder | ||
var tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
Directory.CreateDirectory(tempFolder); | ||
var tempFile = Path.Combine(tempFolder, Path.GetFileName(fileName)); | ||
File.Copy(fileName, tempFile); | ||
|
||
DotNetTasks.DotNetLogger = DefaultConsole; | ||
|
||
DotNetTasks.DotNetNuGetSign(x => x | ||
.SetTargetPath(tempFile) | ||
.SetCertificatePath("Files/signfile.pfx") | ||
.SetCertificatePassword("signfile") | ||
.SetTimestamper("http://timestamp.digicert.com") | ||
); | ||
|
||
try | ||
{ | ||
DotNetTasks.DotNetNuGetVerify(x => x | ||
.SetTargetPath(tempFile) | ||
.SetCertificateFingerprint("E413994364668939A34B235D378FC8C2CA12C56C0BF9ECC56538FC6079576855") | ||
); | ||
} | ||
catch { } | ||
} | ||
} | ||
|
||
public class NuGetTests | ||
{ | ||
[OneTimeSetUp] | ||
public void SetupEnvironmentToolPath() | ||
{ | ||
var packageId = NuGetTasks.NuGetPackageId; | ||
|
||
var userFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
var packagesFolder = Path.Combine(userFolder, ".nuget", "packages"); | ||
|
||
var packageIdFolder = Path.Combine(packagesFolder, packageId); | ||
var packageExe = Directory.GetFiles(packageIdFolder, "*.exe", SearchOption.AllDirectories).FirstOrDefault(); | ||
Environment.SetEnvironmentVariable(Path.GetFileNameWithoutExtension(packageExe).ToUpper() + "_EXE", packageExe); | ||
} | ||
|
||
public static void DefaultConsole(OutputType type, string output) | ||
{ | ||
if (type == OutputType.Std) | ||
Console.WriteLine(output); | ||
else | ||
Console.WriteLine(output); | ||
} | ||
|
||
[TestCase("Files/package.nupkg")] | ||
public void SignPackage(string fileName) | ||
{ | ||
// Copy File to temp folder | ||
var tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); | ||
Directory.CreateDirectory(tempFolder); | ||
var tempFile = Path.Combine(tempFolder, Path.GetFileName(fileName)); | ||
File.Copy(fileName, tempFile); | ||
|
||
NuGetTasks.NuGetLogger = DefaultConsole; | ||
|
||
NuGetTasks.NuGetSign(x => x | ||
.SetTargetPath(tempFile) | ||
.SetCertificatePath("Files/signfile.pfx") | ||
.SetCertificatePassword("signfile") | ||
.SetTimestamper("http://timestamp.digicert.com") | ||
); | ||
|
||
try | ||
{ | ||
NuGetTasks.NuGetVerify(x => x | ||
.SetTargetPath(tempFile) | ||
.SetCertificateFingerprint("E413994364668939A34B235D378FC8C2CA12C56C0BF9ECC56538FC6079576855") | ||
); | ||
} | ||
catch { } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.