ctlplane-ip-range: Verify lower IP bound is smaller than upper
Change-Id: I9c76c3a90fed305b77b80ed39a7b2451f16de21c
This commit is contained in:
parent
bc3b90c2a8
commit
f5ba8e6f2f
6
releasenotes/notes/ip-range-input-23493c5850ddbf49.yaml
Normal file
6
releasenotes/notes/ip-range-input-23493c5850ddbf49.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Added additional input validation to the ctlplane-ip-range validation.
|
||||
The validation now ensures the lower IP bound is smaller than the upper
|
||||
bound.
|
@ -63,3 +63,10 @@ class TestIPRange(base.TestCase):
|
||||
'contains 5 addresses.', errors[0])
|
||||
self.assertEqual('This might not be enough for the deployment ' +
|
||||
'or later scaling.', errors[1])
|
||||
|
||||
def test_check_lower_bound_greater_than_upper(self):
|
||||
"""Test ip_range when lower IP bound is greater than upper"""
|
||||
errors = validation.check_arguments('192.168.0.10', '192.168.0.1', 5)
|
||||
self.assertEqual(len(errors), 1)
|
||||
self.assertEqual("Lower IP bound (192.168.0.10) must be smaller than "
|
||||
"upper bound (192.168.0.1)", errors[0])
|
||||
|
@ -70,8 +70,13 @@ def check_arguments(start, end, min_size):
|
||||
except netaddr.core.AddrFormatError:
|
||||
errors.append('Argument end ({}) must be an IP'.format(end))
|
||||
|
||||
if (not errors) and (startIP.version != endIP.version):
|
||||
errors.append('Arguments start, end must share the same IP version')
|
||||
if not errors:
|
||||
if startIP.version != endIP.version:
|
||||
errors.append("Arguments start, end must share the same IP "
|
||||
"version")
|
||||
if startIP > endIP:
|
||||
errors.append("Lower IP bound ({}) must be smaller than upper "
|
||||
"bound ({})".format(startIP, endIP))
|
||||
|
||||
if min_size < 0:
|
||||
errors.append('Argument min_size({}) must be greater than 0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user