Skip to content

Commit

Permalink
test: update unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Jun 5, 2023
1 parent fd53d63 commit e24297b
Showing 1 changed file with 0 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,5 @@ public void Build_WithValidLeafAndCertificateBundle_BuildsCertificateChain()
Assert.NotNull(certificateChain);
Assert.True(certificateChain.Count > 0);
}

[Fact]
public void Build_WithInvalidLeafCertificate_ThrowsValidationException()
{
// Arrange
X509Certificate2 expiredLeafCert = new X509Certificate2(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "expired_leaf.crt"));
X509Certificate2Collection certificateBundle = new X509Certificate2Collection();

// Act and Assert
Assert.Throws<ValidationException>(() => CertificateChain.Build(expiredLeafCert, certificateBundle));
}

[Fact]
public void Build_WithIncompleteCertificateBundle_ThrowsValidationException()
{
// Arrange
X509Certificate2 invalidLeafCert = new X509Certificate2(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "leaf.crt"));
X509Certificate2Collection certificateBundle = new X509Certificate2Collection();

// Act and Assert
Assert.Throws<ValidationException>(() => CertificateChain.Build(invalidLeafCert, certificateBundle));
}

[Fact]
public void Build_WithValidLeafAndUnmatchableCertificateBundle_BuildsCertificateChain()
{
// Arrange
X509Certificate2 leafCert = new X509Certificate2(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "leaf.crt"));
X509Certificate2Collection certificateBundle = CertificateBundle.Create(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "unmatchable_root.pem"));

// Act and Assert
Assert.Throws<ValidationException>(() => CertificateChain.Build(leafCert, certificateBundle));
}
}
}

0 comments on commit e24297b

Please sign in to comment.