Allow assigning "0" to port
Function for port validation doesn't validate "0" as a proper port number, althought IANA RFC 6335 [1] describes as valid 0-65535. Add missing "0" to function. [1] https://tools.ietf.org/html/rfc6335#section-8.1.2 Change-Id: I088add52cf454e5df503ecb5d6551724fb5ddaf4 Closes-Bug: #1590485
This commit is contained in:
parent
dfdaaa2e31
commit
9598077a85
@ -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):
|
||||
|
@ -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))
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
fixes:
|
||||
- Expanded range of allowed ports by adding 0 to valid number.
|
Loading…
x
Reference in New Issue
Block a user