Merge "FWaaSv2 - Enable to specify 'any' for protocol"
This commit is contained in:
@@ -147,7 +147,8 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True):
|
|||||||
if parsed_args.description:
|
if parsed_args.description:
|
||||||
attrs['description'] = str(parsed_args.description)
|
attrs['description'] = str(parsed_args.description)
|
||||||
if parsed_args.protocol:
|
if parsed_args.protocol:
|
||||||
attrs['protocol'] = parsed_args.protocol
|
protocol = parsed_args.protocol
|
||||||
|
attrs['protocol'] = None if protocol == 'any' else protocol
|
||||||
if parsed_args.action:
|
if parsed_args.action:
|
||||||
attrs['action'] = parsed_args.action
|
attrs['action'] = parsed_args.action
|
||||||
if parsed_args.ip_version:
|
if parsed_args.ip_version:
|
||||||
|
@@ -57,6 +57,8 @@ def _generate_req_and_res(verifylist):
|
|||||||
new_value = True
|
new_value = True
|
||||||
elif (key == 'disable' or key == 'disable_rule') and val:
|
elif (key == 'disable' or key == 'disable_rule') and val:
|
||||||
new_value = False
|
new_value = False
|
||||||
|
elif (key == 'protocol' and val and val.lower() == 'any'):
|
||||||
|
new_value = None
|
||||||
else:
|
else:
|
||||||
new_value = val
|
new_value = val
|
||||||
request[converted] = new_value
|
request[converted] = new_value
|
||||||
@@ -261,7 +263,7 @@ class TestCreateFirewallRule(TestFirewallRule, common.TestCreateFWaaS):
|
|||||||
self.check_parser, self.cmd, arglist, verifylist)
|
self.check_parser, self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
def test_create_with_all_params_protocol_upper_capitalized(self):
|
def test_create_with_all_params_protocol_upper_capitalized(self):
|
||||||
for protocol in ('TCP', 'Tcp', 'ANY', 'AnY'):
|
for protocol in ('TCP', 'Tcp', 'ANY', 'AnY', 'iCMp'):
|
||||||
arglist, verifylist = self._set_all_params({'protocol': protocol})
|
arglist, verifylist = self._set_all_params({'protocol': protocol})
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
testtools.matchers._impl.MismatchError,
|
testtools.matchers._impl.MismatchError,
|
||||||
@@ -359,7 +361,7 @@ class TestSetFirewallRule(TestFirewallRule, common.TestSetFWaaS):
|
|||||||
result = self.cmd.take_action(parsed_args)
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.mocked.assert_called_once_with(
|
self.mocked.assert_called_once_with(
|
||||||
target, {self.res: {'protocol': protocol}})
|
target, {self.res: {'protocol': None}})
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
def test_set_protocol_with_udp(self):
|
def test_set_protocol_with_udp(self):
|
||||||
@@ -645,6 +647,20 @@ class TestUnsetFirewallRule(TestFirewallRule, common.TestUnsetFWaaS):
|
|||||||
self.mocked = self.neutronclient.update_fwaas_firewall_rule
|
self.mocked = self.neutronclient.update_fwaas_firewall_rule
|
||||||
self.cmd = firewallrule.UnsetFirewallRule(self.app, self.namespace)
|
self.cmd = firewallrule.UnsetFirewallRule(self.app, self.namespace)
|
||||||
|
|
||||||
|
def test_unset_protocol_and_raise(self):
|
||||||
|
self.neutronclient.update_fwaas_firewall_rule.side_effect = Exception
|
||||||
|
target = self.resource['id']
|
||||||
|
arglist = [
|
||||||
|
target,
|
||||||
|
'--protocol',
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
(self.res, target),
|
||||||
|
('protocol', False)
|
||||||
|
]
|
||||||
|
self.assertRaises(utils.ParserException, self.check_parser,
|
||||||
|
self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
def test_unset_source_port(self):
|
def test_unset_source_port(self):
|
||||||
target = self.resource['id']
|
target = self.resource['id']
|
||||||
arglist = [
|
arglist = [
|
||||||
|
Reference in New Issue
Block a user