diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-04-28 09:01:58 -0300 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2018-07-03 10:53:20 -0300 |
| commit | 9865af5d41906adadf3e081f785134424397db43 (patch) | |
| tree | 485e51a71b032f098c6e6ead50ef8a78496b071c | |
| parent | 2aa01f3300533568a277a992fc935d7c2f5b1a7a (diff) | |
| download | mullvadvpn-9865af5d41906adadf3e081f785134424397db43.tar.xz mullvadvpn-9865af5d41906adadf3e081f785134424397db43.zip | |
Test if account token is updated
| -rw-r--r-- | mullvad-tests/tests/account.rs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/mullvad-tests/tests/account.rs b/mullvad-tests/tests/account.rs index 88eda432fc..4d7c2bdcea 100644 --- a/mullvad-tests/tests/account.rs +++ b/mullvad-tests/tests/account.rs @@ -7,7 +7,7 @@ use std::io::{BufRead, BufReader}; use std::path::Path; use mullvad_tests::mock_openvpn::search_openvpn_args; -use mullvad_tests::{DaemonRunner, PathWatcher}; +use mullvad_tests::{watch_event, DaemonRunner, PathWatcher}; #[test] fn uses_account_token() { @@ -29,6 +29,34 @@ fn uses_account_token() { assert_eq!(account_token_sent_to_plugin, specified_account); } +#[test] +fn uses_updated_account_token() { + let mut daemon = DaemonRunner::spawn(); + let mut rpc_client = daemon.rpc_client().unwrap(); + let openvpn_args_file = daemon.mock_openvpn_args_file(); + let mut openvpn_args_file_events = PathWatcher::watch(&openvpn_args_file).unwrap(); + + let first_account_specified = "123456"; + rpc_client + .set_account(Some(first_account_specified.to_owned())) + .unwrap(); + rpc_client.connect().unwrap(); + + openvpn_args_file_events.assert_create_write_close_sequence(); + + let second_account_specified = "654321"; + rpc_client + .set_account(Some(second_account_specified.to_owned())) + .unwrap(); + + assert_eq!(openvpn_args_file_events.next(), Some(watch_event::REMOVE)); + openvpn_args_file_events.assert_create_write_close_sequence(); + + let account_token_sent_to_plugin = read_account_token(openvpn_args_file).unwrap(); + + assert_eq!(account_token_sent_to_plugin, second_account_specified); +} + fn read_account_token<P: AsRef<Path>>(openvpn_args_file_path: P) -> Result<String, String> { let account_token_file_path = search_openvpn_args(openvpn_args_file_path, "--auth-user-pass") .skip(1) |
