2727import static org .junit .jupiter .api .Assertions .assertEquals ;
2828import static org .junit .jupiter .api .Assertions .assertTrue ;
2929import static software .amazon .encryption .s3 .S3EncryptionClient .withCustomInstructionFileSuffix ;
30+ import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .BUCKET ;
3031import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .appendTestSuffix ;
3132import static software .amazon .encryption .s3 .utils .S3EncryptionClientTestResources .deleteObject ;
3233
@@ -335,13 +336,24 @@ public static void simpleRsaKeyringReEncryptInstructionFileWithCustomSuffix(fina
335336 PublicKey thirdPartyPublicKey = thirdPartyKeyPair .getPublic ();
336337 PrivateKey thirdPartyPrivateKey = thirdPartyKeyPair .getPrivate ();
337338
338- // Create a partial RSA key pair for the third party's keyring
339+ // Create a partial RSA key pair for the third party's decryption keyring
339340 PartialRsaKeyPair thirdPartyPartialRsaKeyPair = PartialRsaKeyPair .builder ()
340341 .publicKey (thirdPartyPublicKey )
341342 .privateKey (thirdPartyPrivateKey )
342343 .build ();
343344
344- // Create the third party's RSA keyring with updated materials description
345+ // Create RSA keyring with third party's public key and updated materials description for re-encryption request
346+ RsaKeyring sharedKeyring = RsaKeyring .builder ()
347+ .wrappingKeyPair (PartialRsaKeyPair .builder ()
348+ .publicKey (thirdPartyPublicKey )
349+ .build ())
350+ .materialsDescription (MaterialsDescription .builder ()
351+ .put ("isOwner" , "no" )
352+ .put ("access-level" , "user" )
353+ .build ())
354+ .build ();
355+
356+ // Create RSA keyring with third party's public and private keys for decryption purposes with updated materials description
345357 RsaKeyring thirdPartyKeyring = RsaKeyring .builder ()
346358 .wrappingKeyPair (thirdPartyPartialRsaKeyPair )
347359 .materialsDescription (MaterialsDescription .builder ()
@@ -356,7 +368,7 @@ public static void simpleRsaKeyringReEncryptInstructionFileWithCustomSuffix(fina
356368 .bucket (bucket )
357369 .key (objectKey )
358370 .instructionFileSuffix ("third-party-access-instruction-file" ) // Custom instruction file suffix for third party
359- .newKeyring (thirdPartyKeyring )
371+ .newKeyring (sharedKeyring )
360372 .build ();
361373
362374 // Perform the re-encryption operation to create the new instruction file
0 commit comments