@@ -564,6 +564,49 @@ mod basic {
564
564
Ok ( ( ) )
565
565
}
566
566
567
+ #[ tokio:: test( flavor = "multi_thread" ) ]
568
+ async fn machine_4_5_reauthentication_when_session_involved ( ) -> anyhow:: Result < ( ) > {
569
+ let admin_client = Client :: with_uri_str ( & * MONGODB_URI ) . await ?;
570
+
571
+ // Now set a failpoint for find with 391 error code
572
+ let fail_point =
573
+ FailPoint :: fail_command ( & [ "find" ] , FailPointMode :: Times ( 1 ) ) . error_code ( 391 ) ;
574
+ let _guard = admin_client. enable_fail_point ( fail_point) . await . unwrap ( ) ;
575
+
576
+ // we need to assert the callback count
577
+ let call_count: Arc < Mutex < i32 > > = Arc :: new ( Mutex :: new ( 0 ) ) ;
578
+ let cb_call_count = call_count. clone ( ) ;
579
+
580
+ let mut opts = ClientOptions :: parse ( & * MONGODB_URI_SINGLE ) . await ?;
581
+ opts. credential = Credential :: builder ( )
582
+ . mechanism ( AuthMechanism :: MongoDbOidc )
583
+ . oidc_callback ( oidc:: Callback :: machine ( move |_| {
584
+ let call_count = cb_call_count. clone ( ) ;
585
+ async move {
586
+ * call_count. lock ( ) . await += 1 ;
587
+ Ok ( oidc:: IdpServerResponse {
588
+ access_token : get_access_token_test_user_1 ( ) . await ,
589
+ expires : None ,
590
+ refresh_token : None ,
591
+ } )
592
+ }
593
+ . boxed ( )
594
+ } ) )
595
+ . build ( )
596
+ . into ( ) ;
597
+ let client = Client :: with_options ( opts) ?;
598
+ let mut session = client. start_session ( ) . await . unwrap ( ) ;
599
+
600
+ client
601
+ . database ( "test" )
602
+ . collection :: < Document > ( "test" )
603
+ . find_one ( doc ! { } )
604
+ . session ( & mut session)
605
+ . await ?;
606
+ assert_eq ! ( 2 , * ( * call_count) . lock( ) . await ) ;
607
+ Ok ( ( ) )
608
+ }
609
+
567
610
// Human Callback tests
568
611
#[ tokio:: test]
569
612
async fn human_1_1_single_principal_implicit_username ( ) -> anyhow:: Result < ( ) > {
0 commit comments