Merge "Don't convert numeric protocol values to int" into stable/icehouse
This commit is contained in:
commit
68846f6b13
@ -114,7 +114,7 @@ def convert_protocol(value):
|
||||
try:
|
||||
val = int(value)
|
||||
if val >= 0 and val <= 255:
|
||||
return val
|
||||
return value
|
||||
raise SecurityGroupRuleInvalidProtocol(
|
||||
protocol=value, values=sg_supported_protocols)
|
||||
except (ValueError, TypeError):
|
||||
|
@ -1421,5 +1421,15 @@ class TestConvertIPPrefixToCIDR(base.BaseTestCase):
|
||||
self.assertEqual(ext_sg.convert_ip_prefix_to_cidr(addr), addr)
|
||||
|
||||
|
||||
class TestConvertProtocol(base.BaseTestCase):
|
||||
def test_convert_numeric_protocol(self):
|
||||
assert(isinstance(ext_sg.convert_protocol('2'), str))
|
||||
|
||||
def test_convert_bad_protocol(self):
|
||||
for val in ['bad', '256', '-1']:
|
||||
self.assertRaises(ext_sg.SecurityGroupRuleInvalidProtocol,
|
||||
ext_sg.convert_protocol, val)
|
||||
|
||||
|
||||
class TestSecurityGroupsXML(TestSecurityGroups):
|
||||
fmt = 'xml'
|
||||
|
Loading…
Reference in New Issue
Block a user