From 9aa45aaff0cdeab258d18c025cf66e9bdba529c0 Mon Sep 17 00:00:00 2001 From: Dariusz Smigiel Date: Mon, 27 Jun 2022 07:20:06 -0700 Subject: Restored test for port 0. --- oauthlib/oauth1/rfc5849/signature.py | 2 +- tests/oauth1/rfc5849/test_signatures.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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') -- cgit v1.2.1