@@ -24,17 +24,21 @@ describe('Client Side Encryption Corpus', function() {
24
24
return EJSON . parse ( fs . readFileSync ( path . resolve ( corpusDir , filename ) , { strict : true } ) ) ;
25
25
}
26
26
27
+ const CSFLE_KMS_PROVIDERS = process . env . CSFLE_KMS_PROVIDERS ;
28
+ const kmsProviders = CSFLE_KMS_PROVIDERS ? EJSON . parse ( CSFLE_KMS_PROVIDERS ) : { } ;
29
+ kmsProviders . local = {
30
+ key : Buffer . from (
31
+ 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk' ,
32
+ 'base64'
33
+ )
34
+ } ;
35
+
27
36
// TODO: build this into EJSON
28
37
// TODO: make a custom chai assertion for this
29
38
function toComparableExtendedJSON ( value ) {
30
39
return JSON . parse ( EJSON . stringify ( { value } , { strict : true } ) ) ;
31
40
}
32
41
33
- const localKey = Buffer . from (
34
- 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk' ,
35
- 'base64'
36
- ) ;
37
-
38
42
// Filters out tests that have to do with dbPointer
39
43
// TODO: fix dbpointer and get rid of this.
40
44
function filterImportedObject ( object ) {
@@ -53,6 +57,8 @@ describe('Client Side Encryption Corpus', function() {
53
57
const corpusSchema = loadCorpusData ( 'corpus-schema.json' ) ;
54
58
const corpusKeyLocal = loadCorpusData ( 'corpus-key-local.json' ) ;
55
59
const corpusKeyAws = loadCorpusData ( 'corpus-key-aws.json' ) ;
60
+ const corpusKeyAzure = loadCorpusData ( 'corpus-key-azure.json' ) ;
61
+ const corpusKeyGcp = loadCorpusData ( 'corpus-key-gcp.json' ) ;
56
62
const corpusAll = filterImportedObject ( loadCorpusData ( 'corpus.json' ) ) ;
57
63
const corpusEncryptedExpectedAll = filterImportedObject ( loadCorpusData ( 'corpus-encrypted.json' ) ) ;
58
64
@@ -69,13 +75,23 @@ describe('Client Side Encryption Corpus', function() {
69
75
] ) ;
70
76
const identifierMap = new Map ( [
71
77
[ 'local' , corpusKeyLocal . _id ] ,
72
- [ 'aws' , corpusKeyAws . _id ]
78
+ [ 'aws' , corpusKeyAws . _id ] ,
79
+ [ 'azure' , corpusKeyAzure . _id ] ,
80
+ [ 'gcp' , corpusKeyGcp . _id ]
73
81
] ) ;
74
82
const keyAltNameMap = new Map ( [
75
83
[ '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'
77
94
] ) ;
78
- const copyOverValues = new Set ( [ '_id' , 'altname_aws' , 'altname_local' ] ) ;
79
95
80
96
let client ;
81
97
@@ -102,7 +118,7 @@ describe('Client Side Encryption Corpus', function() {
102
118
break ;
103
119
}
104
120
default : {
105
- throw new Error ( 'how did you get here?' ) ;
121
+ throw new Error ( 'Unexpected algorithm: ' + expected . algo ) ;
106
122
}
107
123
}
108
124
@@ -122,7 +138,7 @@ describe('Client Side Encryption Corpus', function() {
122
138
} else if ( expected . allowed === false ) {
123
139
expect ( actualJSON ) . to . deep . equal ( expectedJSON ) ;
124
140
} else {
125
- throw new Error ( 'how did you get here?' ) ;
141
+ throw new Error ( 'Unexpected value for allowed: ' + expected . allowed ) ;
126
142
}
127
143
}
128
144
@@ -142,7 +158,9 @@ describe('Client Side Encryption Corpus', function() {
142
158
. then ( ( ) => keyDb . dropCollection ( keyVaultCollName ) )
143
159
. catch ( ( ) => { } )
144
160
. then ( ( ) => keyDb . collection ( keyVaultCollName ) )
145
- . then ( keyColl => keyColl . insertMany ( [ corpusKeyLocal , corpusKeyAws ] ) ) ;
161
+ . then ( keyColl =>
162
+ keyColl . insertMany ( [ corpusKeyLocal , corpusKeyAws , corpusKeyAzure , corpusKeyGcp ] )
163
+ ) ;
146
164
} ) ;
147
165
} ) ;
148
166
@@ -185,7 +203,7 @@ describe('Client Side Encryption Corpus', function() {
185
203
// Configure both objects with ``keyVaultNamespace`` set to ``keyvault.datakeys``.
186
204
const autoEncryption = {
187
205
keyVaultNamespace,
188
- kmsProviders : this . configuration . kmsProviders ( null , localKey )
206
+ kmsProviders
189
207
} ;
190
208
if ( useClientSideSchema ) {
191
209
autoEncryption . schemaMap = {
@@ -204,7 +222,7 @@ describe('Client Side Encryption Corpus', function() {
204
222
return clientEncrypted . connect ( ) . then ( ( ) => {
205
223
clientEncryption = new mongodbClientEncryption . ClientEncryption ( client , {
206
224
keyVaultNamespace,
207
- kmsProviders : this . configuration . kmsProviders ( null , localKey )
225
+ kmsProviders
208
226
} ) ;
209
227
} ) ;
210
228
} ) ;
@@ -269,7 +287,7 @@ describe('Client Side Encryption Corpus', function() {
269
287
} else if ( field . identifier === 'altname' ) {
270
288
encryptOptions . keyAltName = keyAltNameMap . get ( field . kms ) ;
271
289
} else {
272
- throw new Error ( 'wtf how did u get here?' ) ;
290
+ throw new Error ( 'Unexpected identifier: ' + field . identifier ) ;
273
291
}
274
292
275
293
return Promise . resolve ( )
@@ -294,7 +312,7 @@ describe('Client Side Encryption Corpus', function() {
294
312
) ;
295
313
}
296
314
297
- throw new Error ( 'how did u get here?' ) ;
315
+ throw new Error ( 'Unexpected method: ' + field . method ) ;
298
316
} ) ;
299
317
} )
300
318
. then ( ( ) => {
0 commit comments