Skip to content

Commit

Permalink
Added the requested tests.
Browse files Browse the repository at this point in the history
Moved the new parameters to be just before the target assemblies.
  • Loading branch information
tstewart65 committed Dec 6, 2024
1 parent 2f13405 commit 2d3cbdb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,34 @@ public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Use_Machine_Store
// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /sm /s \"Special Test Store\" \"/Working/a.dll\"", result.Args);
}

[Fact]
public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Cryptographic_Service_Provider()
{
// Given
var fixture = new SignToolSignRunnerFixture();
fixture.Settings.CspName = "Test Service Provider";

// When
var result = fixture.Run();

// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /csp \"Test Service Provider\" \"/Working/a.dll\"", result.Args);
}

[Fact]
public void Should_Call_Sign_Tool_With_Correct_Parameters_With_Private_Key_Container_Name()
{
// Given
var fixture = new SignToolSignRunnerFixture();
fixture.Settings.PrivateKeyContainerName = "[{{password}}]=TestContainerName";

// When
var result = fixture.Run();

// Then
Assert.Equal("SIGN /f \"/Working/cert.pfx\" /p secret /kc \"[{{password}}]=TestContainerName\" \"/Working/a.dll\"", result.Args);
}
}
}
}
14 changes: 7 additions & 7 deletions src/Cake.Common/Tools/SignTool/SignToolSignRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ private ProcessArgumentBuilder GetArguments(FilePath[] absoluteAssemblyPaths, Si
builder.Append("/sm");
}

// open a specific certificate store
if (!string.IsNullOrWhiteSpace(settings.StoreName))
{
builder.Append("/s");
builder.AppendQuoted(settings.StoreName);
}

// Cryptographic Service Provider
if (!string.IsNullOrEmpty(settings.CspName))
{
Expand All @@ -255,13 +262,6 @@ private ProcessArgumentBuilder GetArguments(FilePath[] absoluteAssemblyPaths, Si
builder.AppendQuoted(settings.PrivateKeyContainerName);
}

// open a specific certificate store
if (!string.IsNullOrWhiteSpace(settings.StoreName))
{
builder.Append("/s");
builder.AppendQuoted(settings.StoreName);
}

// Target Assemblies to sign.
foreach (var path in absoluteAssemblyPaths)
{
Expand Down

0 comments on commit 2d3cbdb

Please sign in to comment.