MCPcopy
hub / github.com/sshuttle/sshuttle / test_main

Function test_main

tests/client/test_firewall.py:115–163  ·  view source on GitHub ↗
(mock_get_method, mock_setup_daemon, mock_rewrite_etc_hosts)

Source from the content-addressed store, hash-verified

113@patch('sshuttle.firewall.setup_daemon')
114@patch('sshuttle.firewall.get_method')
115def test_main(mock_get_method, mock_setup_daemon, mock_rewrite_etc_hosts):
116 stdin, stdout = setup_daemon()
117 mock_setup_daemon.return_value = stdin, stdout
118
119 mock_get_method("not_auto").name = "test"
120 mock_get_method.reset_mock()
121
122 sshuttle.firewall.main("not_auto", False)
123
124 assert mock_rewrite_etc_hosts.mock_calls == [
125 call({'1.2.3.3': 'existing'}, 1024),
126 call({}, 1024),
127 ]
128
129 assert stdout.mock_calls == [
130 call.write(b'READY test\n'),
131 call.flush(),
132 call.write(b'STARTED\n'),
133 call.flush()
134 ]
135 assert mock_setup_daemon.mock_calls == [call()]
136 assert mock_get_method.mock_calls == [
137 call('not_auto'),
138 call().is_supported(),
139 call().is_supported().__bool__(),
140 call().setup_firewall(
141 1024, 1026,
142 [(AF_INET6, u'2404:6800:4004:80c::33')],
143 AF_INET6,
144 [(AF_INET6, 64, False, u'2404:6800:4004:80c::', 0, 0),
145 (AF_INET6, 128, True, u'2404:6800:4004:80c::101f', 80, 80)],
146 True,
147 None,
148 None,
149 '0x01'),
150 call().setup_firewall(
151 1025, 1027,
152 [(AF_INET, u'1.2.3.33')],
153 AF_INET,
154 [(AF_INET, 24, False, u'1.2.3.0', 8000, 9000),
155 (AF_INET, 32, True, u'1.2.3.66', 8080, 8080)],
156 True,
157 None,
158 None,
159 '0x01'),
160 call().wait_for_firewall_ready(12345),
161 call().restore_firewall(1024, AF_INET6, True, None, None),
162 call().restore_firewall(1025, AF_INET, True, None, None),
163 ]

Callers

nothing calls this directly

Calls 7

setup_daemonFunction · 0.85
writeMethod · 0.80
flushMethod · 0.80
is_supportedMethod · 0.45
setup_firewallMethod · 0.45
restore_firewallMethod · 0.45

Tested by

no test coverage detected