diff options
| -rw-r--r-- | mullvad-tests/src/lib.rs | 4 | ||||
| -rw-r--r-- | mullvad-tests/tests/connection.rs | 28 |
2 files changed, 32 insertions, 0 deletions
diff --git a/mullvad-tests/src/lib.rs b/mullvad-tests/src/lib.rs index 54aea065c8..a9af2b9c10 100644 --- a/mullvad-tests/src/lib.rs +++ b/mullvad-tests/src/lib.rs @@ -313,6 +313,10 @@ impl MockOpenVpnPluginRpcClient { self.send_event(OpenVpnPluginEvent::Up, env) } + pub fn route_predown(&mut self) -> Result<(), String> { + self.send_event(OpenVpnPluginEvent::RoutePredown, HashMap::new()) + } + fn send_event( &mut self, event: OpenVpnPluginEvent, diff --git a/mullvad-tests/tests/connection.rs b/mullvad-tests/tests/connection.rs index 84306eeb14..4e548bbdde 100644 --- a/mullvad-tests/tests/connection.rs +++ b/mullvad-tests/tests/connection.rs @@ -174,6 +174,34 @@ fn changes_to_connected_state() { assert_eq!(rpc_client.get_state().unwrap(), CONNECTED_STATE); } +#[test] +fn returns_to_connecting_state() { + let mut daemon = DaemonRunner::spawn(); + let mut rpc_client = daemon.rpc_client().unwrap(); + let openvpn_args_file = daemon.mock_openvpn_args_file(); + let state_events = rpc_client.new_state_subscribe().unwrap(); + + rpc_client.set_account(Some("123456".to_owned())).unwrap(); + rpc_client.connect().unwrap(); + + assert_state_event(&state_events, CONNECTING_STATE); + + let mut mock_plugin_client = create_mock_openvpn_plugin_client(openvpn_args_file); + + mock_plugin_client.authenticate().unwrap(); + mock_plugin_client.up().unwrap(); + + assert_state_event(&state_events, CONNECTED_STATE); + + mock_plugin_client.route_predown().unwrap(); + + // Wait for new OpenVPN instance + wait_for_file_write_finish(&openvpn_args_file, Duration::from_secs(5)); + + assert_state_event(&state_events, CONNECTING_STATE); + assert_eq!(rpc_client.get_state().unwrap(), CONNECTING_STATE); +} + fn assert_state_event(receiver: &mpsc::Receiver<DaemonState>, expected_state: DaemonState) { let received_state = receiver .recv_timeout(Duration::from_secs(1)) |
