@@ -21,19 +21,59 @@ 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 crate :: tests:: helpers;
35
+ use mullvad_types:: relay_list:: RelayEndpointData ;
36
+ use std:: net:: SocketAddr ;
37
+ use talpid_types:: net:: proxy:: Shadowsocks ;
38
+ // Set up all the parameters needed to create a custom Shadowsocks access method.
39
+ //
40
+ // Since Mullvad host's Shadowsocks relays on their bridge servers, we can
41
+ // simply select a bridge server to derive all the needed parameters.
42
+ // mullvad_client
43
+ let bridges = helpers:: filter_relays ( & mut mullvad_client, |relay| {
44
+ matches ! ( relay. endpoint_data, RelayEndpointData :: Bridge )
45
+ } )
46
+ . await ?;
47
+
48
+ let shadowsocks_relay = bridges
49
+ . first ( )
50
+ . expect ( "`test_shadowsocks` needs at least one shadowsocks relay to execute. Found non in relay list." ) ;
51
+
52
+ let access_method = Shadowsocks {
53
+ endpoint : SocketAddr :: from ( (
54
+ shadowsocks_relay. ipv4_addr_in ,
55
+ // TODO(markus): Will this always be valid?
56
+ 443 ,
57
+ ) ) ,
58
+ // TODO(markus): Will this always be valid?
59
+ password : "mullvad" . to_string ( ) ,
60
+ // TODO(markus): Will this always be valid?
61
+ cipher : "aes-256-cfb" . to_string ( ) ,
62
+ } ;
63
+
64
+ let successful = mullvad_client
65
+ . test_custom_api_access_method ( access_method. clone ( ) . into ( ) )
66
+ . await ?;
67
+
68
+ assert ! (
69
+ successful,
70
+ "Failed while testing access method - {access_method:?}"
71
+ ) ;
72
+
73
+ Ok ( ( ) )
35
74
}
36
75
76
+ #[ allow( clippy:: unused_async) ]
37
77
async fn test_socks_remote ( ) -> Result < ( ) , Error > {
38
78
unimplemented ! ( "Testing SOCKS5 (Remote) access method is not implemented" )
39
79
}
0 commit comments