MCPcopy
hub / github.com/sshuttle/sshuttle / test_get_tcp_dstip

Function test_get_tcp_dstip

tests/client/test_methods_pf.py:20–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19@patch('sshuttle.helpers.verbose', new=3)
20def test_get_tcp_dstip():
21 sock = Mock()
22 sock.getpeername.return_value = ("127.0.0.1", 1024)
23 sock.getsockname.return_value = ("127.0.0.2", 1025)
24 sock.family = AF_INET
25
26 firewall = Mock()
27 firewall.pfile.readline.return_value = \
28 b"QUERY_PF_NAT_SUCCESS 127.0.0.3,1026\n"
29
30 method = get_method('pf')
31 method.set_firewall(firewall)
32 assert method.get_tcp_dstip(sock) == ('127.0.0.3', 1026)
33
34 assert sock.mock_calls == [
35 call.getpeername(),
36 call.getsockname(),
37 ]
38 assert firewall.mock_calls == [
39 call.pfile.write(b'QUERY_PF_NAT 2,6,127.0.0.1,1024,127.0.0.2,1025\n'),
40 call.pfile.flush(),
41 call.pfile.readline()
42 ]
43
44
45def test_recv_udp():

Callers

nothing calls this directly

Calls 5

get_methodFunction · 0.90
set_firewallMethod · 0.80
writeMethod · 0.80
flushMethod · 0.80
get_tcp_dstipMethod · 0.45

Tested by

no test coverage detected