@@ -417,6 +417,70 @@ describe('OIDC Auth Spec Tests', function () {
417417 } ) ;
418418 } ) ;
419419
420+ describe ( '4.1 Reauthentication Succeeds (promoteValues: false)' , function ( ) {
421+ let utilClient : MongoClient ;
422+ const callbackSpy = sinon . spy ( createCallback ( ) ) ;
423+ // Create an OIDC configured client.
424+ // Set a fail point for find commands of the form:
425+ // {
426+ // configureFailPoint: "failCommand",
427+ // mode: {
428+ // times: 1
429+ // },
430+ // data: {
431+ // failCommands: [
432+ // "find"
433+ // ],
434+ // errorCode: 391 // ReauthenticationRequired
435+ // }
436+ // }
437+ // Perform a find operation that succeeds.
438+ // Assert that the callback was called 2 times (once during the connection handshake, and again during reauthentication).
439+ // Close the client.
440+ beforeEach ( async function ( ) {
441+ client = new MongoClient ( uriSingle , {
442+ authMechanismProperties : {
443+ OIDC_CALLBACK : callbackSpy
444+ } ,
445+ retryReads : false ,
446+ promoteValues : false
447+ } ) ;
448+ utilClient = new MongoClient ( uriSingle , {
449+ authMechanismProperties : {
450+ OIDC_CALLBACK : createCallback ( )
451+ } ,
452+ retryReads : false
453+ } ) ;
454+ collection = client . db ( 'test' ) . collection ( 'test' ) ;
455+ await utilClient
456+ . db ( )
457+ . admin ( )
458+ . command ( {
459+ configureFailPoint : 'failCommand' ,
460+ mode : {
461+ times : 1
462+ } ,
463+ data : {
464+ failCommands : [ 'find' ] ,
465+ errorCode : 391
466+ }
467+ } ) ;
468+ } ) ;
469+
470+ afterEach ( async function ( ) {
471+ await utilClient . db ( ) . admin ( ) . command ( {
472+ configureFailPoint : 'failCommand' ,
473+ mode : 'off'
474+ } ) ;
475+ await utilClient . close ( ) ;
476+ } ) ;
477+
478+ it ( 'successfully authenticates' , async function ( ) {
479+ await collection . findOne ( ) ;
480+ expect ( callbackSpy ) . to . have . been . calledTwice ;
481+ } ) ;
482+ } ) ;
483+
420484 describe ( '4.2 Read Commands Fail If Reauthentication Fails' , function ( ) {
421485 let utilClient : MongoClient ;
422486 const callbackSpy = sinon . spy ( createBadCallback ( ) ) ;
0 commit comments