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
cb53d8a1
Commit
cb53d8a1
authored
Oct 17, 2020
by
Scott Kuhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests for parse_subnetport() expect lists & update expected error messages in tests
parent
64d5c77a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
test_options.py
tests/client/test_options.py
+16
-16
No files found.
tests/client/test_options.py
View file @
cb53d8a1
...
...
@@ -31,7 +31,7 @@ _ip6_swidths = (48, 64, 96, 115, 128)
def
test_parse_subnetport_ip4
():
for
ip_repr
,
ip
in
_ip4_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
ip_repr
)
\
==
(
socket
.
AF_INET
,
ip
,
32
,
0
,
0
)
==
[(
socket
.
AF_INET
,
ip
,
32
,
0
,
0
)]
with
pytest
.
raises
(
Fatal
)
as
excinfo
:
sshuttle
.
options
.
parse_subnetport
(
'10.256.0.0'
)
assert
str
(
excinfo
.
value
)
==
'Unable to resolve address: 10.256.0.0'
...
...
@@ -42,34 +42,34 @@ def test_parse_subnetport_ip4_with_mask():
for
swidth
in
_ip4_swidths
:
assert
sshuttle
.
options
.
parse_subnetport
(
'/'
.
join
((
ip_repr
,
str
(
swidth
)))
)
==
(
socket
.
AF_INET
,
ip
,
swidth
,
0
,
0
)
)
==
[(
socket
.
AF_INET
,
ip
,
swidth
,
0
,
0
)]
assert
sshuttle
.
options
.
parse_subnetport
(
'0/0'
)
\
==
(
socket
.
AF_INET
,
'0.0.0.0'
,
0
,
0
,
0
)
==
[(
socket
.
AF_INET
,
'0.0.0.0'
,
0
,
0
,
0
)]
with
pytest
.
raises
(
Fatal
)
as
excinfo
:
sshuttle
.
options
.
parse_subnetport
(
'10.0.0.0/33'
)
assert
str
(
excinfo
.
value
)
==
'
width 33
is not between 0 and 32'
assert
str
(
excinfo
.
value
)
==
'
Slash in CIDR notation (/33)
is not between 0 and 32'
def
test_parse_subnetport_ip4_with_port
():
for
ip_repr
,
ip
in
_ip4_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
':'
.
join
((
ip_repr
,
'80'
)))
\
==
(
socket
.
AF_INET
,
ip
,
32
,
80
,
80
)
==
[(
socket
.
AF_INET
,
ip
,
32
,
80
,
80
)]
assert
sshuttle
.
options
.
parse_subnetport
(
':'
.
join
((
ip_repr
,
'80-90'
)))
\
==
(
socket
.
AF_INET
,
ip
,
32
,
80
,
90
)
==
[(
socket
.
AF_INET
,
ip
,
32
,
80
,
90
)]
def
test_parse_subnetport_ip4_with_mask_and_port
():
for
ip_repr
,
ip
in
_ip4_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
ip_repr
+
'/32:80'
)
\
==
(
socket
.
AF_INET
,
ip
,
32
,
80
,
80
)
==
[(
socket
.
AF_INET
,
ip
,
32
,
80
,
80
)]
assert
sshuttle
.
options
.
parse_subnetport
(
ip_repr
+
'/16:80-90'
)
\
==
(
socket
.
AF_INET
,
ip
,
16
,
80
,
90
)
==
[(
socket
.
AF_INET
,
ip
,
16
,
80
,
90
)]
def
test_parse_subnetport_ip6
():
for
ip_repr
,
ip
in
_ip6_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
ip_repr
)
\
==
(
socket
.
AF_INET6
,
ip
,
128
,
0
,
0
)
==
[(
socket
.
AF_INET6
,
ip
,
128
,
0
,
0
)]
def
test_parse_subnetport_ip6_with_mask
():
...
...
@@ -77,25 +77,25 @@ def test_parse_subnetport_ip6_with_mask():
for
swidth
in
_ip4_swidths
+
_ip6_swidths
:
assert
sshuttle
.
options
.
parse_subnetport
(
'/'
.
join
((
ip_repr
,
str
(
swidth
)))
)
==
(
socket
.
AF_INET6
,
ip
,
swidth
,
0
,
0
)
)
==
[(
socket
.
AF_INET6
,
ip
,
swidth
,
0
,
0
)]
assert
sshuttle
.
options
.
parse_subnetport
(
'::/0'
)
\
==
(
socket
.
AF_INET6
,
'::'
,
0
,
0
,
0
)
==
[(
socket
.
AF_INET6
,
'::'
,
0
,
0
,
0
)]
with
pytest
.
raises
(
Fatal
)
as
excinfo
:
sshuttle
.
options
.
parse_subnetport
(
'fc00::/129'
)
assert
str
(
excinfo
.
value
)
==
'
width 129
is not between 0 and 128'
assert
str
(
excinfo
.
value
)
==
'
Slash in CIDR notation (/129)
is not between 0 and 128'
def
test_parse_subnetport_ip6_with_port
():
for
ip_repr
,
ip
in
_ip6_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
'['
+
ip_repr
+
']:80'
)
\
==
(
socket
.
AF_INET6
,
ip
,
128
,
80
,
80
)
==
[(
socket
.
AF_INET6
,
ip
,
128
,
80
,
80
)]
assert
sshuttle
.
options
.
parse_subnetport
(
'['
+
ip_repr
+
']:80-90'
)
\
==
(
socket
.
AF_INET6
,
ip
,
128
,
80
,
90
)
==
[(
socket
.
AF_INET6
,
ip
,
128
,
80
,
90
)]
def
test_parse_subnetport_ip6_with_mask_and_port
():
for
ip_repr
,
ip
in
_ip6_reprs
.
items
():
assert
sshuttle
.
options
.
parse_subnetport
(
'['
+
ip_repr
+
'/128]:80'
)
\
==
(
socket
.
AF_INET6
,
ip
,
128
,
80
,
80
)
==
[(
socket
.
AF_INET6
,
ip
,
128
,
80
,
80
)]
assert
sshuttle
.
options
.
parse_subnetport
(
'['
+
ip_repr
+
'/16]:80-90'
)
\
==
(
socket
.
AF_INET6
,
ip
,
16
,
80
,
90
)
==
[(
socket
.
AF_INET6
,
ip
,
16
,
80
,
90
)]
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