1
- package client
1
+ package encrypted
2
2
3
3
import (
4
4
"context"
@@ -162,7 +162,10 @@ func TestEncryptedClient_PutItem(t *testing.T) {
162
162
nil ,
163
163
), nil )
164
164
165
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
165
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
166
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
167
+
168
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
166
169
167
170
item := map [string ]types.AttributeValue {
168
171
"PK" : & types.AttributeValueMemberS {Value : "123" },
@@ -186,7 +189,10 @@ func TestEncryptedClient_PutItem(t *testing.T) {
186
189
func TestEncryptedClient_PutItem_Failure (t * testing.T ) {
187
190
mockDynamoDBClient := new (MockDynamoDBClient )
188
191
mockCMProvider := new (MockCryptographicMaterialsProvider )
189
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
192
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
193
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
194
+
195
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
190
196
191
197
// Mock the DescribeTable call to simulate fetching table primary key schema.
192
198
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -229,7 +235,10 @@ func TestEncryptedClient_PutItem_Failure(t *testing.T) {
229
235
func TestEncryptedClient_GetItem_Success (t * testing.T ) {
230
236
mockDynamoDBClient := new (MockDynamoDBClient )
231
237
mockCMProvider := new (MockCryptographicMaterialsProvider )
232
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
238
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
239
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
240
+
241
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
233
242
234
243
// Mock DescribeTable call to simulate fetching table primary key schema.
235
244
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -277,7 +286,9 @@ func TestEncryptedClient_GetItem_Success(t *testing.T) {
277
286
func TestEncryptedClient_Query (t * testing.T ) {
278
287
mockDynamoDBClient := new (MockDynamoDBClient )
279
288
mockCMProvider := new (MockCryptographicMaterialsProvider )
280
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
289
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
290
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
291
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
281
292
282
293
// Mock DescribeTable call to simulate fetching table primary key schema.
283
294
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -331,7 +342,9 @@ func TestEncryptedClient_Query(t *testing.T) {
331
342
func TestEncryptedClient_Scan (t * testing.T ) {
332
343
mockDynamoDBClient := new (MockDynamoDBClient )
333
344
mockCMProvider := new (MockCryptographicMaterialsProvider )
334
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
345
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
346
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
347
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
335
348
336
349
// Mock DescribeTable call to simulate fetching table primary key schema.
337
350
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -381,7 +394,9 @@ func TestEncryptedClient_Scan(t *testing.T) {
381
394
func TestEncryptedClient_BatchGetItem (t * testing.T ) {
382
395
mockDynamoDBClient := new (MockDynamoDBClient )
383
396
mockCMProvider := new (MockCryptographicMaterialsProvider )
384
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
397
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
398
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
399
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
385
400
386
401
// Mock DescribeTable call to simulate fetching table primary key schema.
387
402
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -446,7 +461,9 @@ func TestEncryptedClient_BatchGetItem(t *testing.T) {
446
461
func TestEncryptedClient_BatchWriteItem (t * testing.T ) {
447
462
mockDynamoDBClient := new (MockDynamoDBClient )
448
463
mockCMProvider := new (MockCryptographicMaterialsProvider )
449
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
464
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
465
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
466
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
450
467
451
468
// Mock DescribeTable call to simulate fetching table primary key schema.
452
469
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
@@ -503,7 +520,9 @@ func TestEncryptedClient_BatchWriteItem(t *testing.T) {
503
520
func TestEncryptedClient_DeleteItem (t * testing.T ) {
504
521
mockDynamoDBClient := new (MockDynamoDBClient )
505
522
mockCMProvider := new (MockCryptographicMaterialsProvider )
506
- encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider )
523
+ attributeActions := NewAttributeActions (AttributeActionDoNothing )
524
+ attributeActions .SetAttributeAction ("SensitiveAttribute" , AttributeActionEncrypt )
525
+ encryptedClient := NewEncryptedClient (mockDynamoDBClient , mockCMProvider , attributeActions )
507
526
508
527
// Mock DescribeTable call to simulate fetching table primary key schema.
509
528
mockDynamoDBClient .On ("DescribeTable" , mock .Anything , mock .AnythingOfType ("*dynamodb.DescribeTableInput" ), mock .Anything ).Return (& dynamodb.DescribeTableOutput {
0 commit comments