-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathIndex.dfy
67 lines (59 loc) · 2.56 KB
/
Index.dfy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
include "LibraryIndex.dfy"
include "TestVectors.dfy"
include "WriteSetPermutations.dfy"
module WrappedDDBEncryptionMain {
import opened Wrappers
import opened DdbEncryptionTestVectors
import WriteSetPermutations
import CreateInterceptedDDBClient
import FileIO
import JSON.API
import opened JSONHelpers
import KeyVectors
import KeyVectorsTypes = AwsCryptographyMaterialProvidersTestVectorKeysTypes
const {:extern "Utils.constants", "getDefaultKeys"} DEFAULT_KEYS : string
// const DEFAULT_KEYS : string := "../../../submodules/MaterialProviders/TestVectorsAwsCryptographicMaterialProviders/dafny/TestVectorsAwsCryptographicMaterialProviders/test/keys.json"
method AddJson(prev : TestVectorConfig, file : string, keyVectors: KeyVectors.KeyVectorsClient)
returns (output : Result<TestVectorConfig, string>)
requires keyVectors.ValidState()
modifies keyVectors.Modifies
ensures keyVectors.ValidState()
{
var configBv := FileIO.ReadBytesFromFile(file);
if configBv.Failure? {
print "Failed to open ", file, " continuing anyway.\n";
return Success(MakeEmptyTestVector());
}
var configBytes := BvToBytes(configBv.value);
var json :- expect API.Deserialize(configBytes);
output := ParseTestVector(json, prev, keyVectors);
if output.Failure? {
print output.error, "\n";
}
}
method ASDF()
{
// KeyVectors client passed to every test.
// All test vectors currently use the same keys manifest, located at DEFAULT_KEYS.
// All test vectors can share this same KeyVectors client.
// To use a different keys manifest, create a new KeyVectors client.
// If you need to create a new KeyVectors client, create it as infrequently as possible.
// Creating this client frequently means JSON is parsed frequently.
// Parsing JSON is very slow in Python. Parse JSON as infrequently as possible.
var keyVectors :- expect KeyVectors.KeyVectors(
KeyVectorsTypes.KeyVectorsConfig(
keyManifestPath := DEFAULT_KEYS
)
);
WriteSetPermutations.WriteSetPermutations();
var config := MakeEmptyTestVector();
config :- expect AddJson(config, "records.json", keyVectors);
config :- expect AddJson(config, "configs.json", keyVectors);
config :- expect AddJson(config, "data.json", keyVectors);
config :- expect AddJson(config, "iotest.json", keyVectors);
config :- expect AddJson(config, "PermTest.json", keyVectors);
config.RunAllTests(keyVectors);
}
}