diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py index 0ad02fd..f452470 100644 --- a/oslo_utils/netutils.py +++ b/oslo_utils/netutils.py @@ -222,12 +222,12 @@ def _is_int_in_range(value, start, end): def is_valid_port(port): """Verify that port represents a valid port number. - Port can be valid integer having a value of 1 up to and + Port can be valid integer having a value of 0 up to and including 65535. .. versionadded:: 1.1.1 """ - return _is_int_in_range(port, 1, 65535) + return _is_int_in_range(port, 0, 65535) def is_valid_icmp_type(type): diff --git a/oslo_utils/tests/test_netutils.py b/oslo_utils/tests/test_netutils.py index 9b15d61..823c502 100644 --- a/oslo_utils/tests/test_netutils.py +++ b/oslo_utils/tests/test_netutils.py @@ -193,13 +193,13 @@ class NetworkUtilsTest(test_base.BaseTestCase): self.assertFalse(netutils.is_valid_cidr(10)) def test_valid_port(self): - valid_inputs = [1, '1', 2, '3', '5', 8, 13, 21, + valid_inputs = [0, '0', 1, '1', 2, '3', '5', 8, 13, 21, '80', '3246', '65535'] for input_str in valid_inputs: self.assertTrue(netutils.is_valid_port(input_str)) def test_valid_port_fail(self): - invalid_inputs = ['-32768', '0', 0, '65536', 528491, '528491', + invalid_inputs = ['-32768', '65536', 528491, '528491', '528.491', 'thirty-seven', None] for input_str in invalid_inputs: self.assertFalse(netutils.is_valid_port(input_str)) diff --git a/releasenotes/notes/bump-up-port-range-f774a16336158339.yaml b/releasenotes/notes/bump-up-port-range-f774a16336158339.yaml new file mode 100644 index 0000000..5e7e9aa --- /dev/null +++ b/releasenotes/notes/bump-up-port-range-f774a16336158339.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Expanded range of allowed ports by adding 0 to valid number.