22// SPDX-License-Identifier: Apache-2.0
33package com .amazonaws .services .dynamodbv2 .datamodeling ;
44
5+ import static com .amazonaws .services .dynamodbv2 .datamodeling .LegacyTestVectors .baseClassToV1AttrMap ;
56import static org .testng .AssertJUnit .assertEquals ;
67import static org .testng .AssertJUnit .assertFalse ;
78import static org .testng .AssertJUnit .assertNull ;
@@ -107,18 +108,18 @@ public class TransformerHolisticIT {
107108 private static final PrivateKey rsaPriv ;
108109 private static final PublicKey rsaPub ;
109110 private static final KeyPair rsaPair ;
110- private static final EncryptionMaterialsProvider symProv ;
111+ public static final EncryptionMaterialsProvider symProv ;
111112 private static final EncryptionMaterialsProvider asymProv ;
112113 private static final EncryptionMaterialsProvider symWrappedProv ;
113114 protected static final String HASH_KEY = "hashKey" ;
114115 protected static final String RANGE_KEY = "rangeKey" ;
115- protected static final String BASE_CLASS_TABLE_NAME = "TableName" ;
116+ public static final String BASE_CLASS_TABLE_NAME = "TableName" ;
116117 private static final String RSA = "RSA" ;
117118
118119 private AmazonDynamoDB client ;
119- private static AWSKMS kmsClient = AWSKMSClientBuilder .standard ().build ();
120+ public static AWSKMS kmsClient = AWSKMSClientBuilder .standard ().build ();
120121
121- private static Map <String , KeyData > keyDataMap = new HashMap <>();
122+ public static Map <String , KeyData > keyDataMap = new HashMap <>();
122123
123124 // AttributeEncryptor *must* be used with SaveBehavior.CLOBBER to avoid the risk of data
124125 // corruption.
@@ -127,7 +128,7 @@ public class TransformerHolisticIT {
127128 .builder ()
128129 .withSaveBehavior (SaveBehavior .CLOBBER )
129130 .build ();
130- private static final BaseClass ENCRYPTED_TEST_VALUE = new BaseClass ();
131+ public static final BaseClass ENCRYPTED_TEST_VALUE = new BaseClass ();
131132 private static final Mixed MIXED_TEST_VALUE = new Mixed ();
132133 private static final SignOnly SIGNED_TEST_VALUE = new SignOnly ();
133134 private static final Untouched UNTOUCHED_TEST_VALUE = new Untouched ();
@@ -139,7 +140,7 @@ public class TransformerHolisticIT {
139140
140141 private static final String TEST_VECTOR_MANIFEST_DIR =
141142 "/vectors/encrypted_item/" ;
142- private static final String SCENARIO_MANIFEST_PATH =
143+ public static final String SCENARIO_MANIFEST_PATH =
143144 TEST_VECTOR_MANIFEST_DIR + "scenarios.json" ;
144145 private static final String JAVA_DIR = "java" ;
145146
@@ -326,6 +327,28 @@ public void setUp() {
326327 createCiphertextTables (client );
327328 }
328329
330+ // This test configures EC with various combination. This is different from other tests as other test run in same hardcoded EC.
331+ @ Test
332+ public void decryptWithECConfigTest ()
333+ throws IOException , GeneralSecurityException {
334+ final String nullTableNameInECCipherFile =
335+ "file://ciphertext/java/static-aes-hmac-null-table-1.json" ;
336+ final String nonBMPinECCipherFile =
337+ "file://ciphertext/java/kms-nonbmp-hashkey-1.json" ;
338+ final String nonAsciiTableInECCipherFile =
339+ "file://ciphertext/java/static-aes-hmac-nonascii-table-1.json" ;
340+
341+ TransformerHolisticITHelper .decryptNullTableNameInEC (
342+ nullTableNameInECCipherFile
343+ );
344+ TransformerHolisticITHelper .decryptNonBmpHashKeyVector (
345+ nonBMPinECCipherFile
346+ );
347+ TransformerHolisticITHelper .decryptNonAsciiTableNameVector (
348+ nonAsciiTableInECCipherFile
349+ );
350+ }
351+
329352 @ Test (dataProvider = "getDecryptTestVectors" )
330353 public void decryptTestVector (Scenario scenario ) throws IOException {
331354 client = DynamoDBEmbedded .create ().amazonDynamoDB ();
@@ -1353,7 +1376,7 @@ private void putDataFromFile(AmazonDynamoDB client, String filename)
13531376 }
13541377 }
13551378
1356- private Map <
1379+ public static Map <
13571380 String ,
13581381 List <Map <String , AttributeValue >>
13591382 > getCiphertextManifestFromFile (String filename ) throws IOException {
@@ -1365,7 +1388,7 @@ > getCiphertextManifestFromFile(String filename) throws IOException {
13651388 );
13661389 }
13671390
1368- private static <T > T getManifestFromFile (
1391+ public static <T > T getManifestFromFile (
13691392 String filename ,
13701393 TypeReference typeRef
13711394 ) throws IOException {
@@ -1380,7 +1403,7 @@ private static <T> T getManifestFromFile(
13801403 return (T ) manifestMapper .readValue (manifestFile , typeRef );
13811404 }
13821405
1383- private static void loadKeyData (String filename ) throws IOException {
1406+ static void loadKeyData (String filename ) throws IOException {
13841407 keyDataMap =
13851408 getManifestFromFile (
13861409 TEST_VECTOR_MANIFEST_DIR + stripFilePath (filename ),
0 commit comments