Skip to content

Commit cdebb8e

Browse files
WIP Add SOCKS5 (remote) access method test
1 parent fa27ad8 commit cdebb8e

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

talpid-types/src/net/proxy.rs

+18
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ impl CustomProxy {
6565
}
6666
}
6767

68+
impl From<Socks5Remote> for CustomProxy {
69+
fn from(value: Socks5Remote) -> Self {
70+
CustomProxy::Socks5Remote(value)
71+
}
72+
}
73+
74+
impl From<Socks5Local> for CustomProxy {
75+
fn from(value: Socks5Local) -> Self {
76+
CustomProxy::Socks5Local(value)
77+
}
78+
}
79+
80+
impl From<Shadowsocks> for CustomProxy {
81+
fn from(value: Shadowsocks) -> Self {
82+
CustomProxy::Shadowsocks(value)
83+
}
84+
}
85+
6886
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
6987
pub struct Shadowsocks {
7088
pub endpoint: SocketAddr,

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

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Integration tests for API access methods.
22
use super::{Error, TestContext};
33
use mullvad_management_interface::MullvadProxyClient;
4+
use talpid_types::net::proxy::CustomProxy;
45
use test_macro::test_function;
56
use test_rpc::ServiceClient;
67

@@ -26,13 +27,12 @@ pub async fn test_custom_access_methods(
2627
log::info!("Testing Shadowsocks access method");
2728
test_shadowsocks(mullvad_client.clone()).await?;
2829
log::info!("Testing SOCKS5 (Remote) access method");
29-
test_socks_remote().await?;
30+
test_socks_remote(mullvad_client.clone()).await?;
3031
Ok(())
3132
}
3233

3334
async fn test_shadowsocks(mut mullvad_client: MullvadProxyClient) -> Result<(), Error> {
3435
use mullvad_types::relay_list::RelayEndpointData;
35-
use talpid_types::net::proxy::CustomProxy;
3636
// Set up all the parameters needed to create a custom Shadowsocks access method.
3737
//
3838
// Since Mullvad host's Shadowsocks relays on their bridge servers, we can
@@ -54,6 +54,32 @@ async fn test_shadowsocks(mut mullvad_client: MullvadProxyClient) -> Result<(),
5454
})
5555
.expect("`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list.");
5656

57+
assert_access_method_works(mullvad_client, access_method.clone()).await?;
58+
59+
Ok(())
60+
}
61+
62+
async fn test_socks_remote(mut mullvad_client: MullvadProxyClient) -> Result<(), Error> {
63+
use talpid_types::net::proxy::Socks5Remote;
64+
// Set up all the parameters needed to create a custom SOCKS5 access method.
65+
//
66+
// The remote SOCKS5 proxy is assumed to be running on the test manager.
67+
// On which port it listens to is defined in the test config.
68+
let endpoint = todo!();
69+
let access_method = Socks5Remote {
70+
endpoint: todo!(),
71+
auth: None,
72+
};
73+
74+
assert_access_method_works(mullvad_client, access_method.into()).await?;
75+
76+
Ok(())
77+
}
78+
79+
async fn assert_access_method_works(
80+
mut mullvad_client: MullvadProxyClient,
81+
access_method: CustomProxy,
82+
) -> Result<(), Error> {
5783
let successful = mullvad_client
5884
.test_custom_api_access_method(access_method.clone().into())
5985
.await?;
@@ -65,8 +91,3 @@ async fn test_shadowsocks(mut mullvad_client: MullvadProxyClient) -> Result<(),
6591

6692
Ok(())
6793
}
68-
69-
#[allow(clippy::unused_async)]
70-
async fn test_socks_remote() -> Result<(), Error> {
71-
unimplemented!("Testing SOCKS5 (Remote) access method is not implemented")
72-
}

0 commit comments

Comments
 (0)