@@ -40,6 +40,7 @@ const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) =>
40
40
} ;
41
41
42
42
const noop = ( ) => { } ;
43
+ /** @type { MongoDBMetadataUI } */
43
44
const metadata = {
44
45
requires : {
45
46
clientSideEncryption : true ,
@@ -1146,47 +1147,43 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
1146
1147
) ;
1147
1148
} ) ;
1148
1149
1149
- beforeEach ( 'precondition: the shared library must NOT be loaded' , function ( ) {
1150
- const { cryptSharedLibPath } = getEncryptExtraOptions ( ) ;
1151
- if ( cryptSharedLibPath ) {
1152
- this . currentTest . skipReason =
1153
- 'test requires that the shared library NOT is present, but CRYPT_SHARED_LIB_PATH is set.' ;
1154
- this . skip ( ) ;
1155
- }
1156
- // the presence of the shared library can only be reliably determine after
1157
- // libmongocrypt has been initialized, and can be detected with the
1158
- // cryptSharedLibVersionInfo getter on the autoEncrypter.
1159
- expect ( ! ! clientEncrypted . autoEncrypter . cryptSharedLibVersionInfo ) . to . be . false ;
1160
- } ) ;
1161
-
1162
1150
afterEach ( async function ( ) {
1163
1151
await clientEncrypted ?. close ( ) ;
1164
1152
} ) ;
1165
1153
1166
- it ( 'does not spawn mongocryptd' , metadata , async function ( ) {
1167
- // Use client_encrypted to insert the document {"encrypted": "test"} into db.coll.
1168
- // Expect a server selection error propagated from the internal MongoClient failing to connect to mongocryptd on port 27021.
1169
- const insertError = await clientEncrypted
1170
- . db ( dataDbName )
1171
- . collection ( dataCollName )
1172
- . insertOne ( { encrypted : 'test' } )
1173
- . catch ( e => e ) ;
1154
+ it (
1155
+ 'does not spawn mongocryptd' ,
1156
+ {
1157
+ requires : {
1158
+ ...metadata . requires ,
1159
+ crypt_shared : 'enabled'
1160
+ }
1161
+ } ,
1162
+ async function ( ) {
1163
+ // Use client_encrypted to insert the document {"encrypted": "test"} into db.coll.
1164
+ // Expect a server selection error propagated from the internal MongoClient failing to connect to mongocryptd on port 27021.
1165
+ const insertError = await clientEncrypted
1166
+ . db ( dataDbName )
1167
+ . collection ( dataCollName )
1168
+ . insertOne ( { encrypted : 'test' } )
1169
+ . catch ( e => e ) ;
1174
1170
1175
- expect ( insertError )
1176
- . to . be . instanceOf ( MongoRuntimeError )
1177
- . to . match (
1178
- / U n a b l e t o c o n n e c t t o ` m o n g o c r y p t d ` , p l e a s e m a k e s u r e i t i s r u n n i n g o r i n y o u r P A T H f o r a u t o - s p a w n /
1179
- ) ;
1171
+ expect ( insertError )
1172
+ . to . be . instanceOf ( MongoRuntimeError )
1173
+ . to . match (
1174
+ / U n a b l e t o c o n n e c t t o ` m o n g o c r y p t d ` , p l e a s e m a k e s u r e i t i s r u n n i n g o r i n y o u r P A T H f o r a u t o - s p a w n /
1175
+ ) ;
1180
1176
1181
- const { cause } = insertError ;
1177
+ const { cause } = insertError ;
1182
1178
1183
- expect ( cause ) . to . be . instanceOf ( MongoServerSelectionError ) ;
1184
- expect ( cause , 'Error must contain ECONNREFUSED' ) . to . satisfy (
1185
- error =>
1186
- / E C O N N R E F U S E D / . test ( error . message ) ||
1187
- ! ! error . cause ?. cause ?. errors ?. every ( e => e . code === 'ECONNREFUSED' )
1188
- ) ;
1189
- } ) ;
1179
+ expect ( cause ) . to . be . instanceOf ( MongoServerSelectionError ) ;
1180
+ expect ( cause , 'Error must contain ECONNREFUSED' ) . to . satisfy (
1181
+ error =>
1182
+ / E C O N N R E F U S E D / . test ( error . message ) ||
1183
+ ! ! error . cause ?. cause ?. errors ?. every ( e => e . code === 'ECONNREFUSED' )
1184
+ ) ;
1185
+ }
1186
+ ) ;
1190
1187
} ) ;
1191
1188
1192
1189
describe ( 'via bypassAutoEncryption' , function ( ) {
@@ -1241,19 +1238,6 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
1241
1238
expect ( insertResult ) . to . have . property ( 'insertedId' ) ;
1242
1239
} ) ;
1243
1240
1244
- beforeEach ( 'precondition: the shared library must NOT be loaded' , function ( ) {
1245
- const { cryptSharedLibPath } = getEncryptExtraOptions ( ) ;
1246
- if ( cryptSharedLibPath ) {
1247
- this . currentTest . skipReason =
1248
- 'test requires that the shared library NOT is present, but CRYPT_SHARED_LIB_PATH is set.' ;
1249
- this . skip ( ) ;
1250
- }
1251
- // the presence of the shared library can only be reliably determine after
1252
- // libmongocrypt has been initialized, and can be detected with the
1253
- // cryptSharedLibVersionInfo getter on the autoEncrypter.
1254
- expect ( ! ! clientEncrypted . autoEncrypter . cryptSharedLibVersionInfo ) . to . be . false ;
1255
- } ) ;
1256
-
1257
1241
afterEach ( async function ( ) {
1258
1242
await clientEncrypted ?. close ( ) ;
1259
1243
await client ?. close ( ) ;
@@ -1262,34 +1246,34 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
1262
1246
// Validate that mongocryptd was not spawned. Create a MongoClient to localhost:27021
1263
1247
// (or whatever was passed via --port) with serverSelectionTimeoutMS=1000. Run a handshake
1264
1248
// command and ensure it fails with a server selection timeout.
1265
- it ( 'does not spawn mongocryptd' , metadata , async function ( ) {
1266
- client = new MongoClient ( 'mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000' ) ;
1267
- const error = await client . connect ( ) . catch ( e => e ) ;
1249
+ it (
1250
+ 'does not spawn mongocryptd' ,
1251
+ {
1252
+ requires : {
1253
+ ...metadata . requires ,
1254
+ crypt_shared : 'enabled'
1255
+ }
1256
+ } ,
1257
+ async function ( ) {
1258
+ client = new MongoClient ( 'mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000' ) ;
1259
+ const error = await client . connect ( ) . catch ( e => e ) ;
1268
1260
1269
- expect ( error , 'Error MUST be a MongoServerSelectionError error' ) . to . be . instanceOf (
1270
- MongoServerSelectionError
1271
- ) ;
1272
- expect ( error , 'Error MUST contain ECONNREFUSED information' ) . to . satisfy (
1273
- error =>
1274
- / E C O N N R E F U S E D / . test ( error . message ) ||
1275
- ! ! error . cause ?. cause ?. errors ?. every ( e => e . code === 'ECONNREFUSED' )
1276
- ) ;
1277
- } ) ;
1261
+ expect ( error , 'Error MUST be a MongoServerSelectionError error' ) . to . be . instanceOf (
1262
+ MongoServerSelectionError
1263
+ ) ;
1264
+ expect ( error , 'Error MUST contain ECONNREFUSED information' ) . to . satisfy (
1265
+ error =>
1266
+ / E C O N N R E F U S E D / . test ( error . message ) ||
1267
+ ! ! error . cause ?. cause ?. errors ?. every ( e => e . code === 'ECONNREFUSED' )
1268
+ ) ;
1269
+ }
1270
+ ) ;
1278
1271
} ) ;
1279
1272
1280
1273
describe ( 'via loading shared library' , function ( ) {
1281
1274
let clientEncrypted ;
1282
1275
let client ;
1283
1276
1284
- beforeEach ( function ( ) {
1285
- const { cryptSharedLibPath } = getEncryptExtraOptions ( ) ;
1286
- if ( ! cryptSharedLibPath ) {
1287
- this . currentTest . skipReason =
1288
- 'test requires that the shared library is present, but CRYPT_SHARED_LIB_PATH is unset.' ;
1289
- this . skip ( ) ;
1290
- }
1291
- } ) ;
1292
-
1293
1277
// Setup
1294
1278
beforeEach ( async function ( ) {
1295
1279
const { cryptSharedLibPath } = getEncryptExtraOptions ( ) ;
@@ -1345,11 +1329,23 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
1345
1329
// 4. Validate that mongocryptd was not spawned. Create a MongoClient to localhost:27021 (or
1346
1330
// whatever was passed via `--port` with serverSelectionTimeoutMS=1000.) Run a handshake
1347
1331
// command and ensure it fails with a server selection timeout
1348
- it ( 'should not spawn mongocryptd' , metadata , async function ( ) {
1349
- client = new MongoClient ( 'mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000' ) ;
1350
- const error = await client . connect ( ) . catch ( e => e ) ;
1351
- expect ( error ) . to . be . instanceOf ( MongoServerSelectionError , / ' S e r v e r s e l e c t i o n t i m e d o u t ' / i) ;
1352
- } ) ;
1332
+ it (
1333
+ 'should not spawn mongocryptd' ,
1334
+ {
1335
+ requires : {
1336
+ ...metadata . requires ,
1337
+ crypt_shared : 'enabled'
1338
+ }
1339
+ } ,
1340
+ async function ( ) {
1341
+ client = new MongoClient ( 'mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000' ) ;
1342
+ const error = await client . connect ( ) . catch ( e => e ) ;
1343
+ expect ( error ) . to . be . instanceOf (
1344
+ MongoServerSelectionError ,
1345
+ / ' S e r v e r s e l e c t i o n t i m e d o u t ' / i
1346
+ ) ;
1347
+ }
1348
+ ) ;
1353
1349
} ) ;
1354
1350
} ) ;
1355
1351
0 commit comments