@@ -21,19 +21,52 @@ use test_rpc::ServiceClient;
21
21
pub async fn test_custom_access_methods (
22
22
_: TestContext ,
23
23
_rpc : ServiceClient ,
24
- _mullvad_client : MullvadProxyClient ,
24
+ mullvad_client : MullvadProxyClient ,
25
25
) -> Result < ( ) , Error > {
26
26
log:: info!( "Testing Shadowsocks access method" ) ;
27
- test_shadowsocks ( ) . await ?;
27
+ test_shadowsocks ( mullvad_client . clone ( ) ) . await ?;
28
28
log:: info!( "Testing SOCKS5 (Remote) access method" ) ;
29
29
test_socks_remote ( ) . await ?;
30
30
Ok ( ( ) )
31
31
}
32
32
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
+ . nth ( 0 )
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 ( ( ) )
35
67
}
36
68
69
+ #[ allow( clippy:: unused_async) ]
37
70
async fn test_socks_remote ( ) -> Result < ( ) , Error > {
38
71
unimplemented ! ( "Testing SOCKS5 (Remote) access method is not implemented" )
39
72
}
0 commit comments