@@ -1208,115 +1208,95 @@ describe('encryption integration tests', () => {
1208
1208
1209
1209
await connection . openUri ( clusterUri , autoEncryptionOptions ( ) ) ;
1210
1210
1211
- afterEach ( async function ( ) {
1212
- await connection . close ( ) ;
1213
- } ) ;
1214
-
1215
- it ( 'returns a client encryption object' , async function ( ) {
1216
- assert . ok ( model . clientEncryption ( ) instanceof mdb . ClientEncryption ) ;
1217
- } ) ;
1218
1211
1219
- it ( 'the client encryption is usable as a key vault' , async function ( ) {
1220
- const clientEncryption = model . clientEncryption ( ) ;
1221
- const dataKey = await clientEncryption . createDataKey ( 'local' ) ;
1222
- const keys = await clientEncryption . getKeys ( ) . toArray ( ) ;
1212
+ } ) ;
1213
+ afterEach ( async function ( ) {
1214
+ await connection . close ( ) ;
1215
+ } ) ;
1223
1216
1224
- assert . ok ( keys . length > 0 ) ;
1217
+ it ( 'returns a client encryption object' , async function ( ) {
1218
+ assert . ok ( model . clientEncryption ( ) instanceof mdb . ClientEncryption ) ;
1219
+ } ) ;
1225
1220
1226
- const key = keys . find (
1227
- ( { _id } ) => _id . toString ( ) === dataKey . toString ( )
1228
- ) ;
1221
+ it ( 'the client encryption is usable as a key vault' , async function ( ) {
1222
+ const clientEncryption = model . clientEncryption ( ) ;
1223
+ const dataKey = await clientEncryption . createDataKey ( 'local' ) ;
1224
+ const keys = await clientEncryption . getKeys ( ) . toArray ( ) ;
1229
1225
1230
- assert . ok ( key ) ;
1231
- } ) ;
1226
+ assert . ok ( keys . length > 0 ) ;
1232
1227
1233
- it ( 'uses the same keyvaultNamespace' , async function ( ) {
1234
- assert . equal ( model . clientEncryption ( ) . _keyVaultNamespace , 'keyvault.datakeys' ) ;
1235
- } ) ;
1228
+ const key = keys . find (
1229
+ ( { _id } ) => _id . toString ( ) === dataKey . toString ( )
1230
+ ) ;
1236
1231
1237
- it ( 'uses the same kms providers' , async function ( ) {
1238
- assert . deepEqual ( model . clientEncryption ( ) . _kmsProviders , { local : { key : LOCAL_KEY } } ) ;
1239
- } ) ;
1232
+ assert . ok ( key ) ;
1233
+ } ) ;
1240
1234
1241
- it ( 'uses the same proxy options' , async function ( ) {
1242
- const options = model . collection . conn . client . options . autoEncryption ;
1243
- options . proxyOptions = { name : 'bailey' } ;
1244
- assert . deepEqual ( model . clientEncryption ( ) . _proxyOptions , { name : 'bailey' } ) ;
1245
- } ) ;
1235
+ it ( 'uses the same keyvaultNamespace' , async function ( ) {
1236
+ assert . equal ( model . clientEncryption ( ) . _keyVaultNamespace , 'keyvault.datakeys' ) ;
1237
+ } ) ;
1246
1238
1247
- it ( 'uses the same TLS options' , async function ( ) {
1248
- const options = model . collection . conn . client . options . autoEncryption ;
1249
- options . tlsOptions = {
1250
- tlsCAFile : 'some file'
1251
- } ;
1252
- assert . deepEqual ( model . clientEncryption ( ) . _tlsOptions , {
1253
- tlsCAFile : 'some file'
1254
- } ) ;
1255
- } ) ;
1239
+ it ( 'uses the same kms providers' , async function ( ) {
1240
+ assert . deepEqual ( model . clientEncryption ( ) . _kmsProviders , { local : { key : LOCAL_KEY } } ) ;
1241
+ } ) ;
1256
1242
1257
- it . skip ( 'uses the same credentialProviders' , async function ( ) {
1258
- const options = model . collection . conn . client . options . autoEncryption ;
1259
- const credentialProviders = {
1260
- aws : async ( ) => { }
1261
- } ;
1262
- options . credentialProviders = credentialProviders ;
1263
- assert . equal ( model . clientEncryption ( ) . _credentialProviders , credentialProviders ) ;
1264
- } ) ;
1243
+ it ( 'uses the same proxy options' , async function ( ) {
1244
+ const options = model . collection . conn . client . options . autoEncryption ;
1245
+ options . proxyOptions = { name : 'bailey' } ;
1246
+ assert . deepEqual ( model . clientEncryption ( ) . _proxyOptions , { name : 'bailey' } ) ;
1247
+ } ) ;
1265
1248
1266
- it ( 'uses the underlying MongoClient as the keyvault client' , async function ( ) {
1267
- const options = model . collection . conn . client . options . autoEncryption ;
1268
- assert . ok ( model . clientEncryption ( ) . _client === options . keyVaultClient , 'client not the same' ) ;
1269
- assert . equal ( model . clientEncryption ( ) . _keyVaultClient , options . keyVaultClient , 'keyvault client not the same' ) ;
1249
+ it ( 'uses the same TLS options' , async function ( ) {
1250
+ const options = model . collection . conn . client . options . autoEncryption ;
1251
+ options . tlsOptions = {
1252
+ tlsCAFile : 'some file'
1253
+ } ;
1254
+ assert . deepEqual ( model . clientEncryption ( ) . _tlsOptions , {
1255
+ tlsCAFile : 'some file'
1270
1256
} ) ;
1271
1257
} ) ;
1272
1258
1259
+ it . skip ( 'uses the same credentialProviders' , async function ( ) {
1260
+ const options = model . collection . conn . client . options . autoEncryption ;
1261
+ const credentialProviders = {
1262
+ aws : async ( ) => { }
1263
+ } ;
1264
+ options . credentialProviders = credentialProviders ;
1265
+ assert . equal ( model . clientEncryption ( ) . _credentialProviders , credentialProviders ) ;
1266
+ } ) ;
1273
1267
1268
+ it ( 'uses the underlying MongoClient as the keyvault client' , async function ( ) {
1269
+ const options = model . collection . conn . client . options . autoEncryption ;
1270
+ assert . ok ( model . clientEncryption ( ) . _client === options . keyVaultClient , 'client not the same' ) ;
1271
+ assert . equal ( model . clientEncryption ( ) . _keyVaultClient , options . keyVaultClient , 'keyvault client not the same' ) ;
1272
+ } ) ;
1274
1273
} ) ;
1275
- describe ( 'auto index creation' , function ( ) {
1276
- let connection ;
1277
-
1278
- describe ( 'CSFLE' , function ( ) {
1279
- it ( 'automatically creates indexes for CSFLE models' , async function ( ) {
1280
- connection = mongoose . createConnection ( ) ;
1281
- const schema = new Schema ( {
1282
- name : { type : String , encrypt : { keyId : [ keyId ] , algorithm } } ,
1283
- age : Number
1284
- } , { encryptionType : 'csfle' } ) ;
1285
- schema . index ( { age : 1 } ) ;
1286
- const model = connection . model ( new UUID ( ) . toHexString ( ) , schema ) ;
1287
- await connection . openUri ( clusterUri , autoEncryptionOptions ( ) ) ;
1288
-
1289
- await model . init ( ) ;
1290
1274
1291
- const indexes = await model . listIndexes ( ) ;
1292
- assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
1293
- } ) ;
1294
- } ) ;
1275
+ } ) ;
1295
1276
1277
+ describe ( 'auto index creation' , function ( ) {
1278
+ let connection ;
1296
1279
1297
- describe ( 'Queryable Encryption ' , function ( ) {
1298
- it ( 'automatically creates indexes for QE models' , async function ( ) {
1299
- connection = mongoose . createConnection ( ) ;
1300
- const schema = new Schema ( {
1301
- name : { type : String , encrypt : { keyId } } ,
1302
- age : Number
1303
- } , { encryptionType : 'queryableEncryption ' } ) ;
1304
- schema . index ( { age : 1 } ) ;
1305
- const model = connection . model ( new UUID ( ) . toHexString ( ) , schema ) ;
1306
- await connection . openUri ( clusterUri , autoEncryptionOptions ( ) ) ;
1280
+ describe ( 'CSFLE ' , function ( ) {
1281
+ it ( 'automatically creates indexes for CSFLE models' , async function ( ) {
1282
+ connection = mongoose . createConnection ( ) ;
1283
+ const schema = new Schema ( {
1284
+ name : { type : String , encrypt : { keyId : [ keyId ] , algorithm } } ,
1285
+ age : Number
1286
+ } , { encryptionType : 'csfle ' } ) ;
1287
+ schema . index ( { age : 1 } ) ;
1288
+ const model = connection . model ( new UUID ( ) . toHexString ( ) , schema ) ;
1289
+ await connection . openUri ( clusterUri , autoEncryptionOptions ( ) ) ;
1307
1290
1308
- await model . init ( ) ;
1291
+ await model . init ( ) ;
1309
1292
1310
- const indexes = await model . listIndexes ( ) ;
1311
- assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
1312
- } ) ;
1293
+ const indexes = await model . listIndexes ( ) ;
1294
+ assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
1313
1295
} ) ;
1314
1296
} ) ;
1315
1297
1316
1298
1317
1299
describe ( 'Queryable Encryption' , function ( ) {
1318
- let connection ;
1319
-
1320
1300
it ( 'automatically creates indexes for QE models' , async function ( ) {
1321
1301
connection = mongoose . createConnection ( ) ;
1322
1302
const schema = new Schema ( {
@@ -1332,11 +1312,10 @@ describe('encryption integration tests', () => {
1332
1312
const indexes = await model . listIndexes ( ) ;
1333
1313
assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
1334
1314
} ) ;
1335
-
1336
-
1337
1315
} ) ;
1338
1316
} ) ;
1339
1317
1318
+
1340
1319
describe ( 'auto collection creation' , function ( ) {
1341
1320
let connection ;
1342
1321
0 commit comments