@@ -1208,115 +1208,95 @@ describe('encryption integration tests', () => {
12081208
12091209 await connection . openUri ( clusterUri , autoEncryptionOptions ( ) ) ;
12101210
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- } ) ;
12181211
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+ } ) ;
12231216
1224- assert . ok ( keys . length > 0 ) ;
1217+ it ( 'returns a client encryption object' , async function ( ) {
1218+ assert . ok ( model . clientEncryption ( ) instanceof mdb . ClientEncryption ) ;
1219+ } ) ;
12251220
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 ( ) ;
12291225
1230- assert . ok ( key ) ;
1231- } ) ;
1226+ assert . ok ( keys . length > 0 ) ;
12321227
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+ ) ;
12361231
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+ } ) ;
12401234
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+ } ) ;
12461238
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+ } ) ;
12561242
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+ } ) ;
12651248
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'
12701256 } ) ;
12711257 } ) ;
12721258
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+ } ) ;
12731267
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+ } ) ;
12741273 } ) ;
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 ( ) ;
12901274
1291- const indexes = await model . listIndexes ( ) ;
1292- assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
1293- } ) ;
1294- } ) ;
1275+ } ) ;
12951276
1277+ describe ( 'auto index creation' , function ( ) {
1278+ let connection ;
12961279
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 ( ) ) ;
13071290
1308- await model . init ( ) ;
1291+ await model . init ( ) ;
13091292
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' ) ) ;
13131295 } ) ;
13141296 } ) ;
13151297
13161298
13171299 describe ( 'Queryable Encryption' , function ( ) {
1318- let connection ;
1319-
13201300 it ( 'automatically creates indexes for QE models' , async function ( ) {
13211301 connection = mongoose . createConnection ( ) ;
13221302 const schema = new Schema ( {
@@ -1332,11 +1312,10 @@ describe('encryption integration tests', () => {
13321312 const indexes = await model . listIndexes ( ) ;
13331313 assert . ok ( indexes . find ( ( { name } ) => name === 'age_1' ) ) ;
13341314 } ) ;
1335-
1336-
13371315 } ) ;
13381316 } ) ;
13391317
1318+
13401319 describe ( 'auto collection creation' , function ( ) {
13411320 let connection ;
13421321
0 commit comments