@@ -18,14 +18,13 @@ describe.skip('MongoClient.close() Integration', () => {
18
18
await runScriptAndGetProcessInfo (
19
19
'tls-file-read' ,
20
20
config ,
21
- async function run ( { MongoClient, uri, log , chai } ) {
21
+ async function run ( { MongoClient, uri, expect } ) {
22
22
const infiniteFile = '/dev/zero' ;
23
23
const client = new MongoClient ( uri , { tlsCertificateKeyFile : infiniteFile } ) ;
24
24
client . connect ( ) ;
25
- log ( { ActiveResources : process . getActiveResourcesInfo ( ) } ) ;
26
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
25
+ expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
27
26
await client . close ( ) ;
28
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
27
+ expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
29
28
}
30
29
) ;
31
30
} ) ;
@@ -41,27 +40,37 @@ describe.skip('MongoClient.close() Integration', () => {
41
40
42
41
describe ( 'MongoClientAuthProviders' , ( ) => {
43
42
describe ( 'Node.js resource: Token file read' , ( ) => {
43
+ let tokenFileEnvCache ;
44
+
45
+ beforeEach ( function ( ) {
46
+ if ( process . env . AUTH === 'auth' ) {
47
+ this . currentTest . skipReason = 'OIDC test environment requires auth disabled' ;
48
+ return this . skip ( ) ;
49
+ }
50
+ tokenFileEnvCache = process . env . OIDC_TOKEN_FILE ;
51
+ } ) ;
52
+
53
+ afterEach ( function ( ) {
54
+ process . env . OIDC_TOKEN_FILE = tokenFileEnvCache ;
55
+ } ) ;
56
+
44
57
describe ( 'when MongoClientAuthProviders is instantiated and token file read hangs' , ( ) => {
45
58
it ( 'the file read is interrupted by client.close()' , async ( ) => {
46
59
await runScriptAndGetProcessInfo (
47
60
'token-file-read' ,
48
61
config ,
49
- async function run ( { MongoClient, uri, log , chai } ) {
62
+ async function run ( { MongoClient, uri, expect } ) {
50
63
const infiniteFile = '/dev/zero' ;
51
- log ( { ActiveResources : process . getActiveResourcesInfo ( ) } ) ;
52
-
53
- // speculative authentication call to getToken() is during initial handshake
54
- const client = new MongoClient ( uri , {
55
- authMechanismProperties : { TOKEN_RESOURCE : infiniteFile }
56
- } ) ;
64
+ process . env . OIDC_TOKEN_FILE = infiniteFile ;
65
+ const options = {
66
+ authMechanismProperties : { ENVIRONMENT : 'test' } ,
67
+ authMechanism : 'MONGODB-OIDC'
68
+ } ;
69
+ const client = new MongoClient ( uri , options ) ;
57
70
client . connect ( ) ;
58
-
59
- log ( { ActiveResources : process . getActiveResourcesInfo ( ) } ) ;
60
-
61
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
71
+ expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
62
72
await client . close ( ) ;
63
-
64
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
73
+ expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
65
74
}
66
75
) ;
67
76
} ) ;
@@ -220,9 +229,9 @@ describe.skip('MongoClient.close() Integration', () => {
220
229
describe ( 'when KMSRequest reads an infinite TLS file' , ( ) => {
221
230
it ( 'the file read is interrupted by client.close()' , async ( ) => {
222
231
await runScriptAndGetProcessInfo (
223
- 'tls-file-read' ,
232
+ 'tls-file-read-auto-encryption ' ,
224
233
config ,
225
- async function run ( { MongoClient, uri, log , chai , ClientEncryption, BSON } ) {
234
+ async function run ( { MongoClient, uri, expect , ClientEncryption, BSON } ) {
226
235
const infiniteFile = '/dev/zero' ;
227
236
228
237
const kmsProviders = BSON . EJSON . parse ( process . env . CSFLE_KMS_PROVIDERS ) ;
@@ -281,23 +290,23 @@ describe.skip('MongoClient.close() Integration', () => {
281
290
const encryptedClient = new MongoClient ( uri , encryptionOptions ) ;
282
291
await encryptedClient . connect ( ) ;
283
292
293
+ expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
294
+
284
295
const insertPromise = encryptedClient
285
296
. db ( 'db' )
286
297
. collection ( 'coll' )
287
298
. insertOne ( { a : 1 } ) ;
288
299
289
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
290
- log ( { activeResourcesBeforeClose : process . getActiveResourcesInfo ( ) } ) ;
300
+ expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
291
301
292
302
await keyVaultClient . close ( ) ;
293
303
await encryptedClient . close ( ) ;
294
304
295
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
296
- log ( { activeResourcesAfterClose : process . getActiveResourcesInfo ( ) } ) ;
305
+ expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
297
306
298
307
const err = await insertPromise . catch ( e => e ) ;
299
- chai . expect ( err ) . to . exist ;
300
- chai . expect ( err . errmsg ) . to . contain ( 'Error in KMS response' ) ;
308
+ expect ( err ) . to . exist ;
309
+ expect ( err . errmsg ) . to . contain ( 'Error in KMS response' ) ;
301
310
}
302
311
) ;
303
312
} ) ;
@@ -316,9 +325,9 @@ describe.skip('MongoClient.close() Integration', () => {
316
325
describe ( 'when KMSRequest reads an infinite TLS file read' , ( ) => {
317
326
it ( 'the file read is interrupted by client.close()' , async ( ) => {
318
327
await runScriptAndGetProcessInfo (
319
- 'tls-file-read' ,
328
+ 'tls-file-read-client-encryption ' ,
320
329
config ,
321
- async function run ( { MongoClient, uri, log , chai , ClientEncryption, BSON } ) {
330
+ async function run ( { MongoClient, uri, expect , ClientEncryption, BSON } ) {
322
331
const infiniteFile = '/dev/zero' ;
323
332
const kmsProviders = BSON . EJSON . parse ( process . env . CSFLE_KMS_PROVIDERS ) ;
324
333
const masterKey = {
@@ -339,19 +348,15 @@ describe.skip('MongoClient.close() Integration', () => {
339
348
340
349
const dataKeyPromise = clientEncryption . createDataKey ( provider , { masterKey } ) ;
341
350
342
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
343
-
344
- log ( { activeResourcesBeforeClose : process . getActiveResourcesInfo ( ) } ) ;
351
+ expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
345
352
346
353
await keyVaultClient . close ( ) ;
347
354
348
- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
349
-
350
- log ( { activeResourcesAfterClose : process . getActiveResourcesInfo ( ) } ) ;
355
+ expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
351
356
352
357
const err = await dataKeyPromise . catch ( e => e ) ;
353
- chai . expect ( err ) . to . exist ;
354
- chai . expect ( err . errmsg ) . to . contain ( 'Error in KMS response' ) ;
358
+ expect ( err ) . to . exist ;
359
+ expect ( err . errmsg ) . to . contain ( 'Error in KMS response' ) ;
355
360
}
356
361
) ;
357
362
} ) ;
0 commit comments