diff options
Diffstat (limited to 'neutronclient/tests/unit/vpn')
-rw-r--r-- | neutronclient/tests/unit/vpn/__init__.py | 0 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_cli20_endpoint_group.py | 145 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py | 241 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_cli20_ipsec_site_connection.py | 342 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py | 249 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_cli20_vpnservice.py | 157 | ||||
-rw-r--r-- | neutronclient/tests/unit/vpn/test_utils.py | 130 |
7 files changed, 0 insertions, 1264 deletions
diff --git a/neutronclient/tests/unit/vpn/__init__.py b/neutronclient/tests/unit/vpn/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/neutronclient/tests/unit/vpn/__init__.py +++ /dev/null diff --git a/neutronclient/tests/unit/vpn/test_cli20_endpoint_group.py b/neutronclient/tests/unit/vpn/test_cli20_endpoint_group.py deleted file mode 100644 index f43da90..0000000 --- a/neutronclient/tests/unit/vpn/test_cli20_endpoint_group.py +++ /dev/null @@ -1,145 +0,0 @@ -# (c) Copyright 2015 Cisco Systems, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import sys - -from neutronclient.neutron.v2_0.vpn import endpoint_group -from neutronclient.tests.unit import test_cli20 - - -class CLITestV20VpnEndpointGroupJSON(test_cli20.CLITestV20Base): - - def setUp(self): - super(CLITestV20VpnEndpointGroupJSON, self).setUp() - self.register_non_admin_status_resource('endpoint_group') - - def test_create_endpoint_group_with_cidrs(self): - # vpn-endpoint-group-create with CIDR endpoints.""" - resource = 'endpoint_group' - cmd = endpoint_group.CreateEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - tenant_id = 'mytenant-id' - my_id = 'my-id' - name = 'my-endpoint-group' - description = 'my endpoint group' - endpoint_type = 'cidr' - endpoints = ['10.0.0.0/24', '20.0.0.0/24'] - - args = ['--name', name, - '--description', description, - '--tenant-id', tenant_id, - '--type', endpoint_type, - '--value', '10.0.0.0/24', - '--value', '20.0.0.0/24'] - - position_names = ['name', 'description', 'tenant_id', - 'type', 'endpoints'] - - position_values = [name, description, tenant_id, - endpoint_type, endpoints] - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values) - - def test_create_endpoint_group_with_subnets(self): - # vpn-endpoint-group-create with subnet endpoints.""" - resource = 'endpoint_group' - cmd = endpoint_group.CreateEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - tenant_id = 'mytenant-id' - my_id = 'my-id' - endpoint_type = 'subnet' - subnet = 'subnet-id' - endpoints = [subnet] - - args = ['--type', endpoint_type, - '--value', subnet, - '--tenant-id', tenant_id] - - position_names = ['type', 'endpoints', 'tenant_id'] - - position_values = [endpoint_type, endpoints, tenant_id] - - self._test_create_resource(resource, cmd, None, my_id, args, - position_names, position_values) - - def test_list_endpoint_group(self): - # vpn-endpoint-group-list. - resources = "endpoint_groups" - cmd = endpoint_group.ListEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - self._test_list_resources(resources, cmd, True) - - def test_list_endpoint_group_pagination(self): - # vpn-endpoint-group-list. - resources = "endpoint_groups" - cmd = endpoint_group.ListEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - self._test_list_resources_with_pagination(resources, cmd) - - def test_list_endpoint_group_sort(self): - # vpn-endpoint-group-list --sort-key name --sort-key id - # --sort-key asc --sort-key desc - resources = "endpoint_groups" - cmd = endpoint_group.ListEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - self._test_list_resources(resources, cmd, - sort_key=["name", "id"], - sort_dir=["asc", "desc"]) - - def test_list_endpoint_group_limit(self): - # vpn-endpoint-group-list -P. - resources = "endpoint_groups" - cmd = endpoint_group.ListEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - self._test_list_resources(resources, cmd, page_size=1000) - - def test_show_endpoint_group_id(self): - # vpn-endpoint-group-show test_id. - resource = 'endpoint_group' - cmd = endpoint_group.ShowEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - args = ['--fields', 'id', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, args, ['id']) - - def test_show_endpoint_group_id_name(self): - # vpn-endpoint-group-show. - resource = 'endpoint_group' - cmd = endpoint_group.ShowEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - args = ['--fields', 'id', '--fields', 'name', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, - args, ['id', 'name']) - - def test_update_endpoint_group(self): - # vpn-endpoint-group-update myid --name newname --description newdesc. - resource = 'endpoint_group' - cmd = endpoint_group.UpdateEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--name', 'newname', - '--description', 'newdesc'], - {'name': 'newname', - 'description': 'newdesc'}) - - def test_delete_endpoint_group(self): - # vpn-endpoint-group-delete my-id. - resource = 'endpoint_group' - cmd = endpoint_group.DeleteEndpointGroup(test_cli20.MyApp(sys.stdout), - None) - my_id = 'my-id' - args = [my_id] - self._test_delete_resource(resource, cmd, my_id, args) diff --git a/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py b/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py deleted file mode 100644 index 33e326c..0000000 --- a/neutronclient/tests/unit/vpn/test_cli20_ikepolicy.py +++ /dev/null @@ -1,241 +0,0 @@ -# (c) Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import sys - -from neutronclient.common import exceptions -from neutronclient.neutron.v2_0.vpn import ikepolicy -from neutronclient.tests.unit import test_cli20 - - -class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base): - - non_admin_status_resources = ['ikepolicy'] - - def _test_create_ikepolicy_all_params(self, auth='sha1', - expected_exc=None): - # vpn-ikepolicy-create all params. - resource = 'ikepolicy' - cmd = ikepolicy.CreateIKEPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ikepolicy1' - description = 'my-ike-policy' - auth_algorithm = auth - encryption_algorithm = 'aes-256' - ike_version = 'v1' - phase1_negotiation_mode = 'main' - pfs = 'group5' - tenant_id = 'my-tenant' - my_id = 'my-id' - lifetime = 'units=seconds,value=20000' - - args = [name, - '--description', description, - '--tenant-id', tenant_id, - '--auth-algorithm', auth_algorithm, - '--encryption-algorithm', encryption_algorithm, - '--ike-version', ike_version, - '--phase1-negotiation-mode', phase1_negotiation_mode, - '--lifetime', lifetime, - '--pfs', pfs] - - position_names = ['name', 'description', - 'auth_algorithm', 'encryption_algorithm', - 'phase1_negotiation_mode', - 'ike_version', 'pfs', - 'tenant_id'] - - position_values = [name, description, - auth_algorithm, encryption_algorithm, - phase1_negotiation_mode, ike_version, pfs, - tenant_id] - extra_body = { - 'lifetime': { - 'units': 'seconds', - 'value': 20000, - }, - } - - if not expected_exc: - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - else: - self.assertRaises( - expected_exc, - self._test_create_resource, - resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - - def test_create_ikepolicy_all_params(self): - self._test_create_ikepolicy_all_params() - - def test_create_ikepolicy_auth_sha256(self): - self._test_create_ikepolicy_all_params(auth='sha256') - - def test_create_ikepolicy_auth_sha384(self): - self._test_create_ikepolicy_all_params(auth='sha384') - - def test_create_ikepolicy_auth_sha512(self): - self._test_create_ikepolicy_all_params(auth='sha512') - - def test_create_ikepolicy_invalid_auth(self): - self._test_create_ikepolicy_all_params(auth='invalid', - expected_exc=SystemExit) - - def test_create_ikepolicy_with_limited_params(self): - # vpn-ikepolicy-create with limited params. - resource = 'ikepolicy' - cmd = ikepolicy.CreateIKEPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ikepolicy1' - auth_algorithm = 'sha1' - encryption_algorithm = 'aes-128' - ike_version = 'v1' - phase1_negotiation_mode = 'main' - pfs = 'group5' - tenant_id = 'my-tenant' - my_id = 'my-id' - - args = [name, - '--tenant-id', tenant_id] - - position_names = ['name', - 'auth_algorithm', 'encryption_algorithm', - 'phase1_negotiation_mode', - 'ike_version', 'pfs', - 'tenant_id'] - - position_values = [name, - auth_algorithm, encryption_algorithm, - phase1_negotiation_mode, - ike_version, pfs, - tenant_id] - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values) - - def _test_lifetime_values(self, lifetime, expected_exc=None): - resource = 'ikepolicy' - cmd = ikepolicy.CreateIKEPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ikepolicy1' - description = 'my-ike-policy' - auth_algorithm = 'sha1' - encryption_algorithm = 'aes-256' - ike_version = 'v1' - phase1_negotiation_mode = 'main' - pfs = 'group5' - tenant_id = 'my-tenant' - my_id = 'my-id' - - args = [name, - '--description', description, - '--tenant-id', tenant_id, - '--auth-algorithm', auth_algorithm, - '--encryption-algorithm', encryption_algorithm, - '--ike-version', ike_version, - '--phase1-negotiation-mode', phase1_negotiation_mode, - '--lifetime', lifetime, - '--pfs', pfs] - - position_names = ['name', 'description', - 'auth_algorithm', 'encryption_algorithm', - 'phase1_negotiation_mode', - 'ike_version', 'pfs', - 'tenant_id'] - - position_values = [name, description, - auth_algorithm, encryption_algorithm, - phase1_negotiation_mode, ike_version, pfs, - tenant_id] - if not expected_exc: - expected_exc = exceptions.CommandError - self.assertRaises( - expected_exc, - self._test_create_resource, - resource, cmd, name, my_id, args, - position_names, position_values) - - def test_create_ikepolicy_with_invalid_lifetime_keys(self): - lifetime = 'uts=seconds,val=20000' - self._test_lifetime_values(lifetime, expected_exc=SystemExit) - - def test_create_ikepolicy_with_invalid_lifetime_value(self): - lifetime = 'units=seconds,value=-1' - self._test_lifetime_values(lifetime) - - def test_list_ikepolicy(self): - # vpn-ikepolicy-list. - resources = "ikepolicies" - cmd = ikepolicy.ListIKEPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, True) - - def test_list_ikepolicy_pagination(self): - # vpn-ikepolicy-list. - resources = "ikepolicies" - cmd = ikepolicy.ListIKEPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources_with_pagination(resources, cmd) - - def test_list_ikepolicy_sort(self): - # vpn-ikepolicy-list --sort-key name --sort-key id --sort-key asc - # --sort-key desc - resources = "ikepolicies" - cmd = ikepolicy.ListIKEPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, - sort_key=["name", "id"], - sort_dir=["asc", "desc"]) - - def test_list_ikepolicy_limit(self): - # vpn-ikepolicy-list -P. - resources = "ikepolicies" - cmd = ikepolicy.ListIKEPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, page_size=1000) - - def test_show_ikepolicy_id(self): - # vpn-ikepolicy-show ikepolicy_id. - resource = 'ikepolicy' - cmd = ikepolicy.ShowIKEPolicy(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, args, ['id']) - - def test_show_ikepolicy_id_name(self): - # vpn-ikepolicy-show. - resource = 'ikepolicy' - cmd = ikepolicy.ShowIKEPolicy(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', '--fields', 'name', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, - args, ['id', 'name']) - - def test_update_ikepolicy(self): - # vpn-ikepolicy-update myid --name newname --tags a b. - resource = 'ikepolicy' - cmd = ikepolicy.UpdateIKEPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--name', 'newname'], - {'name': 'newname', }) - # vpn-ikepolicy-update myid --pfs group2 --ike-version v2. - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--pfs', 'group2', - '--ike-version', 'v2'], - {'pfs': 'group2', - 'ike_version': 'v2'}) - - def test_delete_ikepolicy(self): - # vpn-ikepolicy-delete my-id. - resource = 'ikepolicy' - cmd = ikepolicy.DeleteIKEPolicy(test_cli20.MyApp(sys.stdout), None) - my_id = 'my-id' - args = [my_id] - self._test_delete_resource(resource, cmd, my_id, args) diff --git a/neutronclient/tests/unit/vpn/test_cli20_ipsec_site_connection.py b/neutronclient/tests/unit/vpn/test_cli20_ipsec_site_connection.py deleted file mode 100644 index cbab15c..0000000 --- a/neutronclient/tests/unit/vpn/test_cli20_ipsec_site_connection.py +++ /dev/null @@ -1,342 +0,0 @@ -# (c) Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import sys - -from neutronclient.common import exceptions -from neutronclient.neutron.v2_0.vpn import ipsec_site_connection -from neutronclient.tests.unit import test_cli20 - - -class CLITestV20IPsecSiteConnectionJSON(test_cli20.CLITestV20Base): - - # TODO(pcm): Remove, once peer-cidr is deprecated completely - def test_create_ipsec_site_connection_all_params_using_peer_cidrs(self): - # ipsecsite-connection-create all params using peer CIDRs. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.CreateIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - tenant_id = 'mytenant_id' - name = 'connection1' - my_id = 'my_id' - peer_address = '192.168.2.10' - peer_id = '192.168.2.10' - psk = 'abcd' - mtu = '1500' - initiator = 'bi-directional' - vpnservice_id = 'vpnservice_id' - ikepolicy_id = 'ikepolicy_id' - ipsecpolicy_id = 'ipsecpolicy_id' - peer_cidrs = ['192.168.3.0/24', '192.168.2.0/24'] - admin_state = True - description = 'my-vpn-connection' - dpd = 'action=restart,interval=30,timeout=120' - - args = ['--tenant-id', tenant_id, - '--peer-address', peer_address, '--peer-id', peer_id, - '--psk', psk, '--initiator', initiator, - '--vpnservice-id', vpnservice_id, - '--ikepolicy-id', ikepolicy_id, '--name', name, - '--ipsecpolicy-id', ipsecpolicy_id, '--mtu', mtu, - '--description', description, - '--peer-cidr', '192.168.3.0/24', - '--peer-cidr', '192.168.2.0/24', - '--dpd', dpd] - - position_names = ['name', 'tenant_id', 'admin_state_up', - 'peer_address', 'peer_id', 'peer_cidrs', - 'psk', 'mtu', 'initiator', 'description', - 'vpnservice_id', 'ikepolicy_id', - 'ipsecpolicy_id'] - - position_values = [name, tenant_id, admin_state, peer_address, - peer_id, peer_cidrs, psk, mtu, - initiator, description, - vpnservice_id, ikepolicy_id, ipsecpolicy_id] - extra_body = { - 'dpd': { - 'action': 'restart', - 'interval': 30, - 'timeout': 120, - }, - } - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - - def test_create_ipsec_site_conn_all_params(self): - # ipsecsite-connection-create all params using endpoint groups. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.CreateIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - tenant_id = 'mytenant_id' - name = 'connection1' - my_id = 'my_id' - peer_address = '192.168.2.10' - peer_id = '192.168.2.10' - psk = 'abcd' - mtu = '1500' - initiator = 'bi-directional' - vpnservice_id = 'vpnservice_id' - ikepolicy_id = 'ikepolicy_id' - ipsecpolicy_id = 'ipsecpolicy_id' - local_ep_group = 'local-epg' - peer_ep_group = 'peer-epg' - admin_state = True - description = 'my-vpn-connection' - dpd = 'action=restart,interval=30,timeout=120' - - args = ['--tenant-id', tenant_id, - '--peer-address', peer_address, '--peer-id', peer_id, - '--psk', psk, '--initiator', initiator, - '--vpnservice-id', vpnservice_id, - '--ikepolicy-id', ikepolicy_id, '--name', name, - '--ipsecpolicy-id', ipsecpolicy_id, '--mtu', mtu, - '--description', description, - '--local-ep-group', local_ep_group, - '--peer-ep-group', peer_ep_group, - '--dpd', dpd] - - position_names = ['name', 'tenant_id', 'admin_state_up', - 'peer_address', 'peer_id', 'psk', 'mtu', - 'local_ep_group_id', 'peer_ep_group_id', - 'initiator', 'description', - 'vpnservice_id', 'ikepolicy_id', - 'ipsecpolicy_id'] - - position_values = [name, tenant_id, admin_state, peer_address, - peer_id, psk, mtu, local_ep_group, - peer_ep_group, initiator, description, - vpnservice_id, ikepolicy_id, ipsecpolicy_id] - extra_body = { - 'dpd': { - 'action': 'restart', - 'interval': 30, - 'timeout': 120, - }, - } - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - - def test_create_ipsec_site_connection_with_limited_params(self): - # ipsecsite-connection-create with limited params. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.CreateIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - tenant_id = 'mytenant_id' - my_id = 'my_id' - peer_address = '192.168.2.10' - peer_id = '192.168.2.10' - psk = 'abcd' - mtu = '1500' - initiator = 'bi-directional' - vpnservice_id = 'vpnservice_id' - ikepolicy_id = 'ikepolicy_id' - ipsecpolicy_id = 'ipsecpolicy_id' - local_ep_group = 'local-epg' - peer_ep_group = 'peer-epg' - admin_state = True - - args = ['--tenant-id', tenant_id, - '--peer-address', peer_address, - '--peer-id', peer_id, - '--psk', psk, - '--vpnservice-id', vpnservice_id, - '--ikepolicy-id', ikepolicy_id, - '--ipsecpolicy-id', ipsecpolicy_id, - '--local-ep-group', local_ep_group, - '--peer-ep-group', peer_ep_group] - - position_names = ['tenant_id', 'admin_state_up', - 'peer_address', 'peer_id', - 'local_ep_group_id', 'peer_ep_group_id', - 'psk', 'mtu', 'initiator', - 'vpnservice_id', 'ikepolicy_id', - 'ipsecpolicy_id'] - - position_values = [tenant_id, admin_state, peer_address, peer_id, - local_ep_group, peer_ep_group, psk, mtu, initiator, - vpnservice_id, ikepolicy_id, ipsecpolicy_id] - - self._test_create_resource(resource, cmd, None, my_id, args, - position_names, position_values) - - def _test_create_failure(self, additional_args=None, expected_exc=None): - # Helper to test failure of IPSec site-to-site creation failure. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.CreateIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - tenant_id = 'mytenant_id' - my_id = 'my_id' - peer_address = '192.168.2.10' - peer_id = '192.168.2.10' - psk = 'abcd' - mtu = '1500' - initiator = 'bi-directional' - vpnservice_id = 'vpnservice_id' - ikepolicy_id = 'ikepolicy_id' - ipsecpolicy_id = 'ipsecpolicy_id' - admin_state = True - - args = ['--tenant-id', tenant_id, - '--peer-address', peer_address, - '--peer-id', peer_id, - '--psk', psk, - '--vpnservice-id', vpnservice_id, - '--ikepolicy-id', ikepolicy_id, - '--ipsecpolicy-id', ipsecpolicy_id] - if additional_args is not None: - args += additional_args - position_names = ['tenant_id', 'admin_state_up', 'peer_address', - 'peer_id', 'psk', 'mtu', 'initiator', - 'local_ep_group_id', 'peer_ep_group_id', - 'vpnservice_id', 'ikepolicy_id', 'ipsecpolicy_id'] - - position_values = [tenant_id, admin_state, peer_address, peer_id, psk, - mtu, initiator, None, None, vpnservice_id, - ikepolicy_id, ipsecpolicy_id] - if not expected_exc: - expected_exc = exceptions.CommandError - self.assertRaises(expected_exc, - self._test_create_resource, - resource, cmd, None, my_id, args, - position_names, position_values) - - def test_fail_create_with_invalid_mtu(self): - # ipsecsite-connection-create with invalid dpd values. - bad_mtu = ['--mtu', '67'] - self._test_create_failure(bad_mtu) - - def test_fail_create_with_invalid_dpd_keys(self): - bad_dpd_key = ['--dpd', 'act=restart,interval=30,time=120'] - self._test_create_failure(bad_dpd_key, SystemExit) - - def test_fail_create_with_invalid_dpd_values(self): - bad_dpd_values = ['--dpd', 'action=hold,interval=30,timeout=-1'] - self._test_create_failure(bad_dpd_values) - - def test_fail_create_missing_endpoint_groups_or_cidr(self): - # Must provide either endpoint groups or peer cidrs. - self._test_create_failure() - - def test_fail_create_missing_peer_endpoint_group(self): - # Fails if dont have both endpoint groups - missing peer. - self._test_create_failure(['--local-ep-group', 'local-epg']) - - def test_fail_create_missing_local_endpoint_group(self): - # Fails if dont have both endpoint groups - missing local. - self._test_create_failure(['--peer-ep-group', 'peer-epg']) - - def test_fail_create_when_both_endpoints_and_peer_cidr(self): - # Cannot intermix endpoint groups and peer CIDRs for create. - additional_args = ['--local-ep-group', 'local-epg', - '--peer-ep-group', 'peer-epg', - '--peer-cidr', '10.2.0.0/24'] - self._test_create_failure(additional_args) - - def test_list_ipsec_site_connection(self): - # ipsecsite-connection-list. - resources = "ipsec_site_connections" - cmd = ipsec_site_connection.ListIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - self._test_list_resources(resources, cmd, True) - - def test_list_ipsec_site_connection_pagination(self): - # ipsecsite-connection-list. - resources = "ipsec_site_connections" - cmd = ipsec_site_connection.ListIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - self._test_list_resources_with_pagination(resources, cmd) - - def test_list_ipsec_site_connection_sort(self): - # ipsecsite-connection-list. - # --sort-key name --sort-key id --sort-key asc --sort-key desc - resources = "ipsec_site_connections" - cmd = ipsec_site_connection.ListIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - self._test_list_resources(resources, cmd, - sort_key=["name", "id"], - sort_dir=["asc", "desc"]) - - def test_list_ipsec_site_connection_limit(self): - # ipsecsite-connection-list -P. - resources = "ipsec_site_connections" - cmd = ipsec_site_connection.ListIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - self._test_list_resources(resources, cmd, page_size=1000) - - def test_delete_ipsec_site_connection(self): - # ipsecsite-connection-delete my-id. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.DeleteIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - my_id = 'my-id' - args = [my_id] - self._test_delete_resource(resource, cmd, my_id, args) - - def test_update_ipsec_site_connection(self): - # ipsecsite-connection-update myid --name Branch-new --tags a b. - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.UpdateIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--name', 'Branch-new', - '--tags', 'a', 'b'], - {'name': 'Branch-new', - 'tags': ['a', 'b'], }) - # ipsecsite-connection-update myid --mtu 69 --initiator response-only - # --peer-id '192.168.2.11' --peer-ep-group 'update-grp' - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--mtu', '69', - '--initiator', 'response-only', - '--peer-id', '192.168.2.11', - '--peer-ep-group', 'update-grp'], - {'mtu': '69', - 'initiator': 'response-only', - 'peer_id': '192.168.2.11', - 'peer_ep_group_id': 'update-grp', },) - - def test_show_ipsec_site_connection_id(self): - # ipsecsite-connection-show test_id.""" - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.ShowIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - args = ['--fields', 'id', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, args, ['id']) - - def test_show_ipsec_site_connection_id_name(self): - # ipsecsite-connection-show.""" - resource = 'ipsec_site_connection' - cmd = ipsec_site_connection.ShowIPsecSiteConnection( - test_cli20.MyApp(sys.stdout), None - ) - args = ['--fields', 'id', '--fields', 'name', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, - args, ['id', 'name']) diff --git a/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py b/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py deleted file mode 100644 index 8c7df4a..0000000 --- a/neutronclient/tests/unit/vpn/test_cli20_ipsecpolicy.py +++ /dev/null @@ -1,249 +0,0 @@ -# (c) Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import sys - -from neutronclient.common import exceptions -from neutronclient.neutron.v2_0.vpn import ipsecpolicy -from neutronclient.tests.unit import test_cli20 - - -class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base): - - non_admin_status_resources = ['ipsecpolicy'] - - def _test_create_ipsecpolicy_all_params(self, auth='sha1', - expected_exc=None): - # vpn-ipsecpolicy-create all params with dashes. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.CreateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ipsecpolicy1' - description = 'first-ipsecpolicy1' - auth_algorithm = auth - encryption_algorithm = 'aes-256' - encapsulation_mode = 'tunnel' - pfs = 'group5' - transform_protocol = 'ah' - tenant_id = 'my-tenant' - my_id = 'my-id' - lifetime = 'units=seconds,value=20000' - - args = [name, - '--description', description, - '--tenant-id', tenant_id, - '--auth-algorithm', auth_algorithm, - '--encryption-algorithm', encryption_algorithm, - '--transform-protocol', transform_protocol, - '--encapsulation-mode', encapsulation_mode, - '--lifetime', lifetime, - '--pfs', pfs] - - position_names = ['name', 'auth_algorithm', 'encryption_algorithm', - 'encapsulation_mode', 'description', - 'transform_protocol', 'pfs', - 'tenant_id'] - - position_values = [name, auth_algorithm, encryption_algorithm, - encapsulation_mode, description, - transform_protocol, pfs, - tenant_id] - extra_body = { - 'lifetime': { - 'units': 'seconds', - 'value': 20000, - }, - } - - if not expected_exc: - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - else: - self.assertRaises( - expected_exc, - self._test_create_resource, - resource, cmd, name, my_id, args, - position_names, position_values, - extra_body=extra_body) - - def test_create_ipsecpolicy_all_params(self): - self._test_create_ipsecpolicy_all_params() - - def test_create_ipsecpolicy_auth_sha256(self): - self._test_create_ipsecpolicy_all_params(auth='sha256') - - def test_create_ipsecpolicy_auth_sha384(self): - self._test_create_ipsecpolicy_all_params(auth='sha384') - - def test_create_ipsecpolicy_auth_sha512(self): - self._test_create_ipsecpolicy_all_params(auth='sha512') - - def test_create_ipsecpolicy_invalid_auth(self): - self._test_create_ipsecpolicy_all_params(auth='invalid', - expected_exc=SystemExit) - - def test_create_ipsecpolicy_with_limited_params(self): - # vpn-ipsecpolicy-create with limited params. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.CreateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ipsecpolicy1' - auth_algorithm = 'sha1' - encryption_algorithm = 'aes-128' - encapsulation_mode = 'tunnel' - pfs = 'group5' - transform_protocol = 'esp' - tenant_id = 'my-tenant' - my_id = 'my-id' - - args = [name, - '--tenant-id', tenant_id] - - position_names = ['name', 'auth_algorithm', 'encryption_algorithm', - 'encapsulation_mode', - 'transform_protocol', 'pfs', - 'tenant_id'] - - position_values = [name, auth_algorithm, encryption_algorithm, - encapsulation_mode, - transform_protocol, pfs, - tenant_id] - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values) - - def _test_lifetime_values(self, lifetime, expected_exc=None): - resource = 'ipsecpolicy' - cmd = ipsecpolicy.CreateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - name = 'ipsecpolicy1' - description = 'my-ipsec-policy' - auth_algorithm = 'sha1' - encryption_algorithm = 'aes-256' - ike_version = 'v1' - phase1_negotiation_mode = 'main' - pfs = 'group5' - tenant_id = 'my-tenant' - my_id = 'my-id' - - args = [name, - '--description', description, - '--tenant-id', tenant_id, - '--auth-algorithm', auth_algorithm, - '--encryption-algorithm', encryption_algorithm, - '--ike-version', ike_version, - '--phase1-negotiation-mode', phase1_negotiation_mode, - '--lifetime', lifetime, - '--pfs', pfs] - - position_names = ['name', 'description', - 'auth_algorithm', 'encryption_algorithm', - 'phase1_negotiation_mode', - 'ike_version', 'pfs', - 'tenant_id'] - - position_values = [name, description, - auth_algorithm, encryption_algorithm, - phase1_negotiation_mode, ike_version, pfs, - tenant_id] - if not expected_exc: - expected_exc = exceptions.CommandError - self.assertRaises( - expected_exc, - self._test_create_resource, - resource, cmd, name, my_id, args, - position_names, position_values) - - def test_create_ipsecpolicy_with_invalid_lifetime_keys(self): - lifetime = 'uts=seconds,val=20000' - self._test_lifetime_values(lifetime, SystemExit) - - def test_create_ipsecpolicy_with_invalid_lifetime_units(self): - lifetime = 'units=minutes,value=600' - self._test_lifetime_values(lifetime) - - def test_create_ipsecpolicy_with_invalid_lifetime_value(self): - lifetime = 'units=seconds,value=0' - self._test_lifetime_values(lifetime) - - def test_list_ipsecpolicy(self): - # vpn-ipsecpolicy-list. - resources = "ipsecpolicies" - cmd = ipsecpolicy.ListIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, True) - - def test_list_ipsecpolicy_pagination(self): - # vpn-ipsecpolicy-list. - resources = "ipsecpolicies" - cmd = ipsecpolicy.ListIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources_with_pagination(resources, cmd) - - def test_list_ipsecpolicy_sort(self): - # vpn-ipsecpolicy-list --sort-key name --sort-key id --sort-key asc - # --sort-key desc - resources = "ipsecpolicies" - cmd = ipsecpolicy.ListIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, - sort_key=["name", "id"], - sort_dir=["asc", "desc"]) - - def test_list_ipsecpolicy_limit(self): - # vpn-ipsecpolicy-list -P. - resources = "ipsecpolicies" - cmd = ipsecpolicy.ListIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, page_size=1000) - - def test_show_ipsecpolicy_id(self): - # vpn-ipsecpolicy-show ipsecpolicy_id. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.ShowIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, args, ['id']) - - def test_show_ipsecpolicy_id_name(self): - # vpn-ipsecpolicy-show. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.ShowIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', '--fields', 'name', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, - args, ['id', 'name']) - - def test_update_ipsecpolicy_name(self): - # vpn-ipsecpolicy-update myid --name newname --tags a b. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.UpdateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--name', 'newname'], - {'name': 'newname', }) - - def test_update_ipsecpolicy_other_params(self): - # vpn-ipsecpolicy-update myid --transform-protocol esp - # --pfs group14 --encapsulation-mode transport - resource = 'ipsecpolicy' - cmd = ipsecpolicy.UpdateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--transform-protocol', 'esp', - '--pfs', 'group14', - '--encapsulation-mode', 'transport'], - {'transform_protocol': 'esp', - 'pfs': 'group14', - 'encapsulation_mode': 'transport', }) - - def test_delete_ipsecpolicy(self): - # vpn-ipsecpolicy-delete my-id. - resource = 'ipsecpolicy' - cmd = ipsecpolicy.DeleteIPsecPolicy(test_cli20.MyApp(sys.stdout), None) - my_id = 'my-id' - args = [my_id] - self._test_delete_resource(resource, cmd, my_id, args) diff --git a/neutronclient/tests/unit/vpn/test_cli20_vpnservice.py b/neutronclient/tests/unit/vpn/test_cli20_vpnservice.py deleted file mode 100644 index 3c4def8..0000000 --- a/neutronclient/tests/unit/vpn/test_cli20_vpnservice.py +++ /dev/null @@ -1,157 +0,0 @@ -# (c) Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import sys - -from neutronclient.neutron.v2_0.vpn import vpnservice -from neutronclient.tests.unit import test_cli20 - - -class CLITestV20VpnServiceJSON(test_cli20.CLITestV20Base): - - def test_create_vpnservice_all_params(self): - # vpn-service-create all params. - resource = 'vpnservice' - cmd = vpnservice.CreateVPNService(test_cli20.MyApp(sys.stdout), None) - subnet = 'mysubnet-id' - router = 'myrouter-id' - tenant_id = 'mytenant-id' - my_id = 'my-id' - name = 'myvpnservice' - description = 'my-vpn-service' - admin_state = True - - args = ['--name', name, - '--description', description, - router, - subnet, - '--tenant-id', tenant_id] - - position_names = ['admin_state_up', 'name', 'description', - 'subnet_id', 'router_id', - 'tenant_id'] - - position_values = [admin_state, name, description, - subnet, router, tenant_id] - - self._test_create_resource(resource, cmd, name, my_id, args, - position_names, position_values) - - def test_create_vpnservice_with_limited_params(self): - # vpn-service-create with limited params. - resource = 'vpnservice' - cmd = vpnservice.CreateVPNService(test_cli20.MyApp(sys.stdout), None) - subnet = 'mysubnet-id' - router = 'myrouter-id' - tenant_id = 'mytenant-id' - my_id = 'my-id' - admin_state = True - - args = [router, - subnet, - '--tenant-id', tenant_id] - - position_names = ['admin_state_up', - 'subnet_id', 'router_id', - 'tenant_id'] - - position_values = [admin_state, subnet, router, tenant_id] - - self._test_create_resource(resource, cmd, None, my_id, args, - position_names, position_values) - - def test_create_vpnservice_without_subnet(self): - # vpn-service-create with no subnet provided. - resource = 'vpnservice' - cmd = vpnservice.CreateVPNService(test_cli20.MyApp(sys.stdout), None) - router = 'myrouter-id' - tenant_id = 'mytenant-id' - my_id = 'my-id' - admin_state = True - - args = [router, - '--tenant-id', tenant_id] - - position_names = ['admin_state_up', - 'subnet_id', 'router_id', - 'tenant_id'] - - position_values = [admin_state, None, router, tenant_id] - - self._test_create_resource(resource, cmd, None, my_id, args, - position_names, position_values) - - def test_list_vpnservice(self): - # vpn-service-list. - resources = "vpnservices" - cmd = vpnservice.ListVPNService(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, True) - - def test_list_vpnservice_pagination(self): - # vpn-service-list. - resources = "vpnservices" - cmd = vpnservice.ListVPNService(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources_with_pagination(resources, cmd) - - def test_list_vpnservice_sort(self): - # vpn-service-list --sort-key name --sort-key id --sort-key asc - # --sort-key desc - resources = "vpnservices" - cmd = vpnservice.ListVPNService(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, - sort_key=["name", "id"], - sort_dir=["asc", "desc"]) - - def test_list_vpnservice_limit(self): - # vpn-service-list -P. - resources = "vpnservices" - cmd = vpnservice.ListVPNService(test_cli20.MyApp(sys.stdout), None) - self._test_list_resources(resources, cmd, page_size=1000) - - def test_show_vpnservice_id(self): - # vpn-service-show test_id. - resource = 'vpnservice' - cmd = vpnservice.ShowVPNService(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, args, ['id']) - - def test_show_vpnservice_id_name(self): - # vpn-service-show.""" - resource = 'vpnservice' - cmd = vpnservice.ShowVPNService(test_cli20.MyApp(sys.stdout), None) - args = ['--fields', 'id', '--fields', 'name', self.test_id] - self._test_show_resource(resource, cmd, self.test_id, - args, ['id', 'name']) - - def test_update_vpnservice(self): - # vpn-service-update myid --name newname --tags a b. - resource = 'vpnservice' - cmd = vpnservice.UpdateVPNService(test_cli20.MyApp(sys.stdout), None) - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--name', 'newname'], - {'name': 'newname', }) - # vpn-service-update myid --admin-state-up False - self._test_update_resource(resource, cmd, 'myid', - ['myid', '--admin-state-up', 'False'], - {'admin_state_up': 'False', }) - - def test_delete_vpnservice(self): - # vpn-service-delete my-id. - resource = 'vpnservice' - cmd = vpnservice.DeleteVPNService(test_cli20.MyApp(sys.stdout), None) - my_id = 'my-id' - args = [my_id] - self._test_delete_resource(resource, cmd, my_id, args) diff --git a/neutronclient/tests/unit/vpn/test_utils.py b/neutronclient/tests/unit/vpn/test_utils.py deleted file mode 100644 index c39f7ce..0000000 --- a/neutronclient/tests/unit/vpn/test_utils.py +++ /dev/null @@ -1,130 +0,0 @@ -# (c) Copyright 2013 Hewlett-Packard Development Company, L.P. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# - -import testtools - -from neutronclient.common import exceptions -from neutronclient.common import utils -from neutronclient.neutron.v2_0.vpn import utils as vpn_utils - - -class TestVPNUtils(testtools.TestCase): - - def test_validate_lifetime_dictionary_seconds(self): - input_str = utils.str2dict("units=seconds,value=3600") - self.assertIsNone(vpn_utils.validate_lifetime_dict(input_str)) - - def test_validate_dpd_dictionary_action_hold(self): - input_str = utils.str2dict("action=hold,interval=30,timeout=120") - self.assertIsNone(vpn_utils.validate_dpd_dict(input_str)) - - def test_validate_dpd_dictionary_action_restart(self): - input_str = utils.str2dict("action=restart,interval=30,timeout=120") - self.assertIsNone(vpn_utils.validate_dpd_dict(input_str)) - - def test_validate_dpd_dictionary_action_restart_by_peer(self): - input_str = utils.str2dict( - "action=restart-by-peer,interval=30,timeout=120" - ) - self.assertIsNone(vpn_utils.validate_dpd_dict(input_str)) - - def test_validate_dpd_dictionary_action_clear(self): - input_str = utils.str2dict('action=clear,interval=30,timeout=120') - self.assertIsNone(vpn_utils.validate_dpd_dict(input_str)) - - def test_validate_dpd_dictionary_action_disabled(self): - input_str = utils.str2dict('action=disabled,interval=30,timeout=120') - self.assertIsNone(vpn_utils.validate_dpd_dict(input_str)) - - def test_validate_lifetime_dictionary_invalid_unit_key(self): - input_str = utils.str2dict('ut=seconds,value=3600') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_invalid_unit_key_value(self): - input_str = utils.str2dict('units=seconds,val=3600') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_unsupported_units(self): - input_str = utils.str2dict('units=minutes,value=3600') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_invalid_empty_unit(self): - input_str = utils.str2dict('units=,value=3600') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_under_minimum_integer_value(self): - input_str = utils.str2dict('units=seconds,value=59') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_negative_integer_value(self): - input_str = utils.str2dict('units=seconds,value=-1') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_lifetime_dictionary_empty_value(self): - input_str = utils.str2dict('units=seconds,value=') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_dpd_dictionary_invalid_key_action(self): - input_str = utils.str2dict('act=hold,interval=30,timeout=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_invalid_key_interval(self): - input_str = utils.str2dict('action=hold,int=30,timeout=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_invalid_key_timeout(self): - input_str = utils.str2dict('action=hold,interval=30,tiut=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_unsupported_action(self): - input_str = utils.str2dict('action=bye-bye,interval=30,timeout=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_empty_action(self): - input_str = utils.str2dict('action=,interval=30,timeout=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_empty_interval(self): - input_str = utils.str2dict('action=hold,interval=,timeout=120') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_negative_interval_value(self): - input_str = utils.str2dict('action=hold,interval=-1,timeout=120') - self._test_validate_lifetime_negative_test_case(input_str) - - def test_validate_dpd_dictionary_zero_timeout(self): - input_str = utils.str2dict('action=hold,interval=30,timeout=0') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_empty_timeout(self): - input_str = utils.str2dict('action=hold,interval=30,timeout=') - self._test_validate_dpd_negative_test_case(input_str) - - def test_validate_dpd_dictionary_negative_timeout_value(self): - input_str = utils.str2dict('action=hold,interval=30,timeout=-1') - self._test_validate_lifetime_negative_test_case(input_str) - - def _test_validate_lifetime_negative_test_case(self, input_str): - """Generic handler for negative lifetime tests.""" - self.assertRaises(exceptions.CommandError, - vpn_utils.validate_lifetime_dict, - (input_str)) - - def _test_validate_dpd_negative_test_case(self, input_str): - """Generic handler for negative lifetime tests.""" - self.assertRaises(exceptions.CommandError, - vpn_utils.validate_lifetime_dict, - (input_str)) |