@@ -31,6 +31,20 @@ public void testBuild_Nominal() throws Exception {
3131 Assert .assertEquals (Collections .singletonMap ("$" , "$" ), config .getEncryptionPaths ());
3232 }
3333
34+ @ Test
35+ public void testBuild_EncryptionKeyNoDecryptionKey () throws Exception {
36+ JweConfig config = JweConfigBuilder .aJweEncryptionConfig ()
37+ .withEncryptionKey (TestUtils .getTestEncryptionCertificate ().getPublicKey ())
38+ .withEncryptionPath ("$" , "$" )
39+ .withEncryptedValueFieldName ("encryptedPayload" )
40+ .build ();
41+ Assert .assertNotNull (config );
42+ Assert .assertEquals (EncryptionConfig .Scheme .JWE , config .getScheme ());
43+ Assert .assertEquals (TestUtils .getTestEncryptionCertificate ().getPublicKey (), config .getEncryptionKey ());
44+ Assert .assertEquals ("encryptedPayload" , config .getEncryptedValueFieldName ());
45+ Assert .assertEquals (Collections .singletonMap ("$" , "$" ), config .getEncryptionPaths ());
46+ }
47+
3448 @ Test
3549 public void testBuild_EncryptionKeyFromCertificate () throws Exception {
3650 EncryptionConfig config = JweConfigBuilder .aJweEncryptionConfig ()
@@ -102,7 +116,7 @@ public void testBuild_ShouldFallbackToDefaults() throws Exception {
102116 @ Test
103117 public void testBuild_ShouldThrowIllegalArgumentException_WhenMissingDecryptionKey () throws Exception {
104118 expectedException .expect (IllegalArgumentException .class );
105- expectedException .expectMessage ("You must include at least an encryption certificate or a decryption key" );
119+ expectedException .expectMessage ("You must include at least an encryption key/ certificate or a decryption key" );
106120 JweConfigBuilder .aJweEncryptionConfig ()
107121 .build ();
108122 }
0 commit comments