Skip to content

Commit

Permalink
Restored test for port 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasm committed Jun 27, 2022
1 parent f52f641 commit 9aa45aa
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion oauthlib/oauth1/rfc5849/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def base_string_uri(uri: str, host: str = None) -> str:
elif isinstance(hostname, ipaddress.IPv4Address):
hostname = f"{hostname}"

if port is not None and not (0 <= port <= 65535):
if port is not None and not (0 < port <= 65535):
raise ValueError('port out of range') # 16-bit unsigned ints
if (scheme, port) in (('http', 80), ('https', 443)):
netloc = hostname # default port for scheme: exclude port num
Expand Down
1 change: 1 addition & 0 deletions tests/oauth1/rfc5849/test_signatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ def test_base_string_uri(self):
self.assertRaises(ValueError, base_string_uri, 'http:https://:8080')

# Port is not a valid TCP/IP port number
self.assertRaises(ValueError, base_string_uri, 'http:https://eg.com:0')
self.assertRaises(ValueError, base_string_uri, 'http:https://eg.com:-1')
self.assertRaises(ValueError, base_string_uri, 'http:https://eg.com:65536')
self.assertRaises(ValueError, base_string_uri, 'http:https://eg.com:3.14')
Expand Down

0 comments on commit 9aa45aa

Please sign in to comment.