Skip to content
Snippets Groups Projects
Commit 1d7d8ef5 authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Added test Test Pki against production root

parent 6d9d85d5
No related branches found
No related tags found
1 merge request!13Feature/559 validate certificates
......@@ -31,7 +31,7 @@
<None Update="Test.pdf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Certificates\ProdZustelldienst.json">
<None Update="Certificates\ValidCertificateFromProdPki.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Certificates\TestPkiRootCertificate.pem">
......
......@@ -13,7 +13,7 @@ using NUnit.Framework;
namespace SenderTest;
public class RootCertificatesTests {
private ILogger _logger;
private ILogger? _logger;
[OneTimeSetUp]
public void OneTimeSetup() {
......@@ -28,7 +28,7 @@ public class RootCertificatesTests {
public void LoadRootCertificates_ShouldPass() {
// Act
var certificates = CertificateHelper.GetRootCertificates().Result;
// Assert
certificates.Count.Should().BeGreaterThan(2);
}
......@@ -36,9 +36,9 @@ public class RootCertificatesTests {
[Test]
public void ProdSubmission_ValidCertificate_ShouldPass() {
// Arrange
var certificate = File.ReadAllText("./Certificates/ProdZustelldienst.json");
var certificate = File.ReadAllText("./Certificates/ValidCertificateFromProdPki.json");
var key = new JsonWebKeySet(certificate).Keys.First();
// Act
var result = new CertificateHelper(_logger).ValidateCertificate(key, null, LogLevel.Trace)
.Result;
......@@ -50,14 +50,14 @@ public class RootCertificatesTests {
[Test]
public void TestPki_ValidCertificate_ShouldPass() {
// Arrange
var certificate =
new JsonWebKeySet(
File.ReadAllText("./Certificates/ValidCertificateFromTestPki.json"));
var root =
X509Certificate2.CreateFromPem(
File.ReadAllText("./Certificates/TestPkiRootCertificate.pem"));
var certificate =
new JsonWebKeySet(
File.ReadAllText("./Certificates/ValidCertificateFromTestPki.json"));
// Act
var result = new CertificateHelper(_logger)
.ValidateCertificate(certificate, new[] { root }, LogLevel.Trace)
......@@ -85,6 +85,21 @@ public class RootCertificatesTests {
// Assert
result.Should().BeFalse();
}
[Test]
public void TestPkiCertificate_ValidatesAgainstProdPki_ShouldFail() {
// Arrange
var keySetToBeTested =
new JsonWebKey(
File.ReadAllText("./Certificates/RevokedCertificate.json"));
// Act
var result =
new CertificateHelper(_logger).ValidateCertificate(keySetToBeTested,
logLevel: LogLevel.Trace).Result;
// Assert
result.Should().BeFalse();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment