@@ -41,26 +41,36 @@ describe.skip('MongoClient.close() Integration', () => {
4141
4242 describe ( 'MongoClientAuthProviders' , ( ) => {
4343 describe ( 'Node.js resource: Token file read' , ( ) => {
44+ let tokenFileEnvCache ;
45+
46+ beforeEach ( function ( ) {
47+ if ( process . env . AUTH === 'auth' ) {
48+ this . currentTest . skipReason = 'OIDC test environment requires auth disabled' ;
49+ return this . skip ( ) ;
50+ }
51+ tokenFileEnvCache = process . env . OIDC_TOKEN_FILE ;
52+ } ) ;
53+
54+ afterEach ( function ( ) {
55+ process . env . OIDC_TOKEN_FILE = tokenFileEnvCache ;
56+ } ) ;
57+
4458 describe ( 'when MongoClientAuthProviders is instantiated and token file read hangs' , ( ) => {
4559 it ( 'the file read is interrupted by client.close()' , async ( ) => {
4660 await runScriptAndGetProcessInfo (
4761 'token-file-read' ,
4862 config ,
49- async function run ( { MongoClient, uri, log , chai } ) {
63+ async function run ( { MongoClient, uri, chai } ) {
5064 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- } ) ;
65+ process . env . OIDC_TOKEN_FILE = infiniteFile ;
66+ const options = {
67+ authMechanismProperties : { ENVIRONMENT : 'test' } ,
68+ authMechanism : 'MONGODB-OIDC'
69+ } ;
70+ const client = new MongoClient ( uri , options ) ;
5771 client . connect ( ) ;
58-
59- log ( { ActiveResources : process . getActiveResourcesInfo ( ) } ) ;
60-
6172 chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
6273 await client . close ( ) ;
63-
6474 chai . expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
6575 }
6676 ) ;
@@ -220,7 +230,7 @@ describe.skip('MongoClient.close() Integration', () => {
220230 describe ( 'when KMSRequest reads an infinite TLS file' , ( ) => {
221231 it ( 'the file read is interrupted by client.close()' , async ( ) => {
222232 await runScriptAndGetProcessInfo (
223- 'tls-file-read' ,
233+ 'tls-file-read-auto-encryption ' ,
224234 config ,
225235 async function run ( { MongoClient, uri, log, chai, ClientEncryption, BSON } ) {
226236 const infiniteFile = '/dev/zero' ;
@@ -292,7 +302,7 @@ describe.skip('MongoClient.close() Integration', () => {
292302 await keyVaultClient . close ( ) ;
293303 await encryptedClient . close ( ) ;
294304
295- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
305+ chai . expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
296306 log ( { activeResourcesAfterClose : process . getActiveResourcesInfo ( ) } ) ;
297307
298308 const err = await insertPromise . catch ( e => e ) ;
@@ -316,7 +326,7 @@ describe.skip('MongoClient.close() Integration', () => {
316326 describe ( 'when KMSRequest reads an infinite TLS file read' , ( ) => {
317327 it ( 'the file read is interrupted by client.close()' , async ( ) => {
318328 await runScriptAndGetProcessInfo (
319- 'tls-file-read' ,
329+ 'tls-file-read-client-encryption ' ,
320330 config ,
321331 async function run ( { MongoClient, uri, log, chai, ClientEncryption, BSON } ) {
322332 const infiniteFile = '/dev/zero' ;
@@ -345,7 +355,7 @@ describe.skip('MongoClient.close() Integration', () => {
345355
346356 await keyVaultClient . close ( ) ;
347357
348- chai . expect ( process . getActiveResourcesInfo ( ) ) . to . include ( 'FSReqPromise' ) ;
358+ chai . expect ( process . getActiveResourcesInfo ( ) ) . to . not . include ( 'FSReqPromise' ) ;
349359
350360 log ( { activeResourcesAfterClose : process . getActiveResourcesInfo ( ) } ) ;
351361
0 commit comments