Skip to content

Commit 0f66296

Browse files
WIP Add Shadowsocks access method test
1 parent e2ae4ef commit 0f66296

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

test/test-manager/src/tests/access_methods.rs

+36-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,49 @@ use test_rpc::ServiceClient;
2121
pub async fn test_custom_access_methods(
2222
_: TestContext,
2323
_rpc: ServiceClient,
24-
_mullvad_client: MullvadProxyClient,
24+
mullvad_client: MullvadProxyClient,
2525
) -> Result<(), Error> {
2626
log::info!("Testing Shadowsocks access method");
27-
test_shadowsocks().await?;
27+
test_shadowsocks(mullvad_client.clone()).await?;
2828
log::info!("Testing SOCKS5 (Remote) access method");
2929
test_socks_remote().await?;
3030
Ok(())
3131
}
3232

33-
async fn test_shadowsocks() -> Result<(), Error> {
34-
panic!("Testing Shadowsocks access method has not been fully implemented yet!")
33+
async fn test_shadowsocks(mut mullvad_client: MullvadProxyClient) -> Result<(), Error> {
34+
use mullvad_types::relay_list::RelayEndpointData;
35+
use talpid_types::net::proxy::CustomProxy;
36+
// Set up all the parameters needed to create a custom Shadowsocks access method.
37+
//
38+
// Since Mullvad host's Shadowsocks relays on their bridge servers, we can
39+
// simply select a bridge server to derive all the needed parameters.
40+
// mullvad_client
41+
let relay_list = mullvad_client.get_relay_locations().await.unwrap();
42+
let bridge = relay_list
43+
.relays()
44+
.filter(|relay| matches!(relay.endpoint_data, RelayEndpointData::Bridge))
45+
.next()
46+
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list.");
47+
48+
let access_method: CustomProxy = relay_list
49+
.bridge
50+
.shadowsocks
51+
.first()
52+
.map(|shadowsocks| {
53+
shadowsocks.to_proxy_settings(bridge.ipv4_addr_in.into())
54+
})
55+
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list.");
56+
57+
let successful = mullvad_client
58+
.test_custom_api_access_method(access_method.clone().into())
59+
.await?;
60+
61+
assert!(
62+
successful,
63+
"Failed while testing access method - {access_method:?}"
64+
);
65+
66+
Ok(())
3567
}
3668

3769
#[allow(clippy::unused_async)]

0 commit comments

Comments
 (0)