summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDariusz Smigiel <dsmigiel@redhat.com>2022-06-27 07:20:06 -0700
committerDariusz Smigiel <dsmigiel@redhat.com>2022-06-27 07:20:06 -0700
commit9aa45aaff0cdeab258d18c025cf66e9bdba529c0 (patch)
tree2b85ea4fee447da6223e5be87deeb3ea94b7e5f5
parentf52f641d763e4958d108e875e0cd6fca50d110f2 (diff)
downloadoauthlib-9aa45aaff0cdeab258d18c025cf66e9bdba529c0.tar.gz
Restored test for port 0.
-rw-r--r--oauthlib/oauth1/rfc5849/signature.py2
-rw-r--r--tests/oauth1/rfc5849/test_signatures.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/oauthlib/oauth1/rfc5849/signature.py b/oauthlib/oauth1/rfc5849/signature.py
index 862c3f3..9cb1a51 100644
--- a/oauthlib/oauth1/rfc5849/signature.py
+++ b/oauthlib/oauth1/rfc5849/signature.py
@@ -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
diff --git a/tests/oauth1/rfc5849/test_signatures.py b/tests/oauth1/rfc5849/test_signatures.py
index f0e1809..2d4735e 100644
--- a/tests/oauth1/rfc5849/test_signatures.py
+++ b/tests/oauth1/rfc5849/test_signatures.py
@@ -348,6 +348,7 @@ class SignatureTests(TestCase):
self.assertRaises(ValueError, base_string_uri, 'http://:8080')
# Port is not a valid TCP/IP port number
+ self.assertRaises(ValueError, base_string_uri, 'http://eg.com:0')
self.assertRaises(ValueError, base_string_uri, 'http://eg.com:-1')
self.assertRaises(ValueError, base_string_uri, 'http://eg.com:65536')
self.assertRaises(ValueError, base_string_uri, 'http://eg.com:3.14')