@@ -16,14 +16,8 @@ public class MigrationUtils
1616 public static readonly string DO_NOTHING_VALUE = "this will never be encrypted nor signed" ;
1717
1818 // Verify that a returned item matches the expected values
19- public static bool VerifyReturnedItem ( GetItemResponse response , string partitionKeyValue , string sortKeyValue ,
20- string encryptedAndSignedValue = null , string signOnlyValue = null , string doNothingValue = null )
21- {
22- // Use default values if not provided
23- encryptedAndSignedValue = encryptedAndSignedValue ?? ENCRYPTED_AND_SIGNED_VALUE ;
24- signOnlyValue = signOnlyValue ?? SIGN_ONLY_VALUE ;
25- doNothingValue = doNothingValue ?? DO_NOTHING_VALUE ;
26-
19+ public static bool VerifyReturnedItem ( GetItemResponse response , string partitionKeyValue , string sortKeyValue )
20+ {
2721 var item = response . Item ;
2822
2923 // Verify partition key
@@ -39,55 +33,24 @@ public static bool VerifyReturnedItem(GetItemResponse response, string partition
3933 }
4034
4135 // Verify attribute1 (will be encrypted and signed in future steps)
42- if ( ! item . ContainsKey ( "attribute1" ) || item [ "attribute1" ] . S != encryptedAndSignedValue )
36+ if ( ! item . ContainsKey ( "attribute1" ) || item [ "attribute1" ] . S != ENCRYPTED_AND_SIGNED_VALUE )
4337 {
44- throw new Exception ( $ "attribute1 mismatch: expected { encryptedAndSignedValue } , got { ( item . ContainsKey ( "attribute1" ) ? item [ "attribute1" ] . S : "null" ) } ") ;
38+ throw new Exception ( $ "attribute1 mismatch: expected { ENCRYPTED_AND_SIGNED_VALUE } , got { ( item . ContainsKey ( "attribute1" ) ? item [ "attribute1" ] . S : "null" ) } ") ;
4539 }
4640
4741 // Verify attribute2 (will be signed but not encrypted in future steps)
48- if ( ! item . ContainsKey ( "attribute2" ) || item [ "attribute2" ] . S != signOnlyValue )
42+ if ( ! item . ContainsKey ( "attribute2" ) || item [ "attribute2" ] . S != SIGN_ONLY_VALUE )
4943 {
50- throw new Exception ( $ "attribute2 mismatch: expected { signOnlyValue } , got { ( item . ContainsKey ( "attribute2" ) ? item [ "attribute2" ] . S : "null" ) } ") ;
44+ throw new Exception ( $ "attribute2 mismatch: expected { SIGN_ONLY_VALUE } , got { ( item . ContainsKey ( "attribute2" ) ? item [ "attribute2" ] . S : "null" ) } ") ;
5145 }
5246
5347 // Verify attribute3 (will neither be encrypted nor signed in future steps)
54- if ( ! item . ContainsKey ( "attribute3" ) || item [ "attribute3" ] . S != doNothingValue )
48+ if ( ! item . ContainsKey ( "attribute3" ) || item [ "attribute3" ] . S != DO_NOTHING_VALUE )
5549 {
56- throw new Exception ( $ "attribute3 mismatch: expected { doNothingValue } , got { ( item . ContainsKey ( "attribute3" ) ? item [ "attribute3" ] . S : "null" ) } ") ;
50+ throw new Exception ( $ "attribute3 mismatch: expected { DO_NOTHING_VALUE } , got { ( item . ContainsKey ( "attribute3" ) ? item [ "attribute3" ] . S : "null" ) } ") ;
5751 }
5852
5953 return true ;
6054 }
61-
62- // Helper method to clean up test items
63- public static async System . Threading . Tasks . Task CleanupItems ( string tableName , string partitionKey , string [ ] sortKeys )
64- {
65- var ddb = new Amazon . DynamoDBv2 . AmazonDynamoDBClient ( ) ;
66-
67- foreach ( var sortKey in sortKeys )
68- {
69- try
70- {
71- var key = new Dictionary < string , AttributeValue >
72- {
73- [ "partition_key" ] = new AttributeValue { S = partitionKey } ,
74- [ "sort_key" ] = new AttributeValue { N = sortKey }
75- } ;
76-
77- var deleteRequest = new DeleteItemRequest
78- {
79- TableName = tableName ,
80- Key = key
81- } ;
82-
83- await ddb . DeleteItemAsync ( deleteRequest ) ;
84- }
85- catch ( Exception e )
86- {
87- // Log but don't fail if cleanup fails
88- Console . WriteLine ( $ "Warning: Failed to clean up test item with sort key { sortKey } : { e . Message } ") ;
89- }
90- }
91- }
9255 }
9356}
0 commit comments