Skip to content

Commit 1005889

Browse files
committed
chore(TestVectors): Adding a new ENCRYPT_AND_SIGN/SIGN_ONLY attribute is safe
1 parent 139c856 commit 1005889

File tree

3 files changed

+255681
-1
lines changed

3 files changed

+255681
-1
lines changed

TestVectors/dafny/DDBEncryption/src/TestVectors.dfy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module {:options "-functionSyntax:4"} DdbEncryptionTestVectors {
104104
var _ :- expect DecryptManifest.Decrypt("decrypt_java_33a.json", keyVectors);
105105
var _ :- expect DecryptManifest.Decrypt("decrypt_rust_38.json", keyVectors);
106106
var _ :- expect DecryptManifest.Decrypt("decrypt_go_38.json", keyVectors);
107+
var _ :- expect DecryptManifest.Decrypt("decrypt_java_39.json", keyVectors);
107108
var _ :- expect WriteManifest.Write("encrypt.json");
108109
var _ :- expect EncryptManifest.Encrypt("encrypt.json", "decrypt.json", "java", "3.3", keyVectors);
109110
var _ :- expect DecryptManifest.Decrypt("decrypt.json", keyVectors);

TestVectors/dafny/DDBEncryption/src/WriteManifest.dfy

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,26 @@ module {:options "-functionSyntax:4"} WriteManifest {
128128
""allowedUnsignedAttributes"" : [""Stuff"", ""Junk""]
129129
}"
130130

131+
// Configuration with a new encrypted attribute not present in basic config
132+
const ExpandedConfig := @"{
133+
""attributeActionsOnEncrypt"": {
134+
""RecNum"": ""SIGN_ONLY"",
135+
""Stuff"": ""ENCRYPT_AND_SIGN"",
136+
""Junk"": ""ENCRYPT_AND_SIGN"",
137+
""NewAttribute"": ""ENCRYPT_AND_SIGN""
138+
}
139+
}"
140+
141+
// Configuration with a new sign-only attribute not present in basic config
142+
const ExpandedSignConfig := @"{
143+
""attributeActionsOnEncrypt"": {
144+
""RecNum"": ""SIGN_ONLY"",
145+
""Stuff"": ""ENCRYPT_AND_SIGN"",
146+
""Junk"": ""ENCRYPT_AND_SIGN"",
147+
""NewAttribute"": ""SIGN_ONLY""
148+
}
149+
}"
150+
131151
method TextToJson(x: string) returns (output : JSON)
132152
{
133153
var str :- expect UTF8.Encode(x);
@@ -396,8 +416,15 @@ module {:options "-functionSyntax:4"} WriteManifest {
396416
var test12 := MakeTest("12", "positive-encrypt", "Basic encrypt V2 switching1", LongerV2Config1, BasicRecord, Some(LongerV2Config2));
397417
var test13 := MakeTest("13", "positive-encrypt", "Basic encrypt V2 switching2", LongerV2Config2, BasicRecord, Some(LongerV2Config1));
398418
var test14 := MakeTest("14", "positive-encrypt", "Special characters in attribute names", SpecialConfig, SpecialRecord);
419+
420+
// Comprehensive tests for schema evolution scenarios based on AddNewAttributeExample
421+
var test15 := MakeTest("15", "positive-encrypt", "Encrypt with basic config, decrypt expecting new ENCRYPT_AND_SIGN attribute", BasicConfig, BasicRecord, Some(ExpandedConfig));
422+
var test16 := MakeTest("16", "positive-encrypt", "Encrypt with basic config, decrypt expecting new SIGN_ONLY attribute", BasicConfig, BasicRecord, Some(ExpandedSignConfig));
423+
var test17 := MakeTest("17", "positive-encrypt", "Encrypt with expanded config having new attribute, decrypt with basic config", ExpandedConfig, BasicRecord, Some(BasicConfig));
424+
var test18 := MakeTest("18", "positive-encrypt", "Encrypt with expanded SIGN_ONLY config having new attribute, decrypt with basic config", ExpandedSignConfig, BasicRecord, Some(BasicConfig));
425+
399426
var configTests := MakeConfigTests();
400-
var tests : seq<(string, JSON)> := [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12, test13, test14] + configTests;
427+
var tests : seq<(string, JSON)> := [test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12, test13, test14, test15, test16, test17, test18] + configTests;
401428
var final := Object(result + [("tests", Object(tests))]);
402429

403430
var jsonBytes :- expect API.Serialize(final);

0 commit comments

Comments
 (0)