Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
51de9f46
Commit
51de9f46
authored
3 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mod]
#139
: Rename Endpoints.{server,host}
parent
f22bd045
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
duniterpy/api/endpoint.py
+61
-65
61 additions, 65 deletions
duniterpy/api/endpoint.py
tests/api/test_endpoints.py
+5
-5
5 additions, 5 deletions
tests/api/test_endpoints.py
tests/documents/test_peer.py
+6
-6
6 additions, 6 deletions
tests/documents/test_peer.py
with
72 additions
and
76 deletions
duniterpy/api/endpoint.py
+
61
−
65
View file @
51de9f46
...
...
@@ -118,7 +118,7 @@ class UnknownEndpoint(Endpoint):
"""
Return connection handler
:param proxy: Proxy
server
:param proxy: Proxy
address
:return:
"""
return
ConnectionHandler
(
""
,
""
,
""
,
0
,
""
)
...
...
@@ -147,16 +147,16 @@ class BMAEndpoint(Endpoint):
f
"
^
{
API
}
(?: (?P<host>
{
const
.
HOST_REGEX
}
))?(?: (?P<ipv4>
{
const
.
IPV4_REGEX
}
))?(?: (?P<ipv6>
{
const
.
IPV6_REGEX
}
))?(?: (?P<port>
{
const
.
PORT_REGEX
}
))$
"
)
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
)
->
None
:
def
__init__
(
self
,
host
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
)
->
None
:
"""
Init BMAEndpoint instance
:param
server: IP or domain
name
:param
host: Host
name
:param ipv4: IP as IPv4 format
:param ipv6: IP as IPv6 format
:param port: Port number
"""
self
.
server
=
server
self
.
host
=
host
self
.
ipv4
=
ipv4
self
.
ipv6
=
ipv6
self
.
port
=
port
...
...
@@ -172,11 +172,11 @@ class BMAEndpoint(Endpoint):
m
=
BMAEndpoint
.
re_inline
.
match
(
inline
)
if
m
is
None
:
raise
MalformedDocumentError
(
BMAEndpoint
.
API
)
server
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
host
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
ipv6
=
m
[
"
ipv6
"
]
port
=
int
(
m
[
"
port
"
])
return
cls
(
server
,
ipv4
,
ipv6
,
port
)
return
cls
(
host
,
ipv4
,
ipv6
,
port
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -185,7 +185,7 @@ class BMAEndpoint(Endpoint):
:return:
"""
return
BMAEndpoint
.
API
+
"
{DNS}{IPv4}{IPv6}{PORT}
"
.
format
(
DNS
=
(
"
{0}
"
.
format
(
self
.
server
)
if
self
.
server
else
""
),
DNS
=
(
"
{0}
"
.
format
(
self
.
host
)
if
self
.
host
else
""
),
IPv4
=
(
"
{0}
"
.
format
(
self
.
ipv4
)
if
self
.
ipv4
else
""
),
IPv6
=
(
"
{0}
"
.
format
(
self
.
ipv6
)
if
self
.
ipv6
else
""
),
PORT
=
(
"
{0}
"
.
format
(
self
.
port
)
if
self
.
port
else
""
),
...
...
@@ -198,9 +198,9 @@ class BMAEndpoint(Endpoint):
:param proxy: Proxy url
:return:
"""
if
self
.
server
:
if
self
.
host
:
conn_handler
=
ConnectionHandler
(
"
http
"
,
"
ws
"
,
self
.
server
,
self
.
port
,
""
,
proxy
"
http
"
,
"
ws
"
,
self
.
host
,
self
.
port
,
""
,
proxy
)
elif
self
.
ipv6
:
conn_handler
=
ConnectionHandler
(
...
...
@@ -220,14 +220,14 @@ class BMAEndpoint(Endpoint):
if
not
isinstance
(
other
,
BMAEndpoint
):
return
NotImplemented
return
(
self
.
server
==
other
.
server
self
.
host
==
other
.
host
and
self
.
ipv4
==
other
.
ipv4
and
self
.
ipv6
==
other
.
ipv6
and
self
.
port
==
other
.
port
)
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
))
return
hash
((
self
.
host
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
))
# required to type hint cls in classmethod
...
...
@@ -240,17 +240,17 @@ class SecuredBMAEndpoint(BMAEndpoint):
f
"
^
{
API
}
(?: (?P<host>
{
const
.
HOST_REGEX
}
))?(?: (?P<ipv4>
{
const
.
IPV4_REGEX
}
))?(?: (?P<ipv6>
{
const
.
IPV6_REGEX
}
))? (?P<port>
{
const
.
PORT_REGEX
}
)(?: (?P<path>
{
const
.
PATH_REGEX
}
))?$
"
)
def
__init__
(
self
,
server
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
,
path
:
str
)
->
None
:
def
__init__
(
self
,
host
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
,
path
:
str
)
->
None
:
"""
Init SecuredBMAEndpoint instance
:param
server: IP or domain
name
:param
host: Host
name
:param ipv4: IP as IPv4 format
:param ipv6: IP as IPv6 format
:param port: Port number
:param path: Url path
"""
super
().
__init__
(
server
,
ipv4
,
ipv6
,
port
)
super
().
__init__
(
host
,
ipv4
,
ipv6
,
port
)
self
.
path
=
path
@classmethod
...
...
@@ -266,14 +266,14 @@ class SecuredBMAEndpoint(BMAEndpoint):
m
=
SecuredBMAEndpoint
.
re_inline
.
match
(
inline
)
if
m
is
None
:
raise
MalformedDocumentError
(
SecuredBMAEndpoint
.
API
)
server
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
host
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
ipv6
=
m
[
"
ipv6
"
]
port
=
int
(
m
[
"
port
"
])
path
=
m
[
"
path
"
]
if
not
path
:
path
=
""
return
cls
(
server
,
ipv4
,
ipv6
,
port
,
path
)
return
cls
(
host
,
ipv4
,
ipv6
,
port
,
path
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -283,7 +283,7 @@ class SecuredBMAEndpoint(BMAEndpoint):
"""
inlined
=
[
str
(
info
)
for
info
in
(
self
.
server
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
,
self
.
path
)
for
info
in
(
self
.
host
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
,
self
.
path
)
if
info
]
return
SecuredBMAEndpoint
.
API
+
"
"
+
"
"
.
join
(
inlined
)
...
...
@@ -295,9 +295,9 @@ class SecuredBMAEndpoint(BMAEndpoint):
:param proxy: Proxy url
:return:
"""
if
self
.
server
:
if
self
.
host
:
conn_handler
=
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
server
,
self
.
port
,
self
.
path
,
proxy
"
https
"
,
"
wss
"
,
self
.
host
,
self
.
port
,
self
.
path
,
proxy
)
elif
self
.
ipv6
:
conn_handler
=
ConnectionHandler
(
...
...
@@ -321,9 +321,9 @@ class WS2PEndpoint(Endpoint):
f
"
^
{
API
}
(?P<ws2pid>
{
const
.
WS2PID_REGEX
}
) (?P<host>(?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)|(?:
{
const
.
IPV6_REGEX
}
)) (?P<port>
{
const
.
PORT_REGEX
}
)?(?: (?P<path>
{
const
.
PATH_REGEX
}
))?$
"
)
def
__init__
(
self
,
ws2pid
:
str
,
server
:
str
,
port
:
int
,
path
:
str
)
->
None
:
def
__init__
(
self
,
ws2pid
:
str
,
host
:
str
,
port
:
int
,
path
:
str
)
->
None
:
self
.
ws2pid
=
ws2pid
self
.
server
=
server
self
.
host
=
host
self
.
port
=
port
self
.
path
=
path
...
...
@@ -339,12 +339,12 @@ class WS2PEndpoint(Endpoint):
if
m
is
None
:
raise
MalformedDocumentError
(
WS2PEndpoint
.
API
)
ws2pid
=
m
[
"
ws2pid
"
]
server
=
m
[
"
host
"
]
host
=
m
[
"
host
"
]
port
=
int
(
m
[
"
port
"
])
path
=
m
[
"
path
"
]
if
not
path
:
path
=
""
return
cls
(
ws2pid
,
server
,
port
,
path
)
return
cls
(
ws2pid
,
host
,
port
,
path
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -353,9 +353,7 @@ class WS2PEndpoint(Endpoint):
:return:
"""
inlined
=
[
str
(
info
)
for
info
in
(
self
.
ws2pid
,
self
.
server
,
self
.
port
,
self
.
path
)
if
info
str
(
info
)
for
info
in
(
self
.
ws2pid
,
self
.
host
,
self
.
port
,
self
.
path
)
if
info
]
return
WS2PEndpoint
.
API
+
"
"
+
"
"
.
join
(
inlined
)
...
...
@@ -372,7 +370,7 @@ class WS2PEndpoint(Endpoint):
http_scheme
+=
"
s
"
websocket_scheme
+=
"
s
"
return
ConnectionHandler
(
http_scheme
,
websocket_scheme
,
self
.
server
,
self
.
port
,
self
.
path
,
proxy
http_scheme
,
websocket_scheme
,
self
.
host
,
self
.
port
,
self
.
path
,
proxy
)
def
__str__
(
self
)
->
str
:
...
...
@@ -382,14 +380,14 @@ class WS2PEndpoint(Endpoint):
if
not
isinstance
(
other
,
WS2PEndpoint
):
return
NotImplemented
return
(
self
.
server
==
other
.
server
self
.
host
==
other
.
host
and
self
.
ws2pid
==
other
.
ws2pid
and
self
.
port
==
other
.
port
and
self
.
path
==
other
.
path
)
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
ws2pid
,
self
.
server
,
self
.
port
,
self
.
path
))
return
hash
((
self
.
ws2pid
,
self
.
host
,
self
.
port
,
self
.
path
))
# required to type hint cls in classmethod
...
...
@@ -402,8 +400,8 @@ class ESCoreEndpoint(Endpoint):
f
"
^
{
API
}
(?P<host>(?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)) (?P<port>
{
const
.
PORT_REGEX
}
)$
"
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
self
.
server
=
server
def
__init__
(
self
,
host
:
str
,
port
:
int
)
->
None
:
self
.
host
=
host
self
.
port
=
port
@classmethod
...
...
@@ -417,9 +415,9 @@ class ESCoreEndpoint(Endpoint):
m
=
ESCoreEndpoint
.
re_inline
.
match
(
inline
)
if
m
is
None
:
raise
MalformedDocumentError
(
ESCoreEndpoint
.
API
)
server
=
m
[
"
host
"
]
host
=
m
[
"
host
"
]
port
=
int
(
m
[
"
port
"
])
return
cls
(
server
,
port
)
return
cls
(
host
,
port
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -427,7 +425,7 @@ class ESCoreEndpoint(Endpoint):
:return:
"""
inlined
=
[
str
(
info
)
for
info
in
(
self
.
server
,
self
.
port
)
if
info
]
inlined
=
[
str
(
info
)
for
info
in
(
self
.
host
,
self
.
port
)
if
info
]
return
ESCoreEndpoint
.
API
+
"
"
+
"
"
.
join
(
inlined
)
def
conn_handler
(
self
,
proxy
:
str
=
None
)
->
ConnectionHandler
:
...
...
@@ -437,7 +435,7 @@ class ESCoreEndpoint(Endpoint):
:param proxy: Proxy url
:return:
"""
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
server
,
self
.
port
,
""
,
proxy
)
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
host
,
self
.
port
,
""
,
proxy
)
def
__str__
(
self
)
->
str
:
return
self
.
inline
()
...
...
@@ -445,10 +443,10 @@ class ESCoreEndpoint(Endpoint):
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
not
isinstance
(
other
,
ESCoreEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
host
==
other
.
host
and
self
.
port
==
other
.
port
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
port
))
return
hash
((
self
.
host
,
self
.
port
))
# required to type hint cls in classmethod
...
...
@@ -461,8 +459,8 @@ class ESUserEndpoint(Endpoint):
"
^{API} (?P<host>(?:{const.HOST_REGEX})|(?:{const.IPV4_REGEX})) (?P<port>{const.PORT_REGEX})$
"
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
self
.
server
=
server
def
__init__
(
self
,
host
:
str
,
port
:
int
)
->
None
:
self
.
host
=
host
self
.
port
=
port
@classmethod
...
...
@@ -476,9 +474,9 @@ class ESUserEndpoint(Endpoint):
m
=
ESUserEndpoint
.
re_inline
.
match
(
inline
)
if
m
is
None
:
raise
MalformedDocumentError
(
ESUserEndpoint
.
API
)
server
=
m
[
"
host
"
]
host
=
m
[
"
host
"
]
port
=
int
(
m
[
"
port
"
])
return
cls
(
server
,
port
)
return
cls
(
host
,
port
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -486,7 +484,7 @@ class ESUserEndpoint(Endpoint):
:return:
"""
inlined
=
[
str
(
info
)
for
info
in
(
self
.
server
,
self
.
port
)
if
info
]
inlined
=
[
str
(
info
)
for
info
in
(
self
.
host
,
self
.
port
)
if
info
]
return
ESUserEndpoint
.
API
+
"
"
+
"
"
.
join
(
inlined
)
def
conn_handler
(
self
,
proxy
:
str
=
None
)
->
ConnectionHandler
:
...
...
@@ -496,7 +494,7 @@ class ESUserEndpoint(Endpoint):
:param proxy: Proxy url
:return:
"""
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
server
,
self
.
port
,
""
,
proxy
)
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
host
,
self
.
port
,
""
,
proxy
)
def
__str__
(
self
)
->
str
:
return
self
.
inline
()
...
...
@@ -504,10 +502,10 @@ class ESUserEndpoint(Endpoint):
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
not
isinstance
(
other
,
ESUserEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
host
==
other
.
host
and
self
.
port
==
other
.
port
def
__hash__
(
self
)
->
int
:
return
hash
((
self
.
server
,
self
.
port
))
return
hash
((
self
.
host
,
self
.
port
))
# required to type hint cls in classmethod
...
...
@@ -522,8 +520,8 @@ class ESSubscribtionEndpoint(Endpoint):
f
"
^
{
API
}
(?P<host>(?:
{
const
.
HOST_REGEX
}
)|(?:
{
const
.
IPV4_REGEX
}
)) (?P<port>
{
const
.
PORT_REGEX
}
)$
"
)
def
__init__
(
self
,
server
:
str
,
port
:
int
)
->
None
:
self
.
server
=
server
def
__init__
(
self
,
host
:
str
,
port
:
int
)
->
None
:
self
.
host
=
host
self
.
port
=
port
@classmethod
...
...
@@ -539,9 +537,9 @@ class ESSubscribtionEndpoint(Endpoint):
m
=
ESSubscribtionEndpoint
.
re_inline
.
match
(
inline
)
if
m
is
None
:
raise
MalformedDocumentError
(
ESSubscribtionEndpoint
.
API
)
server
=
m
[
"
host
"
]
host
=
m
[
"
host
"
]
port
=
int
(
m
[
"
port
"
])
return
cls
(
server
,
port
)
return
cls
(
host
,
port
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -549,7 +547,7 @@ class ESSubscribtionEndpoint(Endpoint):
:return:
"""
inlined
=
[
str
(
info
)
for
info
in
(
self
.
server
,
self
.
port
)
if
info
]
inlined
=
[
str
(
info
)
for
info
in
(
self
.
host
,
self
.
port
)
if
info
]
return
ESSubscribtionEndpoint
.
API
+
"
"
+
"
"
.
join
(
inlined
)
def
conn_handler
(
self
,
proxy
:
str
=
None
)
->
ConnectionHandler
:
...
...
@@ -559,7 +557,7 @@ class ESSubscribtionEndpoint(Endpoint):
:param proxy: Proxy url
:return:
"""
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
server
,
self
.
port
,
""
,
proxy
)
return
ConnectionHandler
(
"
https
"
,
"
wss
"
,
self
.
host
,
self
.
port
,
""
,
proxy
)
def
__str__
(
self
)
->
str
:
return
self
.
inline
()
...
...
@@ -567,10 +565,10 @@ class ESSubscribtionEndpoint(Endpoint):
def
__eq__
(
self
,
other
:
Any
)
->
bool
:
if
not
isinstance
(
other
,
ESSubscribtionEndpoint
):
return
NotImplemented
return
self
.
server
==
other
.
server
and
self
.
port
==
other
.
port
return
self
.
host
==
other
.
host
and
self
.
port
==
other
.
port
def
__hash__
(
self
)
->
int
:
return
hash
((
ESSubscribtionEndpoint
.
API
,
self
.
server
,
self
.
port
))
return
hash
((
ESSubscribtionEndpoint
.
API
,
self
.
host
,
self
.
port
))
# required to type hint cls in classmethod
...
...
@@ -585,7 +583,7 @@ class GVAEndpoint(Endpoint):
def
__init__
(
self
,
flags
:
str
,
server
:
str
,
host
:
str
,
ipv4
:
str
,
ipv6
:
str
,
port
:
int
,
...
...
@@ -595,14 +593,14 @@ class GVAEndpoint(Endpoint):
Init GVAEndpoint instance
:param flags: Flags of endpoint
:param
server: IP or domain
name
:param
host: Host
name
:param ipv4: IP as IPv4 format
:param ipv6: IP as IPv6 format
:param port: Port number
:param path: Url path
"""
self
.
flags
=
flags
self
.
server
=
server
self
.
host
=
host
self
.
ipv4
=
ipv4
self
.
ipv6
=
ipv6
self
.
port
=
port
...
...
@@ -620,7 +618,7 @@ class GVAEndpoint(Endpoint):
if
m
is
None
:
raise
MalformedDocumentError
(
cls
.
API
)
flags
=
m
[
"
flags
"
]
server
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
host
,
ipv4
=
fix_host_ipv4_mix_up
(
m
[
"
host
"
],
m
[
"
ipv4
"
])
ipv6
=
m
[
"
ipv6
"
]
port
=
int
(
m
[
"
port
"
])
path
=
m
[
"
path
"
]
...
...
@@ -629,7 +627,7 @@ class GVAEndpoint(Endpoint):
flags
=
""
if
not
path
:
path
=
""
return
cls
(
flags
,
server
,
ipv4
,
ipv6
,
port
,
path
)
return
cls
(
flags
,
host
,
ipv4
,
ipv6
,
port
,
path
)
def
inline
(
self
)
->
str
:
"""
...
...
@@ -641,7 +639,7 @@ class GVAEndpoint(Endpoint):
str
(
info
)
for
info
in
(
self
.
flags
,
self
.
server
,
self
.
host
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
,
...
...
@@ -661,9 +659,9 @@ class GVAEndpoint(Endpoint):
scheme_http
=
"
https
"
if
"
S
"
in
self
.
flags
else
"
http
"
scheme_ws
=
"
wss
"
if
"
S
"
in
self
.
flags
else
"
ws
"
if
self
.
server
:
if
self
.
host
:
conn_handler
=
ConnectionHandler
(
scheme_http
,
scheme_ws
,
self
.
server
,
self
.
port
,
self
.
path
,
proxy
scheme_http
,
scheme_ws
,
self
.
host
,
self
.
port
,
self
.
path
,
proxy
)
elif
self
.
ipv6
:
conn_handler
=
ConnectionHandler
(
...
...
@@ -689,7 +687,7 @@ class GVAEndpoint(Endpoint):
return
NotImplemented
return
(
self
.
flags
==
other
.
flags
and
self
.
server
==
other
.
server
and
self
.
host
==
other
.
host
and
self
.
ipv4
==
other
.
ipv4
and
self
.
ipv6
==
other
.
ipv6
and
self
.
port
==
other
.
port
...
...
@@ -697,9 +695,7 @@ class GVAEndpoint(Endpoint):
)
def
__hash__
(
self
)
->
int
:
return
hash
(
(
self
.
flags
,
self
.
server
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
,
self
.
path
)
)
return
hash
((
self
.
flags
,
self
.
host
,
self
.
ipv4
,
self
.
ipv6
,
self
.
port
,
self
.
path
))
MANAGED_API
=
{
...
...
This diff is collapsed.
Click to expand it.
tests/api/test_endpoints.py
+
5
−
5
View file @
51de9f46
...
...
@@ -25,7 +25,7 @@ class TestEndpoint(unittest.TestCase):
gva_endpoint
=
endpoint
.
GVAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
gva_endpoint
.
flags
,
""
)
self
.
assertEqual
(
gva_endpoint
.
server
,
"
test.domain.com
"
)
self
.
assertEqual
(
gva_endpoint
.
host
,
"
test.domain.com
"
)
self
.
assertEqual
(
gva_endpoint
.
ipv4
,
"
127.0.0.1
"
)
self
.
assertEqual
(
gva_endpoint
.
ipv6
,
"
2001:0db8:0000:85a3:0000:0000:ac1f:8001
"
)
self
.
assertEqual
(
gva_endpoint
.
port
,
10902
)
...
...
@@ -38,7 +38,7 @@ class TestEndpoint(unittest.TestCase):
gva_endpoint
=
endpoint
.
GVAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
gva_endpoint
.
flags
,
"
S
"
)
self
.
assertEqual
(
gva_endpoint
.
server
,
"
test.domain.com
"
)
self
.
assertEqual
(
gva_endpoint
.
host
,
"
test.domain.com
"
)
self
.
assertEqual
(
gva_endpoint
.
ipv4
,
None
)
self
.
assertEqual
(
gva_endpoint
.
ipv6
,
None
)
self
.
assertEqual
(
gva_endpoint
.
port
,
10902
)
...
...
@@ -51,7 +51,7 @@ class TestEndpoint(unittest.TestCase):
gva_endpoint
=
endpoint
.
GVAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
gva_endpoint
.
flags
,
"
S
"
)
self
.
assertEqual
(
gva_endpoint
.
server
,
"
xn--duniter.org
"
)
self
.
assertEqual
(
gva_endpoint
.
host
,
"
xn--duniter.org
"
)
self
.
assertEqual
(
gva_endpoint
.
ipv4
,
None
)
self
.
assertEqual
(
gva_endpoint
.
ipv6
,
None
)
self
.
assertEqual
(
gva_endpoint
.
port
,
10902
)
...
...
@@ -62,11 +62,11 @@ class TestEndpoint(unittest.TestCase):
def
test_gva_host_ipv4_mix_up
(
self
):
endpoint_str
=
"
GVA S 127.0.0.1 443 gva
"
gva_endpoint
=
endpoint
.
GVAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
gva_endpoint
.
server
,
""
)
self
.
assertEqual
(
gva_endpoint
.
host
,
""
)
self
.
assertEqual
(
gva_endpoint
.
ipv4
,
"
127.0.0.1
"
)
def
test_bmas_host_ipv4_mix_up
(
self
):
endpoint_str
=
"
BMAS 127.0.0.1 443 bma
"
bmas_endpoint
=
endpoint
.
SecuredBMAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
bmas_endpoint
.
server
,
""
)
self
.
assertEqual
(
bmas_endpoint
.
host
,
""
)
self
.
assertEqual
(
bmas_endpoint
.
ipv4
,
"
127.0.0.1
"
)
This diff is collapsed.
Click to expand it.
tests/documents/test_peer.py
+
6
−
6
View file @
51de9f46
...
...
@@ -57,17 +57,17 @@ class TestPeer(unittest.TestCase):
self
.
assertIsInstance
(
peer
.
endpoints
[
2
],
WS2PEndpoint
)
self
.
assertIsInstance
(
peer
.
endpoints
[
3
],
UnknownEndpoint
)
self
.
assertEqual
(
peer
.
endpoints
[
0
].
server
,
"
some.dns.name
"
)
self
.
assertEqual
(
peer
.
endpoints
[
0
].
host
,
"
some.dns.name
"
)
self
.
assertEqual
(
peer
.
endpoints
[
0
].
ipv4
,
"
88.77.66.55
"
)
self
.
assertEqual
(
peer
.
endpoints
[
0
].
ipv6
,
"
2001:42d0:52:a00::648
"
)
self
.
assertEqual
(
peer
.
endpoints
[
0
].
port
,
9001
)
self
.
assertEqual
(
peer
.
endpoints
[
1
].
server
,
"
some.dns.name
"
)
self
.
assertEqual
(
peer
.
endpoints
[
1
].
host
,
"
some.dns.name
"
)
self
.
assertEqual
(
peer
.
endpoints
[
1
].
ipv4
,
"
88.77.66.55
"
)
self
.
assertEqual
(
peer
.
endpoints
[
1
].
ipv6
,
"
2001:42d0:52:a00::648
"
)
self
.
assertEqual
(
peer
.
endpoints
[
1
].
port
,
9002
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
server
,
"
g1-test.duniter.org
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
host
,
"
g1-test.duniter.org
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
ws2pid
,
"
d2edcb92
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
port
,
20902
)
...
...
@@ -95,17 +95,17 @@ class TestPeer(unittest.TestCase):
self
.
assertIsInstance
(
peer
.
endpoints
[
2
],
WS2PEndpoint
)
self
.
assertIsInstance
(
peer
.
endpoints
[
3
],
UnknownEndpoint
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
0
].
server
,
"
some.dns.name
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
0
].
host
,
"
some.dns.name
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
0
].
ipv4
,
"
88.77.66.55
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
0
].
ipv6
,
"
2001:42d0:52:a00::648
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
0
].
port
,
9001
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
1
].
server
,
"
some.dns.name
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
1
].
host
,
"
some.dns.name
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
1
].
ipv4
,
"
88.77.66.55
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
1
].
ipv6
,
"
2001:42d0:52:a00::648
"
)
self
.
assertEqual
(
from_rendered_peer
.
endpoints
[
1
].
port
,
9002
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
server
,
"
g1-test.duniter.org
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
host
,
"
g1-test.duniter.org
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
ws2pid
,
"
d2edcb92
"
)
self
.
assertEqual
(
peer
.
endpoints
[
2
].
port
,
20902
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment