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
9cc6d636
Commit
9cc6d636
authored
Nov 17, 2015
by
Brian May
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix firewall tests.
parent
43566ebd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
test_firewall.py
sshuttle/tests/test_firewall.py
+17
-5
No files found.
sshuttle/tests/test_firewall.py
View file @
9cc6d636
...
@@ -24,6 +24,11 @@ GO 1
...
@@ -24,6 +24,11 @@ GO 1
return
stdin
,
stdout
return
stdin
,
stdout
@
patch
(
'sshuttle.firewall.HOSTSFILE'
,
new
=
'tmp/hosts'
)
@
patch
(
'sshuttle.firewall.hostmap'
,
new
=
{
'myhost'
:
'1.2.3.4'
,
'myotherhost'
:
'1.2.3.5'
,
})
def
test_rewrite_etc_hosts
():
def
test_rewrite_etc_hosts
():
if
not
os
.
path
.
isdir
(
"tmp"
):
if
not
os
.
path
.
isdir
(
"tmp"
):
os
.
mkdir
(
"tmp"
)
os
.
mkdir
(
"tmp"
)
...
@@ -33,11 +38,6 @@ def test_rewrite_etc_hosts():
...
@@ -33,11 +38,6 @@ def test_rewrite_etc_hosts():
shutil
.
copyfile
(
"tmp/hosts.orig"
,
"tmp/hosts"
)
shutil
.
copyfile
(
"tmp/hosts.orig"
,
"tmp/hosts"
)
sshuttle
.
firewall
.
HOSTSFILE
=
"tmp/hosts"
sshuttle
.
firewall
.
hostmap
=
{
'myhost'
:
'1.2.3.4'
,
'myotherhost'
:
'1.2.3.5'
,
}
sshuttle
.
firewall
.
rewrite_etc_hosts
(
10
)
sshuttle
.
firewall
.
rewrite_etc_hosts
(
10
)
with
open
(
"tmp/hosts"
)
as
f
:
with
open
(
"tmp/hosts"
)
as
f
:
line
=
f
.
readline
()
line
=
f
.
readline
()
...
@@ -61,14 +61,26 @@ def test_rewrite_etc_hosts():
...
@@ -61,14 +61,26 @@ def test_rewrite_etc_hosts():
assert
filecmp
.
cmp
(
"tmp/hosts.orig"
,
"tmp/hosts"
,
shallow
=
False
)
is
True
assert
filecmp
.
cmp
(
"tmp/hosts.orig"
,
"tmp/hosts"
,
shallow
=
False
)
is
True
@
patch
(
'sshuttle.firewall.HOSTSFILE'
,
new
=
'tmp/hosts'
)
@
patch
(
'sshuttle.firewall.setup_daemon'
)
@
patch
(
'sshuttle.firewall.setup_daemon'
)
@
patch
(
'sshuttle.firewall.get_method'
)
@
patch
(
'sshuttle.firewall.get_method'
)
def
test_main
(
mock_get_method
,
mock_setup_daemon
):
def
test_main
(
mock_get_method
,
mock_setup_daemon
):
stdin
,
stdout
=
setup_daemon
()
stdin
,
stdout
=
setup_daemon
()
mock_setup_daemon
.
return_value
=
stdin
,
stdout
mock_setup_daemon
.
return_value
=
stdin
,
stdout
if
not
os
.
path
.
isdir
(
"tmp"
):
os
.
mkdir
(
"tmp"
)
sshuttle
.
firewall
.
main
(
"test"
,
False
)
sshuttle
.
firewall
.
main
(
"test"
,
False
)
with
open
(
"tmp/hosts"
)
as
f
:
line
=
f
.
readline
()
s
=
line
.
split
()
assert
s
==
[
'1.2.3.3'
,
'existing'
]
line
=
f
.
readline
()
assert
line
==
""
stdout
.
mock_calls
==
[
stdout
.
mock_calls
==
[
call
.
write
(
'READY test
\n
'
),
call
.
write
(
'READY test
\n
'
),
call
.
flush
(),
call
.
flush
(),
...
...
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