Skip to content

Commit c7fcb22

Browse files
committed
Add test for computing public key fingerprint
1 parent 0f0e0a3 commit c7fcb22

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/test/java/com/mastercard/developer/encryption/JweConfigBuilderTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,24 @@ public void testBuild_ShouldThrowIllegalArgumentException_WhenMultipleWildcardsO
147147
.build();
148148
}
149149

150+
@Test
151+
public void testBuild_ShouldComputeCertificateKeyFingerprin() throws Exception {
152+
EncryptionConfig config = JweConfigBuilder.aJweEncryptionConfig()
153+
.withEncryptionCertificate(TestUtils.getTestEncryptionCertificate())
154+
.withDecryptionKey(TestUtils.getTestDecryptionKey())
155+
.build();
156+
Assert.assertEquals("761b003c1eade3a5490e5000d37887baa5e6ec0e226c07706e599451fc032a79", config.getEncryptionKeyFingerprint());
157+
}
158+
159+
@Test
160+
public void testBuild_ShouldComputeEncryptionKeyFingerprin() throws Exception {
161+
EncryptionConfig config = JweConfigBuilder.aJweEncryptionConfig()
162+
.withEncryptionKey(TestUtils.getTestEncryptionCertificate().getPublicKey())
163+
.withDecryptionKey(TestUtils.getTestDecryptionKey())
164+
.build();
165+
Assert.assertEquals("761b003c1eade3a5490e5000d37887baa5e6ec0e226c07706e599451fc032a79", config.getEncryptionKeyFingerprint());
166+
}
167+
150168
@Test
151169
public void testBuild_ShouldNotComputeCertificateKeyFingerprint_WhenFingerprintSet() throws Exception {
152170
EncryptionConfig config = JweConfigBuilder.aJweEncryptionConfig()
@@ -156,4 +174,14 @@ public void testBuild_ShouldNotComputeCertificateKeyFingerprint_WhenFingerprintS
156174
.build();
157175
Assert.assertEquals("2f4lvi26vJWzkzAIaiR2G0YsJAQ=", config.getEncryptionKeyFingerprint());
158176
}
177+
178+
@Test
179+
public void testBuild_ShouldNotComputeEncryptionKeyFingerprint_WhenFingerprintSet() throws Exception {
180+
EncryptionConfig config = JweConfigBuilder.aJweEncryptionConfig()
181+
.withEncryptionKey(TestUtils.getTestEncryptionCertificate().getPublicKey())
182+
.withDecryptionKey(TestUtils.getTestDecryptionKey())
183+
.withEncryptionKeyFingerprint("2f4lvi26vJWzkzAIaiR2G0YsJAQ=")
184+
.build();
185+
Assert.assertEquals("2f4lvi26vJWzkzAIaiR2G0YsJAQ=", config.getEncryptionKeyFingerprint());
186+
}
159187
}

0 commit comments

Comments
 (0)