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

Added test to verify signature key is used to create a SET

parent 3506833b
No related branches found
No related tags found
1 merge request!9.NET-SDK: SET-Empfang inkl. Signaturprüfung - Ticket 562
...@@ -13,7 +13,6 @@ namespace BasicUnitTest; ...@@ -13,7 +13,6 @@ namespace BasicUnitTest;
[TestFixture] [TestFixture]
public class SecurityEventTokenTests { public class SecurityEventTokenTests {
private const string rejectSubmission = private const string rejectSubmission =
SecurityEventToken.RejectSubmissionSchema; SecurityEventToken.RejectSubmissionSchema;
...@@ -30,7 +29,6 @@ public class SecurityEventTokenTests { ...@@ -30,7 +29,6 @@ public class SecurityEventTokenTests {
} }
[Test] [Test]
public void CreateJwt_AcceptSubmission() { public void CreateJwt_AcceptSubmission() {
var token = _encryption.CreateAcceptSecurityEventToken(new SubmissionForPickupDto { var token = _encryption.CreateAcceptSecurityEventToken(new SubmissionForPickupDto {
...@@ -129,4 +127,21 @@ public class SecurityEventTokenTests { ...@@ -129,4 +127,21 @@ public class SecurityEventTokenTests {
.Be(rejectSubmission); .Be(rejectSubmission);
decoded.EventType.Should().Be(EventType.Reject); decoded.EventType.Should().Be(EventType.Reject);
} }
[Test]
public void CreateJwt_WithEncryptionKey_ShouldWork() {
_encryption.CreateSecurityEventToken(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
Guid.NewGuid().ToString(), "DummyEvent", null);
}
[Test]
public void CreateJwt_WithEncryptionKey_ShouldThrowAnException() {
Assert.Throws<InvalidOperationException>(() =>
new FitEncryption(_encryption.PrivateKeyDecryption, _encryption.PublicKeyEncryption,
_encryption.PublicKeyEncryption,
_encryption.PublicKeySignatureVerification, null)
.CreateSecurityEventToken(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(),
Guid.NewGuid().ToString(), "DummyEvent", null)
);
}
} }
...@@ -137,7 +137,7 @@ public class FitEncryption { ...@@ -137,7 +137,7 @@ public class FitEncryption {
} }
private string CreateSecurityEventToken(string submissionId, internal string CreateSecurityEventToken(string submissionId,
string caseId, string caseId,
string destinationId, string destinationId,
string eventName, object? content) { string eventName, object? content) {
...@@ -205,7 +205,7 @@ public class FitEncryption { ...@@ -205,7 +205,7 @@ public class FitEncryption {
return sb.ToString(); return sb.ToString();
} }
public static bool VerifyJwt(string signature, IEnumerable<JsonWebKey> keys, public static bool VerifyJwt(string signature, IEnumerable<JsonWebKey> keys,
ILogger? logger = null) { ILogger? logger = null) {
foreach (var key in keys) foreach (var key in keys)
...@@ -263,4 +263,4 @@ public class FitEncryption { ...@@ -263,4 +263,4 @@ public class FitEncryption {
return result.IsValid; return result.IsValid;
} }
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ using System.Runtime.CompilerServices; ...@@ -13,6 +13,7 @@ using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("IntegrationTests")] [assembly:InternalsVisibleTo("IntegrationTests")]
[assembly:InternalsVisibleTo("BasicUnitTest")]
// Von der MSBuild WriteCodeFragment-Klasse generiert. // Von der MSBuild WriteCodeFragment-Klasse generiert.
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