Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sshuttle
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pub
sshuttle
Commits
da4ce191
Commit
da4ce191
authored
Dec 06, 2015
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix MacOSX tests.
parent
12d4b304
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
test_methods_pf.py
sshuttle/tests/test_methods_pf.py
+30
-7
No files found.
sshuttle/tests/test_methods_pf.py
View file @
da4ce191
...
@@ -95,13 +95,21 @@ def test_firewall_command(mock_pf_get_dev, mock_ioctl, mock_stdout):
...
@@ -95,13 +95,21 @@ def test_firewall_command(mock_pf_get_dev, mock_ioctl, mock_stdout):
]
]
# FIXME - test fails with platform=='darwin' due re.search not liking Mock
def
pfctl
(
args
,
stdin
=
None
):
# objects.
if
args
==
'-s all'
:
@
patch
(
'sshuttle.methods.pf.sys.platform'
,
'not_darwin'
)
return
(
b
'another mary had a little lamb
\n
'
,
b
'little lamb
\n
'
)
if
args
==
'-E'
:
return
(
b
'
\n
'
,
b
'Token : abcdefg
\n
'
)
return
None
@
patch
(
'sshuttle.methods.pf.sys.platform'
,
'darwin'
)
@
patch
(
'sshuttle.methods.pf.pfctl'
)
@
patch
(
'sshuttle.methods.pf.pfctl'
)
@
patch
(
'sshuttle.methods.pf.ioctl'
)
@
patch
(
'sshuttle.methods.pf.ioctl'
)
@
patch
(
'sshuttle.methods.pf.pf_get_dev'
)
@
patch
(
'sshuttle.methods.pf.pf_get_dev'
)
def
test_setup_firewall
(
mock_pf_get_dev
,
mock_ioctl
,
mock_pfctl
):
def
test_setup_firewall
(
mock_pf_get_dev
,
mock_ioctl
,
mock_pfctl
):
mock_pfctl
.
side_effect
=
pfctl
method
=
get_method
(
'pf'
)
method
=
get_method
(
'pf'
)
assert
method
.
name
==
'pf'
assert
method
.
name
==
'pf'
...
@@ -145,16 +153,31 @@ def test_setup_firewall(mock_pf_get_dev, mock_ioctl, mock_pfctl):
...
@@ -145,16 +153,31 @@ def test_setup_firewall(mock_pf_get_dev, mock_ioctl, mock_pfctl):
call
(
mock_pf_get_dev
(),
3424666650
,
ANY
),
call
(
mock_pf_get_dev
(),
3424666650
,
ANY
),
call
(
mock_pf_get_dev
(),
3424666650
,
ANY
),
call
(
mock_pf_get_dev
(),
3424666650
,
ANY
),
]
]
# FIXME - needs more work
assert
mock_pfctl
.
mock_calls
==
[
# print(mock_pfctl.mock_calls)
call
(
'-s all'
),
# assert mock_pfctl.mock_calls == []
call
(
'-a sshuttle -f /dev/stdin'
,
b
'table <forward_subnets> {!1.2.3.66/32,1.2.3.0/24}
\n
'
b
'table <dns_servers> {1.2.3.33}
\n
'
b
'rdr pass on lo0 proto tcp '
b
'to <forward_subnets> -> 127.0.0.1 port 1025
\n
'
b
'rdr pass on lo0 proto udp '
b
'to <dns_servers> port 53 -> 127.0.0.1 port 1027
\n
'
b
'pass out route-to lo0 inet proto tcp '
b
'to <forward_subnets> keep state
\n
'
b
'pass out route-to lo0 inet proto udp '
b
'to <dns_servers> port 53 keep state
\n
'
),
call
(
'-E'
),
]
mock_pf_get_dev
.
reset_mock
()
mock_pf_get_dev
.
reset_mock
()
mock_ioctl
.
reset_mock
()
mock_ioctl
.
reset_mock
()
mock_pfctl
.
reset_mock
()
mock_pfctl
.
reset_mock
()
method
.
setup_firewall
(
1025
,
0
,
[],
2
,
[],
False
)
method
.
setup_firewall
(
1025
,
0
,
[],
2
,
[],
False
)
assert
mock_ioctl
.
mock_calls
==
[]
assert
mock_ioctl
.
mock_calls
==
[]
assert
mock_pfctl
.
mock_calls
==
[
call
(
'-a sshuttle -F all'
)]
assert
mock_pfctl
.
mock_calls
==
[
call
(
'-a sshuttle -F all'
),
call
(
"-X b'abcdefg'"
),
]
mock_pf_get_dev
.
reset_mock
()
mock_pf_get_dev
.
reset_mock
()
mock_pfctl
.
reset_mock
()
mock_pfctl
.
reset_mock
()
mock_ioctl
.
reset_mock
()
mock_ioctl
.
reset_mock
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment