@@ -21,17 +21,21 @@ describe('Client Side Encryption Corpus', function () {
21
21
return EJSON . parse ( fs . readFileSync ( path . resolve ( corpusDir , filename ) ) , { relaxed : false } ) ;
22
22
}
23
23
24
+ const CSFLE_KMS_PROVIDERS = process . env . CSFLE_KMS_PROVIDERS ;
25
+ const kmsProviders = CSFLE_KMS_PROVIDERS ? EJSON . parse ( CSFLE_KMS_PROVIDERS ) : { } ;
26
+ kmsProviders . local = {
27
+ key : Buffer . from (
28
+ 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk' ,
29
+ 'base64'
30
+ )
31
+ } ;
32
+
24
33
// TODO: build this into EJSON
25
34
// TODO: make a custom chai assertion for this
26
35
function toComparableExtendedJSON ( value ) {
27
36
return JSON . parse ( EJSON . stringify ( { value } , { relaxed : false } ) ) ;
28
37
}
29
38
30
- const localKey = Buffer . from (
31
- 'Mng0NCt4ZHVUYUJCa1kxNkVyNUR1QURhZ2h2UzR2d2RrZzh0cFBwM3R6NmdWMDFBMUN3YkQ5aXRRMkhGRGdQV09wOGVNYUMxT2k3NjZKelhaQmRCZGJkTXVyZG9uSjFk' ,
32
- 'base64'
33
- ) ;
34
-
35
39
// Filters out tests that have to do with dbPointer
36
40
// TODO: fix dbpointer and get rid of this.
37
41
function filterImportedObject ( object ) {
@@ -50,6 +54,8 @@ describe('Client Side Encryption Corpus', function () {
50
54
const corpusSchema = loadCorpusData ( 'corpus-schema.json' ) ;
51
55
const corpusKeyLocal = loadCorpusData ( 'corpus-key-local.json' ) ;
52
56
const corpusKeyAws = loadCorpusData ( 'corpus-key-aws.json' ) ;
57
+ const corpusKeyAzure = loadCorpusData ( 'corpus-key-azure.json' ) ;
58
+ const corpusKeyGcp = loadCorpusData ( 'corpus-key-gcp.json' ) ;
53
59
const corpusAll = filterImportedObject ( loadCorpusData ( 'corpus.json' ) ) ;
54
60
const corpusEncryptedExpectedAll = filterImportedObject ( loadCorpusData ( 'corpus-encrypted.json' ) ) ;
55
61
@@ -66,13 +72,23 @@ describe('Client Side Encryption Corpus', function () {
66
72
] ) ;
67
73
const identifierMap = new Map ( [
68
74
[ 'local' , corpusKeyLocal . _id ] ,
69
- [ 'aws' , corpusKeyAws . _id ]
75
+ [ 'aws' , corpusKeyAws . _id ] ,
76
+ [ 'azure' , corpusKeyAzure . _id ] ,
77
+ [ 'gcp' , corpusKeyGcp . _id ]
70
78
] ) ;
71
79
const keyAltNameMap = new Map ( [
72
80
[ 'local' , 'local' ] ,
73
- [ 'aws' , 'aws' ]
81
+ [ 'aws' , 'aws' ] ,
82
+ [ 'azure' , 'azure' ] ,
83
+ [ 'gcp' , 'gcp' ]
84
+ ] ) ;
85
+ const copyOverValues = new Set ( [
86
+ '_id' ,
87
+ 'altname_aws' ,
88
+ 'altname_local' ,
89
+ 'altname_azure' ,
90
+ 'altname_gcp'
74
91
] ) ;
75
- const copyOverValues = new Set ( [ '_id' , 'altname_aws' , 'altname_local' ] ) ;
76
92
77
93
let client ;
78
94
@@ -99,7 +115,7 @@ describe('Client Side Encryption Corpus', function () {
99
115
break ;
100
116
}
101
117
default : {
102
- throw new Error ( 'how did you get here?' ) ;
118
+ throw new Error ( 'Unexpected algorithm: ' + expected . algo ) ;
103
119
}
104
120
}
105
121
@@ -119,7 +135,7 @@ describe('Client Side Encryption Corpus', function () {
119
135
} else if ( expected . allowed === false ) {
120
136
expect ( actualJSON ) . to . deep . equal ( expectedJSON ) ;
121
137
} else {
122
- throw new Error ( 'how did you get here?' ) ;
138
+ throw new Error ( 'Unexpected value for allowed: ' + expected . allowed ) ;
123
139
}
124
140
}
125
141
@@ -136,7 +152,9 @@ describe('Client Side Encryption Corpus', function () {
136
152
. then ( ( ) => keyDb . dropCollection ( keyVaultCollName ) )
137
153
. catch ( ( ) => { } )
138
154
. then ( ( ) => keyDb . collection ( keyVaultCollName ) )
139
- . then ( keyColl => keyColl . insertMany ( [ corpusKeyLocal , corpusKeyAws ] ) ) ;
155
+ . then ( keyColl =>
156
+ keyColl . insertMany ( [ corpusKeyLocal , corpusKeyAws , corpusKeyAzure , corpusKeyGcp ] )
157
+ ) ;
140
158
} ) ;
141
159
} ) ;
142
160
@@ -179,7 +197,7 @@ describe('Client Side Encryption Corpus', function () {
179
197
// Configure both objects with ``keyVaultNamespace`` set to ``keyvault.datakeys``.
180
198
const autoEncryption = {
181
199
keyVaultNamespace,
182
- kmsProviders : this . configuration . kmsProviders ( null , localKey )
200
+ kmsProviders
183
201
} ;
184
202
if ( useClientSideSchema ) {
185
203
autoEncryption . schemaMap = {
@@ -192,7 +210,7 @@ describe('Client Side Encryption Corpus', function () {
192
210
clientEncryption = new mongodbClientEncryption . ClientEncryption ( client , {
193
211
bson : BSON ,
194
212
keyVaultNamespace,
195
- kmsProviders : this . configuration . kmsProviders ( null , localKey )
213
+ kmsProviders
196
214
} ) ;
197
215
} ) ;
198
216
} ) ;
@@ -257,7 +275,7 @@ describe('Client Side Encryption Corpus', function () {
257
275
} else if ( field . identifier === 'altname' ) {
258
276
encryptOptions . keyAltName = keyAltNameMap . get ( field . kms ) ;
259
277
} else {
260
- throw new Error ( 'wtf how did u get here?' ) ;
278
+ throw new Error ( 'Unexpected identifier: ' + field . identifier ) ;
261
279
}
262
280
263
281
return Promise . resolve ( )
@@ -282,7 +300,7 @@ describe('Client Side Encryption Corpus', function () {
282
300
) ;
283
301
}
284
302
285
- throw new Error ( 'how did u get here?' ) ;
303
+ throw new Error ( 'Unexpected method: ' + field . method ) ;
286
304
} ) ;
287
305
} )
288
306
. then ( ( ) => {
0 commit comments