Skip to content

Commit 9463c19

Browse files
committed
implemented all changes needed to test runners
1 parent 48beda7 commit 9463c19

File tree

5 files changed

+175
-72
lines changed

5 files changed

+175
-72
lines changed

test/functional/client_side_encryption/corpus.test.js

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,21 @@ describe('Client Side Encryption Corpus', function() {
2424
return EJSON.parse(fs.readFileSync(path.resolve(corpusDir, filename), { strict: true }));
2525
}
2626

27+
const CSFLE_KMS_PROVIDERS = process.env.CSFLE_KMS_PROVIDERS || 'NOT_PROVIDED';
28+
const kmsProviders = EJSON.parse(CSFLE_KMS_PROVIDERS);
29+
kmsProviders.local = {
30+
key: Buffer.from(
31+
'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk',
32+
'base64'
33+
)
34+
};
35+
2736
// TODO: build this into EJSON
2837
// TODO: make a custom chai assertion for this
2938
function toComparableExtendedJSON(value) {
3039
return JSON.parse(EJSON.stringify({ value }, { strict: true }));
3140
}
3241

33-
const localKey = Buffer.from(
34-
'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk',
35-
'base64'
36-
);
37-
3842
// Filters out tests that have to do with dbPointer
3943
// TODO: fix dbpointer and get rid of this.
4044
function filterImportedObject(object) {
@@ -53,6 +57,8 @@ describe('Client Side Encryption Corpus', function() {
5357
const corpusSchema = loadCorpusData('corpus-schema.json');
5458
const corpusKeyLocal = loadCorpusData('corpus-key-local.json');
5559
const corpusKeyAws = loadCorpusData('corpus-key-aws.json');
60+
const corpusKeyAzure = loadCorpusData('corpus-key-azure.json');
61+
const corpusKeyGcp = loadCorpusData('corpus-key-gcp.json');
5662
const corpusAll = filterImportedObject(loadCorpusData('corpus.json'));
5763
const corpusEncryptedExpectedAll = filterImportedObject(loadCorpusData('corpus-encrypted.json'));
5864

@@ -69,13 +75,23 @@ describe('Client Side Encryption Corpus', function() {
6975
]);
7076
const identifierMap = new Map([
7177
['local', corpusKeyLocal._id],
72-
['aws', corpusKeyAws._id]
78+
['aws', corpusKeyAws._id],
79+
['azure', corpusKeyAzure._id],
80+
['gcp', corpusKeyGcp._id]
7381
]);
7482
const keyAltNameMap = new Map([
7583
['local', 'local'],
76-
['aws', 'aws']
84+
['aws', 'aws'],
85+
['azure', 'azure'],
86+
['gcp', 'gcp']
87+
]);
88+
const copyOverValues = new Set([
89+
'_id',
90+
'altname_aws',
91+
'altname_local',
92+
'altname_azure',
93+
'altname_gcp'
7794
]);
78-
const copyOverValues = new Set(['_id', 'altname_aws', 'altname_local']);
7995

8096
let client;
8197

@@ -102,7 +118,7 @@ describe('Client Side Encryption Corpus', function() {
102118
break;
103119
}
104120
default: {
105-
throw new Error('how did you get here?');
121+
throw new Error('Unexpected algorithm: ' + expected.algo);
106122
}
107123
}
108124

@@ -122,7 +138,7 @@ describe('Client Side Encryption Corpus', function() {
122138
} else if (expected.allowed === false) {
123139
expect(actualJSON).to.deep.equal(expectedJSON);
124140
} else {
125-
throw new Error('how did you get here?');
141+
throw new Error('Unexpected value for allowed: ' + expected.allowed);
126142
}
127143
}
128144

@@ -142,7 +158,9 @@ describe('Client Side Encryption Corpus', function() {
142158
.then(() => keyDb.dropCollection(keyVaultCollName))
143159
.catch(() => {})
144160
.then(() => keyDb.collection(keyVaultCollName))
145-
.then(keyColl => keyColl.insertMany([corpusKeyLocal, corpusKeyAws]));
161+
.then(keyColl =>
162+
keyColl.insertMany([corpusKeyLocal, corpusKeyAws, corpusKeyAzure, corpusKeyGcp])
163+
);
146164
});
147165
});
148166

@@ -185,7 +203,7 @@ describe('Client Side Encryption Corpus', function() {
185203
// Configure both objects with ``keyVaultNamespace`` set to ``keyvault.datakeys``.
186204
const autoEncryption = {
187205
keyVaultNamespace,
188-
kmsProviders: this.configuration.kmsProviders(null, localKey)
206+
kmsProviders
189207
};
190208
if (useClientSideSchema) {
191209
autoEncryption.schemaMap = {
@@ -204,7 +222,7 @@ describe('Client Side Encryption Corpus', function() {
204222
return clientEncrypted.connect().then(() => {
205223
clientEncryption = new mongodbClientEncryption.ClientEncryption(client, {
206224
keyVaultNamespace,
207-
kmsProviders: this.configuration.kmsProviders(null, localKey)
225+
kmsProviders
208226
});
209227
});
210228
});
@@ -269,7 +287,7 @@ describe('Client Side Encryption Corpus', function() {
269287
} else if (field.identifier === 'altname') {
270288
encryptOptions.keyAltName = keyAltNameMap.get(field.kms);
271289
} else {
272-
throw new Error('wtf how did u get here?');
290+
throw new Error('Unexpected identifier: ' + field.identifier);
273291
}
274292

275293
return Promise.resolve()
@@ -294,7 +312,7 @@ describe('Client Side Encryption Corpus', function() {
294312
);
295313
}
296314

297-
throw new Error('how did u get here?');
315+
throw new Error('Unexpected method: ' + field.method);
298316
});
299317
})
300318
.then(() => {

0 commit comments

Comments
 (0)