@@ -16,14 +16,8 @@ public class MigrationUtils
16
16
public static readonly string DO_NOTHING_VALUE = "this will never be encrypted nor signed" ;
17
17
18
18
// 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
+ {
27
21
var item = response . Item ;
28
22
29
23
// Verify partition key
@@ -39,55 +33,24 @@ public static bool VerifyReturnedItem(GetItemResponse response, string partition
39
33
}
40
34
41
35
// 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 )
43
37
{
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" ) } ") ;
45
39
}
46
40
47
41
// 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 )
49
43
{
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" ) } ") ;
51
45
}
52
46
53
47
// 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 )
55
49
{
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" ) } ") ;
57
51
}
58
52
59
53
return true ;
60
54
}
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
- }
92
55
}
93
56
}
0 commit comments