@@ -41,6 +41,11 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
41
41
import MPT = AwsCryptographyMaterialProvidersTypes
42
42
import Primitives = AtomicPrimitives
43
43
import ParseJsonManifests
44
+ import Time
45
+ import Trans = AwsCryptographyDbEncryptionSdkDynamoDbTransformsTypes
46
+ import TransOp = AwsCryptographyDbEncryptionSdkDynamoDbTransformsOperations
47
+ import DdbMiddlewareConfig
48
+ import DynamoDbEncryptionTransforms
44
49
45
50
46
51
datatype TestVectorConfig = TestVectorConfig (
@@ -58,7 +63,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
58
63
writeTests : seq <WriteTest >,
59
64
roundTripTests : seq <RoundTripTest >,
60
65
decryptTests : seq <DecryptTest >,
61
- strings : seq <string >
66
+ strings : seq <string >,
67
+ large : seq <LargeRecord >
62
68
) {
63
69
64
70
method RunAllTests (keyVectors: KeyVectors .KeyVectorsClient)
@@ -78,6 +84,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
78
84
print |configsForIoTest|, " configsForIoTest. \n";
79
85
print |configsForModTest|, " configsForModTest. \n";
80
86
print |strings|, " strings. \n";
87
+ print |large|, " large. \n";
81
88
if |roundTripTests| != 0 {
82
89
print |roundTripTests[0]. configs|, " configs and ", |roundTripTests[0]. records|, " records for round trip. \n";
83
90
}
@@ -107,6 +114,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
107
114
return ;
108
115
}
109
116
StringOrdering ();
117
+ LargeTests ();
110
118
BasicIoTest ();
111
119
RunIoTests ();
112
120
BasicQueryTest ();
@@ -484,6 +492,87 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
484
492
}
485
493
}
486
494
495
+ const TestConfigs : set < string > := {"all"}
496
+ const TestRecords : set < string > := {"all"}
497
+
498
+ predicate DoTestConfig (name : string )
499
+ {
500
+ "all" in TestConfigs || name in TestConfigs
501
+ }
502
+
503
+ predicate DoTestRecord (name : string )
504
+ {
505
+ "all" in TestRecords || name in TestRecords
506
+ }
507
+
508
+ method LargeTests ()
509
+ {
510
+ print "LargeTests\n";
511
+ DoLargeTest ("do_nothing");
512
+ DoLargeTest ("do_nothing_nosign");
513
+ DoLargeTest ("full_encrypt");
514
+ DoLargeTest ("full_encrypt_nosign");
515
+ DoLargeTest ("full_sign");
516
+ DoLargeTest ("full_sign_nosign");
517
+ }
518
+
519
+ method DoLargeTest (config : string )
520
+ {
521
+ if ! DoTestConfig (config) {
522
+ return ;
523
+ }
524
+ expect config in tableEncryptionConfigs;
525
+ var tconfig := tableEncryptionConfigs[config];
526
+ var configs := Types. DynamoDbTablesEncryptionConfig (
527
+ tableEncryptionConfigs := map[TableName := tconfig.config]
528
+ );
529
+ // because there are lots of pre-conditions on configs
530
+ assume {:axiom} false ;
531
+ var client :- expect DynamoDbEncryptionTransforms. DynamoDbEncryptionTransforms (configs);
532
+ LargeTestsClient (client, config);
533
+ }
534
+
535
+ method LargeTestsClient (client : Trans .IDynamoDbEncryptionTransformsClient, config : string )
536
+ requires client. ValidState ()
537
+ ensures client. ValidState ()
538
+ modifies client. Modifies
539
+ {
540
+ for i := 0 to |large| {
541
+ RunLargeTest (large[i], client, config);
542
+ }
543
+ }
544
+
545
+ method RunLargeTest (record : LargeRecord , client : Trans .IDynamoDbEncryptionTransformsClient, config : string )
546
+ requires client. ValidState ()
547
+ ensures client. ValidState ()
548
+ modifies client. Modifies
549
+ {
550
+ if ! DoTestRecord (record.name) {
551
+ return ;
552
+ }
553
+
554
+ var time := Time. GetAbsoluteTime ();
555
+ for i := 0 to record. count {
556
+ var put_input_input := Trans. PutItemInputTransformInput ( sdkInput := DDB.PutItemInput (TableName := TableName, Item := record.item));
557
+ var put_input_output :- expect client. PutItemInputTransform (put_input_input);
558
+ }
559
+ var elapsed := Time. TimeSince (time);
560
+ Time. PrintTimeLong (elapsed, "Large Encrypt " + record.name + "(" + Base10Int2String(record.count) + ") " + config);
561
+
562
+ var put_input_input := Trans. PutItemInputTransformInput ( sdkInput := DDB.PutItemInput (TableName := TableName, Item := record.item));
563
+ var put_input_output :- expect client. PutItemInputTransform (put_input_input);
564
+ time := Time. GetAbsoluteTime ();
565
+ for i := 0 to record. count {
566
+ var orig_get_input := DDB. GetItemInput (TableName := TableName, Key := map[]);
567
+ var get_output := DDB. GetItemOutput (Item := Some(put_input_output.transformedInput.Item));
568
+ var trans_get_input := Trans. GetItemOutputTransformInput (sdkOutput := get_output, originalInput := orig_get_input);
569
+ var put_output :- expect client. GetItemOutputTransform (trans_get_input);
570
+
571
+ }
572
+ elapsed := Time. TimeSince (time);
573
+ Time. PrintTimeLong (elapsed, "Large Decrypt " + record.name + "(" + Base10Int2String(record.count) + ") " + config);
574
+ }
575
+
487
576
method RoundTripTests ()
488
577
{
489
578
print "RoundTripTests\n";
@@ -999,7 +1088,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
999
1088
1000
1089
function MakeEmptyTestVector () : TestVectorConfig
1001
1090
{
1002
- TestVectorConfig (MakeCreateTableInput(), [], map [], [], map [], map [], [], [], [], [], [], [], [], [], [])
1091
+ TestVectorConfig (MakeCreateTableInput(), [], map [], [], map [], map [], [], [], [], [], [], [], [], [], [], [] )
1003
1092
}
1004
1093
1005
1094
method ParseTestVector (data : JSON , prev : TestVectorConfig , keyVectors: KeyVectors .KeyVectorsClient)
@@ -1024,6 +1113,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
1024
1113
var roundTripTests : seq < RoundTripTest> := [];
1025
1114
var decryptTests : seq < DecryptTest> := [];
1026
1115
var strings : seq < string > := [];
1116
+ var large : seq < LargeRecord> := [];
1027
1117
1028
1118
for i := 0 to |data. obj| {
1029
1119
match data. obj[i]. 0 {
@@ -1042,6 +1132,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
1042
1132
case "RoundTripTest" => roundTripTests :- GetRoundTripTests (data.obj[i].1, keyVectors);
1043
1133
case "DecryptTests" => decryptTests :- GetDecryptTests (data.obj[i].1, keyVectors);
1044
1134
case "Strings" => strings :- GetStrings (data.obj[i].1);
1135
+ case "Large" => large :- GetLarges (data.obj[i].1);
1045
1136
case _ => return Failure ("Unexpected top level tag " + data.obj[i].0);
1046
1137
}
1047
1138
}
@@ -1063,7 +1154,8 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
1063
1154
writeTests := prev.writeTests + writeTests,
1064
1155
roundTripTests := prev.roundTripTests + roundTripTests,
1065
1156
decryptTests := prev.decryptTests + decryptTests,
1066
- strings := prev.strings + strings
1157
+ strings := prev.strings + strings,
1158
+ large := prev.large + large
1067
1159
)
1068
1160
);
1069
1161
}
0 commit comments