Merge "Allow assigning "0" to port"
This commit is contained in:
commit
98e24bedf3
@ -222,12 +222,12 @@ def _is_int_in_range(value, start, end):
|
|||||||
def is_valid_port(port):
|
def is_valid_port(port):
|
||||||
"""Verify that port represents a valid port number.
|
"""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.
|
including 65535.
|
||||||
|
|
||||||
.. versionadded:: 1.1.1
|
.. 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):
|
def is_valid_icmp_type(type):
|
||||||
|
@ -193,13 +193,13 @@ class NetworkUtilsTest(test_base.BaseTestCase):
|
|||||||
self.assertFalse(netutils.is_valid_cidr(10))
|
self.assertFalse(netutils.is_valid_cidr(10))
|
||||||
|
|
||||||
def test_valid_port(self):
|
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']
|
'80', '3246', '65535']
|
||||||
for input_str in valid_inputs:
|
for input_str in valid_inputs:
|
||||||
self.assertTrue(netutils.is_valid_port(input_str))
|
self.assertTrue(netutils.is_valid_port(input_str))
|
||||||
|
|
||||||
def test_valid_port_fail(self):
|
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]
|
'528.491', 'thirty-seven', None]
|
||||||
for input_str in invalid_inputs:
|
for input_str in invalid_inputs:
|
||||||
self.assertFalse(netutils.is_valid_port(input_str))
|
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…
Reference in New Issue
Block a user