2323import java .security .NoSuchAlgorithmException ;
2424import java .security .SecureRandom ;
2525import java .util .Base64 ;
26+ import java .util .HashMap ;
27+ import java .util .Map ;
2628
2729import static org .junit .jupiter .api .Assertions .assertEquals ;
2830import static org .junit .jupiter .api .Assertions .assertNotNull ;
2931import static org .junit .jupiter .api .Assertions .assertNull ;
32+ import static software .amazon .encryption .s3 .S3EncryptionClient .withAdditionalConfiguration ;
3033import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .BUCKET ;
3134import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .appendTestSuffix ;
3235import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .deleteObject ;
@@ -46,32 +49,6 @@ public static void setUp() throws NoSuchAlgorithmException {
4649 RSA_KEY_PAIR = keyPairGen .generateKeyPair ();
4750 }
4851
49- @ Test
50- public void testMaterialsDescriptionAesKeyring () {
51- AesKeyring aesKeyring = AesKeyring .builder ()
52- .wrappingKey (AES_KEY )
53- .materialsDescription (MaterialsDescription .builder ()
54- .put ("version" , "1.0" )
55- .put ("admin" , "yes" )
56- .build ())
57- .build ();
58- assertNotNull (aesKeyring );
59- }
60-
61- @ Test
62- public void testMaterialsDescriptionRsaKeyring () {
63- PartialRsaKeyPair keyPair = new PartialRsaKeyPair (RSA_KEY_PAIR .getPrivate (), RSA_KEY_PAIR .getPublic ());
64- RsaKeyring rsaKeyring = RsaKeyring .builder ()
65- .wrappingKeyPair (keyPair )
66- .materialsDescription (MaterialsDescription .builder ()
67- .put ("version" , "1.0" )
68- .put ("admin" , "yes" )
69- .build ())
70- .build ();
71- assertNotNull (rsaKeyring );
72-
73- }
74-
7552 @ Test
7653 public void testAesMaterialsDescriptionInObjectMetadata () {
7754 AesKeyring aesKeyring = AesKeyring .builder ()
@@ -267,13 +244,13 @@ public void testAesKeyringMatDescOverridesPutObjectEncryptionContext() {
267244
268245 final String input = "Testing Materials Description in Instruction File and not Encryption Context!" ;
269246 final String objectKey = appendTestSuffix ("test-aes-materials-description-in-instruction-file-and-not-encryption-context" );
270- final String encryptionContext = "{\" admin\" :\" yes\" }" ;
247+ final Map <String , String > encryptionContext = new HashMap <String , String >();
248+ encryptionContext .put ("admin" , "yes" );
271249
272250 client .putObject (builder -> builder
273251 .bucket (BUCKET )
274252 .key (objectKey )
275- .serverSideEncryption (ServerSideEncryption .AWS_KMS )
276- .ssekmsEncryptionContext (Base64 .getEncoder ().encodeToString (encryptionContext .getBytes (StandardCharsets .UTF_8 )))
253+ .overrideConfiguration (withAdditionalConfiguration (encryptionContext ))
277254 .build (), RequestBody .fromString (input )
278255 );
279256 ResponseBytes <GetObjectResponse > responseBytes = client .getObjectAsBytes (builder -> builder
@@ -313,13 +290,13 @@ public void testRsaKeyringMatDescOverridesPutObjectEncryptionContext() {
313290 .build ();
314291 final String input = "Testing Materials Description in Instruction File and not Encryption Context!" ;
315292 final String objectKey = appendTestSuffix ("test-rsa-materials-description-in-instruction-file-and-not-encryption-context" );
316- final String encryptionContext = "{\" admin\" :\" yes\" }" ;
293+ final Map <String , String > encryptionContext = new HashMap <String , String >();
294+ encryptionContext .put ("admin" , "yes" );
317295
318296 client .putObject (builder -> builder
319297 .bucket (BUCKET )
320298 .key (objectKey )
321- .serverSideEncryption (ServerSideEncryption .AWS_KMS )
322- .ssekmsEncryptionContext (Base64 .getEncoder ().encodeToString (encryptionContext .getBytes (StandardCharsets .UTF_8 )))
299+ .overrideConfiguration (withAdditionalConfiguration (encryptionContext ))
323300 .build (), RequestBody .fromString (input )
324301 );
325302 ResponseBytes <GetObjectResponse > responseBytes = client .getObjectAsBytes (builder -> builder
0 commit comments