Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using NuGet.Common;
using NuGet.Packaging.Signing;
using Xunit;

Expand Down Expand Up @@ -43,27 +42,16 @@ public void CreateForTimestamping_Always_ReturnsRootCertificatesValidForTimestam

private void Verify(X509ChainPolicy policy, string expectedFingerprint)
{
if (RuntimeEnvironmentHelper.IsWindows)
{
Assert.Equal(X509ChainTrustMode.System, policy.TrustMode);
}
else if (RuntimeEnvironmentHelper.IsLinux || RuntimeEnvironmentHelper.IsMacOSX)
{
Assert.Equal(X509ChainTrustMode.CustomRootTrust, policy.TrustMode);
Assert.Equal(X509ChainTrustMode.CustomRootTrust, policy.TrustMode);

using (SHA256 hashAlgorithm = SHA256.Create())
using (SHA256 hashAlgorithm = SHA256.Create())
{
Assert.Contains(policy.CustomTrustStore, certificate =>
{
Assert.Contains(policy.CustomTrustStore, certificate =>
{
string actualFingerprint = certificate.GetCertHashString(HashAlgorithmName.SHA256);
string actualFingerprint = certificate.GetCertHashString(HashAlgorithmName.SHA256);

return string.Equals(expectedFingerprint, actualFingerprint, StringComparison.OrdinalIgnoreCase);
});
}
}
else
{
throw new PlatformNotSupportedException();
return string.Equals(expectedFingerprint, actualFingerprint, StringComparison.OrdinalIgnoreCase);
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public AllowListVerificationProviderTests(SigningTestFixture fixture)
_trustedRepoTestCert = fixture.TrustedRepositoryCertificate;
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_AuthorSignedPackage_WithCertificateInAllowList_SuccessAsync()
{
// Arrange
Expand Down Expand Up @@ -77,7 +77,7 @@ public async Task GetTrustResultAsync_AuthorSignedPackage_WithCertificateInAllow
}
}

[CIOnlyTheory]
[Theory]
[MemberData(nameof(EmptyNullAndRequiredListCombinations))]
public async Task GetTrustResultAsync_AuthorSignedPackage_RequirementsAsync(
SignedPackageVerifierSettings verifierSettings,
Expand Down Expand Up @@ -125,7 +125,7 @@ public async Task GetTrustResultAsync_AuthorSignedPackage_RequirementsAsync(
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_AuthorSignedPackage_VerifyWithoutCertificateInAllowList_AllowUntrusted_WarnAsync()
{
// Arrange
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task GetTrustResultAsync_AuthorSignedPackage_VerifyWithoutCertifica
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_AuthorSignedPackage_VerifyWithoutCertificateInAllowList_NotAllowUntrusted_ErrorAsync()
{
// Arrange
Expand Down Expand Up @@ -217,7 +217,7 @@ public async Task GetTrustResultAsync_AuthorSignedPackage_VerifyWithoutCertifica
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithAuthorTarget_AndPrimaryPlacement_ErrorAsync()
{
// Arrange
Expand Down Expand Up @@ -265,7 +265,7 @@ public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithAutho
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithRepositoryTarget_AndCounterPlacementOnly_ErrorAsync()
{
// Arrange
Expand Down Expand Up @@ -313,7 +313,7 @@ public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithRepos
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithRepositoryTarget_AndPrimaryPlacement_SuccessAsync()
{
// Arrange
Expand Down Expand Up @@ -359,7 +359,7 @@ public async Task GetTrustResultAsync_RepositorySignedPackage_AllowListWithRepos
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWithAuthorTarget_AndPrimaryPlacement_ErrorAsync()
{
// Arrange
Expand Down Expand Up @@ -409,7 +409,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWi
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWithRepositoryTarget_AndPrimaryPlacementOnly_ErrorAsync()
{
// Arrange
Expand Down Expand Up @@ -459,7 +459,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWi
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWithRepositoryTarget_AndCounterPlacement_SuccessAsync()
{
// Arrange
Expand Down Expand Up @@ -507,7 +507,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_AllowListWi
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -551,7 +551,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertNotFromAllowList_RequireMode_ErrorAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -602,7 +602,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList_WithOwnerInOwnersList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -652,7 +652,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList_WithOwnerNotInOwnersList_RequireMode_ErrorAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -703,7 +703,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList_WithNoOwnersInPackage_RequireMode_ErrorAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -752,7 +752,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSignedWithCertFromAllowList_WithOwnerInOwnersList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -804,7 +804,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSignedWithCertFromAllowList_WithOwnerNotInOwnersList_RequireMode_ErrorAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -857,7 +857,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSignedWithCertFromAllowList_WithOwnerNotInOwnersList_AuthorInList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -911,7 +911,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSignedWithCertFromAllowList_WithNoOwnersInPackage_RequireMode_ErrorAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -963,7 +963,7 @@ public async Task GetTrustResultAsync_RepositoryCountersignedPackage_PackageSign
}


[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList_WithEmptyOwnersList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down Expand Up @@ -1013,7 +1013,7 @@ public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSign
}
}

[CIOnlyFact]
[Fact]
public async Task GetTrustResultAsync_RepositoryPrimarySignedPackage_PackageSignedWithCertFromAllowList__WithNullOwnersList_RequireMode_SuccessAsync()
{
var nupkg = new SimpleTestPackageContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Dispose()
_trustedRepoTestCert.Dispose();
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.Author, "accept", true, 0)]
[InlineData(SigningTestType.Author, "require", false, 1)]
[InlineData(SigningTestType.RepositoryPrimary, "accept", true, 0)]
Expand Down Expand Up @@ -91,7 +91,7 @@ public async Task ClientPolicies_WithNoTrustedSignersListAsync(SigningTestType s
}
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.Author, "accept", true, 0, 1)]
[InlineData(SigningTestType.Author, "require", false, 1, 0)]
[InlineData(SigningTestType.RepositoryPrimary, "accept", true, 0, 1)]
Expand Down Expand Up @@ -152,7 +152,7 @@ public async Task ClientPolicies_WithSignerNotInTrustedSignersListAsync(SigningT
}
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.Author, SignaturePlacement.PrimarySignature, "accept")]
[InlineData(SigningTestType.Author, SignaturePlacement.PrimarySignature, "require")]
[InlineData(SigningTestType.RepositoryPrimary, SignaturePlacement.PrimarySignature, "accept")]
Expand Down Expand Up @@ -223,7 +223,7 @@ public async Task ClientPolicies_WithSignerInTrustedSignersListAsync(SigningTest
}
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.RepositoryPrimary, "accept")]
[InlineData(SigningTestType.RepositoryPrimary, "require")]
[InlineData(SigningTestType.RepositoryCountersigned, "accept")]
Expand Down Expand Up @@ -283,7 +283,7 @@ public async Task ClientPolicies_WithSignerInTrustedSignersList_WithMatchingOwne
}
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.RepositoryPrimary, "accept", true, 0, 1)]
[InlineData(SigningTestType.RepositoryPrimary, "require", false, 1, 0)]
[InlineData(SigningTestType.RepositoryCountersigned, "accept", true, 0, 1)]
Expand Down Expand Up @@ -343,7 +343,7 @@ public async Task ClientPolicies_WithSignerInTrustedSignersList_WithoutMatchingO
}
}

[CIOnlyTheory]
[Theory]
[InlineData(SigningTestType.RepositoryPrimary, "accept", true, 0, 1)]
[InlineData(SigningTestType.RepositoryPrimary, "require", false, 1, 0)]
[InlineData(SigningTestType.RepositoryCountersigned, "accept", true, 0, 1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static SignedPackageVerifierSettings GetSettingsPolicy(string policyStri
return SignedPackageVerifierSettings.GetDefault(TestEnvironmentVariableReader.EmptyInstance);
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnSignedPackageAsync(string policyString)
Expand All @@ -87,7 +87,7 @@ public async Task Signer_VerifyOnSignedPackageAsync(string policyString)
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnTamperedPackage_FileDeletedAsync(string policyString)
Expand Down Expand Up @@ -121,7 +121,7 @@ public async Task Signer_VerifyOnTamperedPackage_FileDeletedAsync(string policyS
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnTamperedPackage_FileAddedAsync(string policyString)
Expand Down Expand Up @@ -166,7 +166,7 @@ public async Task Signer_VerifyOnTamperedPackage_FileAddedAsync(string policyStr
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnTamperedPackage_FileAppendedAsync(string policyString)
Expand Down Expand Up @@ -210,7 +210,7 @@ public async Task Signer_VerifyOnTamperedPackage_FileAppendedAsync(string policy
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnTamperedPackage_FileTruncatedAsync(string policyString)
Expand Down Expand Up @@ -251,7 +251,7 @@ public async Task Signer_VerifyOnTamperedPackage_FileTruncatedAsync(string polic
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command")]
[InlineData("vs")]
public async Task Signer_VerifyOnTamperedPackage_FileMetadataModifiedAsync(string policyString)
Expand Down Expand Up @@ -295,7 +295,7 @@ public async Task Signer_VerifyOnTamperedPackage_FileMetadataModifiedAsync(strin
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command", false)]
[InlineData("vs", true)]
public async Task Signer_VerifyOnTamperedPackage_SignatureRemovedAsync(string policyString, bool expectedValidity)
Expand Down Expand Up @@ -339,7 +339,7 @@ public async Task Signer_VerifyOnTamperedPackage_SignatureRemovedAsync(string po
}
}

[CIOnlyTheory]
[Theory]
[InlineData("command", false)]
[InlineData("vs", true)]
public async Task Signer_VerifyOnTamperedPackage_SignatureTamperedAsync(string policyString, bool expectedValidity)
Expand Down
Loading