MCPcopy
hub / github.com/sshuttle/sshuttle / test_firewall_command_openbsd

Function test_firewall_command_openbsd

tests/client/test_methods_pf.py:139–155  ·  view source on GitHub ↗
(mock_pf_get_dev, mock_ioctl, mock_stdout)

Source from the content-addressed store, hash-verified

137@patch('sshuttle.methods.pf.ioctl')
138@patch('sshuttle.methods.pf.pf_get_dev')
139def test_firewall_command_openbsd(mock_pf_get_dev, mock_ioctl, mock_stdout):
140 method = get_method('pf')
141 assert not method.firewall_command("something")
142
143 command = "QUERY_PF_NAT %d,%d,%s,%d,%s,%d\n" % (
144 AF_INET, socket.IPPROTO_TCP,
145 "127.0.0.1", 1025, "127.0.0.2", 1024)
146 assert method.firewall_command(command)
147
148 assert mock_pf_get_dev.mock_calls == [call()]
149 assert mock_ioctl.mock_calls == [
150 call(mock_pf_get_dev(), 0xc0504417, ANY),
151 ]
152 assert mock_stdout.mock_calls == [
153 call.write('QUERY_PF_NAT_SUCCESS 0.0.0.0,0\n'),
154 call.flush(),
155 ]
156
157
158def pfctl(args, stdin=None):

Callers

nothing calls this directly

Calls 4

get_methodFunction · 0.90
writeMethod · 0.80
flushMethod · 0.80
firewall_commandMethod · 0.45

Tested by

no test coverage detected