@@ -9,6 +9,12 @@ use crate::migration::plaintext_to_awsdbe::migration_utils::{
9
9
verify_returned_item, ENCRYPTED_AND_SIGNED_VALUE , SIGN_ONLY_VALUE , DO_NOTHING_VALUE ,
10
10
} ;
11
11
use crate :: migration:: plaintext_to_awsdbe:: awsdbe:: common:: create_table_configs;
12
+ // We import these packages for testing combination of migration steps
13
+ use crate :: migration:: plaintext_to_awsdbe:: plaintext:: migration_step_0:: migration_step_0_example;
14
+ use crate :: migration:: plaintext_to_awsdbe:: awsdbe:: migration_step_1:: migration_step_1_example;
15
+ use crate :: migration:: plaintext_to_awsdbe:: awsdbe:: migration_step_3:: migration_step_3_example;
16
+ use crate :: test_utils;
17
+ use uuid:: Uuid ;
12
18
13
19
/*
14
20
Migration Step 2: This is the second step in the migration process from
@@ -136,3 +142,46 @@ pub async fn migration_step_2_example(
136
142
Err ( "No item found" . into ( ) )
137
143
}
138
144
}
145
+
146
+ #[ tokio:: test( flavor = "multi_thread" ) ]
147
+ async fn test_migration_step_2 ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
148
+ let kms_key_id = test_utils:: TEST_KMS_KEY_ID ;
149
+ let table_name = test_utils:: TEST_DDB_TABLE_NAME ;
150
+ let partition_key = Uuid :: new_v4 ( ) . to_string ( ) ;
151
+ let sort_keys = [ "0" , "1" , "2" , "3" ] ;
152
+
153
+ // Given: Step 0 has succeeded
154
+ let success = migration_step_0_example ( table_name, & partition_key, sort_keys[ 0 ] , sort_keys[ 0 ] ) . await ?;
155
+ assert ! ( success, "MigrationStep0 should complete successfully" ) ;
156
+
157
+ // Given: Step 1 has succeeded
158
+ let success = migration_step_1_example ( kms_key_id, table_name, & partition_key, sort_keys[ 1 ] , sort_keys[ 1 ] ) . await ?;
159
+ assert ! ( success, "MigrationStep1 should complete successfully" ) ;
160
+
161
+ // Successfully executes step 2
162
+ let success = migration_step_2_example ( kms_key_id, table_name, & partition_key, sort_keys[ 2 ] , sort_keys[ 2 ] ) . await ?;
163
+ assert ! ( success, "MigrationStep2 should complete successfully" ) ;
164
+
165
+ // When: Execute Step 2 with sortReadValue=0, Then: Success (i.e. can read plaintext values from Step 0)
166
+ let success = migration_step_2_example ( kms_key_id, table_name, & partition_key, sort_keys[ 2 ] , sort_keys[ 0 ] ) . await ?;
167
+ assert ! ( success, "MigrationStep2 should be able to read items written by Step 0" ) ;
168
+
169
+ // When: Execute Step 2 with sortReadValue=1, Then: Success (i.e. can read plaintext values from Step 1)
170
+ let success = migration_step_2_example ( kms_key_id, table_name, & partition_key, sort_keys[ 2 ] , sort_keys[ 1 ] ) . await ?;
171
+ assert ! ( success, "MigrationStep2 should be able to read items written by Step 1" ) ;
172
+
173
+ // Given: Step 3 has succeeded
174
+ let success = migration_step_3_example ( kms_key_id, table_name, & partition_key, sort_keys[ 3 ] , sort_keys[ 3 ] ) . await ?;
175
+ assert ! ( success, "MigrationStep3 should complete successfully" ) ;
176
+
177
+ // When: Execute Step 2 with sortReadValue=3, Then: Success (i.e. can read encrypted values from Step 3)
178
+ let success = migration_step_2_example ( kms_key_id, table_name, & partition_key, sort_keys[ 2 ] , sort_keys[ 3 ] ) . await ?;
179
+ assert ! ( success, "MigrationStep2 should be able to read items written by Step 3" ) ;
180
+
181
+ // Cleanup
182
+ for sort_key in & sort_keys {
183
+ test_utils:: cleanup_items ( table_name, & partition_key, sort_key) . await ?;
184
+ }
185
+
186
+ Ok ( ( ) )
187
+ }
0 commit comments