@@ -86,19 +86,19 @@ def test_recovery_runs_after_threshold_and_resets_counter(
8686 self .assertEqual (operator .auth_failures , 0 )
8787 self .assertEqual (os .environ .get ("BW_SESSION" ), "new-session" )
8888
89- @patch ("bitwardenCrdOperator.sys.exit " )
89+ @patch ("bitwardenCrdOperator.os._exit " )
9090 @patch ("bitwardenCrdOperator.recover_auth_state" )
9191 @patch ("bitwardenCrdOperator.command_wrapper" )
9292 def test_recovery_failure_exits_process (
93- self , command_wrapper_mock , recover_auth_state_mock , sys_exit_mock
93+ self , command_wrapper_mock , recover_auth_state_mock , os_exit_mock
9494 ):
9595 os .environ ["BW_AUTH_FAILURE_THRESHOLD" ] = "1"
9696 command_wrapper_mock .side_effect = [None , None ]
9797
9898 operator .bitwarden_signin (self .logger )
9999
100100 recover_auth_state_mock .assert_called_once_with (self .logger )
101- sys_exit_mock .assert_called_once_with (1 )
101+ os_exit_mock .assert_called_once_with (1 )
102102
103103 def test_invalid_threshold_uses_default_without_exception_control_flow (self ):
104104 os .environ ["BW_AUTH_FAILURE_THRESHOLD" ] = "invalid"
@@ -108,13 +108,16 @@ def test_invalid_threshold_uses_default_without_exception_control_flow(self):
108108 self .assertEqual (threshold , operator .AUTH_FAILURE_THRESHOLD )
109109
110110 @patch ("bitwardenCrdOperator.command_wrapper" )
111- def test_recover_auth_state_clears_session_and_cache_file (
111+ def test_recover_auth_state_clears_session_cache_and_bw_host_marker (
112112 self , command_wrapper_mock
113113 ):
114114 with tempfile .TemporaryDirectory () as temp_dir :
115115 data_file = Path (temp_dir ) / ".config" / "Bitwarden CLI" / "data.json"
116116 data_file .parent .mkdir (parents = True , exist_ok = True )
117117 data_file .write_text ("{ invalid" , encoding = "utf-8" )
118+
119+ bw_host_file = Path (temp_dir ) / ".bw_host"
120+ bw_host_file .write_text ("https://vault.example.com" , encoding = "utf-8" )
118121 os .environ ["BW_SESSION" ] = "stale-session"
119122
120123 with patch (
@@ -124,6 +127,7 @@ def test_recover_auth_state_clears_session_and_cache_file(
124127
125128 self .assertNotIn ("BW_SESSION" , os .environ )
126129 self .assertFalse (data_file .exists ())
130+ self .assertFalse (bw_host_file .exists ())
127131 command_wrapper_mock .assert_called_once_with (
128132 self .logger , "logout" , use_success = False
129133 )
0 commit comments