@@ -473,6 +473,36 @@ public async Task Speculative_authentication_should_be_ignored_on_reauthenticati
473
473
eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandSucceededEvent > ( ) ;
474
474
}
475
475
476
+ // 4.5 Reauthentication Succeeds when a Session is involved
477
+ // https://github.com/mongodb/specifications/blob/668992950d975d3163e538849dd20383a214fc37/source/auth/tests/mongodb-oidc.md?plain=1#L235
478
+ [ Theory ]
479
+ [ ParameterAttributeData ]
480
+ public async Task Reauthentication_Succeeds_when_Session_involved ( [ Values ( false , true ) ] bool async )
481
+ {
482
+ EnsureOidcIsConfigured ( "test" ) ;
483
+
484
+ var callbackMock = new Mock < IOidcCallback > ( ) ;
485
+ // configure mock with valid access token
486
+ ConfigureOidcCallback ( callbackMock , GetAccessTokenValue ( ) ) ;
487
+ var credential = MongoCredential . CreateOidcCredential ( callbackMock . Object ) ;
488
+ var ( collection , client , eventCapturer ) = CreateOidcTestObjects ( credential ) ;
489
+
490
+ using ( ConfigureFailPoint ( 1 , ( int ) ServerErrorCode . ReauthenticationRequired , "find" ) )
491
+ {
492
+ var session = client . StartSession ( ) ;
493
+ _ = async
494
+ ? await collection . FindAsync ( session , Builders < BsonDocument > . Filter . Empty )
495
+ : collection . FindSync ( session , Builders < BsonDocument > . Filter . Empty ) ;
496
+ }
497
+
498
+ VerifyCallbackUsage ( callbackMock , async , Times . Exactly ( 2 ) ) ;
499
+ eventCapturer . Count . Should ( ) . Be( 4 ) ;
500
+ eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandStartedEvent > ( ) ;
501
+ eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandSucceededEvent > ( ) ;
502
+ eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandStartedEvent > ( ) ;
503
+ eventCapturer . Next ( ) . Should ( ) . BeOfType < CommandSucceededEvent > ( ) ;
504
+ }
505
+
476
506
// 5.1 Azure With No Username
477
507
// https://github.com/mongodb/specifications/blob/1448ba6eedfa2f16584222e683b427bea07bb085/source/auth/tests/mongodb-oidc.md?plain=1#L212
478
508
[ Theory ]
0 commit comments