Skip to content

Commit

Permalink
Fix reset access method after mullvad api-access test
Browse files Browse the repository at this point in the history
After running `mullvad api-access test`, the previously used access
method should be used, which was not the case previously.
  • Loading branch information
MarkusPettersson98 committed Sep 28, 2023
1 parent 2406d29 commit 2b463ed
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mullvad-cli/src/cmds/api_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ impl ApiAccess {
/// Test an access method to see if it successfully reaches the Mullvad API.
async fn test(item: SelectItem) -> Result<()> {
let mut rpc = MullvadProxyClient::new().await?;
// Retrieve the currently used access method. We will reset to this
// after we are done testing.
let previous_access_method = rpc.get_current_api_access_method().await?;
let access_method = Self::get_access_method(&mut rpc, &item).await?;
rpc.set_access_method(access_method.get_id()).await?;
println!("Testing access method \"{}\"", access_method.name);
Expand All @@ -185,6 +188,8 @@ impl ApiAccess {
Ok(_) => println!("Success!"),
Err(_) => println!("Failed"),
}
rpc.set_access_method(previous_access_method.get_id())
.await?;

Ok(())
}
Expand Down

0 comments on commit 2b463ed

Please sign in to comment.