diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-01-24 15:22:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-01-24 15:22:08 +0000 |
| commit | 1a2820da3ea70e2c39960875e4b5af13c6354df8 (patch) | |
| tree | b868b3f01146d116fcce9b3bc6ebe759d3c9c1d9 | |
| parent | a910bf78aa2f633399a65931439be8bd17aa5699 (diff) | |
| parent | 9fa08d1bd0314ac63ad7923cae1c3129c64174e3 (diff) | |
| download | python-neutronclient-6.1.0.tar.gz | |
Merge "FWaaSv2 - Enable to specify 'any' for protocol"6.1.0
| -rw-r--r-- | neutronclient/osc/v2/fwaas/firewallrule.py | 3 | ||||
| -rw-r--r-- | neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py | 20 |
2 files changed, 20 insertions, 3 deletions
diff --git a/neutronclient/osc/v2/fwaas/firewallrule.py b/neutronclient/osc/v2/fwaas/firewallrule.py index 4b10e3b..ec87351 100644 --- a/neutronclient/osc/v2/fwaas/firewallrule.py +++ b/neutronclient/osc/v2/fwaas/firewallrule.py @@ -147,7 +147,8 @@ def _get_common_attrs(client_manager, parsed_args, is_create=True): if parsed_args.description: attrs['description'] = str(parsed_args.description) 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: attrs['action'] = parsed_args.action if parsed_args.ip_version: diff --git a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py index be1b3b1..e1ad201 100644 --- a/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py +++ b/neutronclient/tests/unit/osc/v2/fwaas/test_firewallrule.py @@ -57,6 +57,8 @@ def _generate_req_and_res(verifylist): new_value = True elif (key == 'disable' or key == 'disable_rule') and val: new_value = False + elif (key == 'protocol' and val and val.lower() == 'any'): + new_value = None else: new_value = val request[converted] = new_value @@ -261,7 +263,7 @@ class TestCreateFirewallRule(TestFirewallRule, common.TestCreateFWaaS): self.check_parser, self.cmd, arglist, verifylist) 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}) self.assertRaises( testtools.matchers._impl.MismatchError, @@ -359,7 +361,7 @@ class TestSetFirewallRule(TestFirewallRule, common.TestSetFWaaS): result = self.cmd.take_action(parsed_args) self.mocked.assert_called_once_with( - target, {self.res: {'protocol': protocol}}) + target, {self.res: {'protocol': None}}) self.assertIsNone(result) 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.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): target = self.resource['id'] arglist = [ |
