diff options
Diffstat (limited to 'nova/tests/integrated/v3')
10 files changed, 179 insertions, 5 deletions
diff --git a/nova/tests/integrated/v3/api_samples/os-cloudpipe/cloud-pipe-update-req.json.tpl b/nova/tests/integrated/v3/api_samples/os-cloudpipe/cloud-pipe-update-req.json.tpl new file mode 100644 index 0000000000..0ab9141aea --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-cloudpipe/cloud-pipe-update-req.json.tpl @@ -0,0 +1,6 @@ +{ + "configure_project": { + "vpn_ip": "%(vpn_ip)s", + "vpn_port": "%(vpn_port)s" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-add-post-req.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-add-post-req.json.tpl new file mode 100644 index 0000000000..19a6ed2cb8 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-add-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "addSecurityGroup": { + "name": "%(group_name)s" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-post-req.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-post-req.json.tpl new file mode 100644 index 0000000000..3f54ab6856 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-post-req.json.tpl @@ -0,0 +1,6 @@ +{ + "security_group": { + "name": "%(group_name)s", + "description": "description" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-remove-post-req.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-remove-post-req.json.tpl new file mode 100644 index 0000000000..7f550036b8 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-group-remove-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "removeSecurityGroup": { + "name": "%(group_name)s" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-create-resp.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-create-resp.json.tpl new file mode 100644 index 0000000000..e51714e3ee --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-create-resp.json.tpl @@ -0,0 +1,9 @@ +{ + "security_group": { + "description": "%(description)s", + "id": 1, + "name": "%(group_name)s", + "rules": [], + "tenant_id": "openstack" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-get-resp.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-get-resp.json.tpl new file mode 100644 index 0000000000..0372512744 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-get-resp.json.tpl @@ -0,0 +1,9 @@ +{ + "security_group": { + "description": "default", + "id": 1, + "name": "default", + "rules": [], + "tenant_id": "openstack" + } +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-list-get-resp.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-list-get-resp.json.tpl new file mode 100644 index 0000000000..1771f2dff1 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/security-groups-list-get-resp.json.tpl @@ -0,0 +1,11 @@ +{ + "security_groups": [ + { + "description": "default", + "id": 1, + "name": "default", + "rules": [], + "tenant_id": "openstack" + } + ] +} diff --git a/nova/tests/integrated/v3/api_samples/os-security-groups/server-security-groups-list-resp.json.tpl b/nova/tests/integrated/v3/api_samples/os-security-groups/server-security-groups-list-resp.json.tpl new file mode 100644 index 0000000000..1771f2dff1 --- /dev/null +++ b/nova/tests/integrated/v3/api_samples/os-security-groups/server-security-groups-list-resp.json.tpl @@ -0,0 +1,11 @@ +{ + "security_groups": [ + { + "description": "default", + "id": 1, + "name": "default", + "rules": [], + "tenant_id": "openstack" + } + ] +} diff --git a/nova/tests/integrated/v3/test_cloudpipe.py b/nova/tests/integrated/v3/test_cloudpipe.py index 435f875795..a3042eb736 100644 --- a/nova/tests/integrated/v3/test_cloudpipe.py +++ b/nova/tests/integrated/v3/test_cloudpipe.py @@ -69,3 +69,12 @@ class CloudPipeSampleTest(api_sample_base.ApiSampleTestBaseV3): subs.update(project) subs['image_id'] = CONF.vpn_image_id self._verify_response('cloud-pipe-get-resp', subs, response, 200) + + def test_cloud_pipe_update(self): + subs = {'vpn_ip': '192.168.1.1', + 'vpn_port': 2000} + response = self._do_put('os-cloudpipe/configure-project', + 'cloud-pipe-update-req', + subs) + self.assertEqual(response.status_code, 202) + self.assertEqual(response.content, "") diff --git a/nova/tests/integrated/v3/test_security_groups.py b/nova/tests/integrated/v3/test_security_groups.py index c1f27d5a46..2859bf1f12 100644 --- a/nova/tests/integrated/v3/test_security_groups.py +++ b/nova/tests/integrated/v3/test_security_groups.py @@ -19,21 +19,44 @@ from nova.tests.integrated.v3 import test_servers def fake_get(*args, **kwargs): nova_group = {} - nova_group['id'] = 'fake' - nova_group['description'] = '' - nova_group['name'] = 'test' - nova_group['project_id'] = 'fake' + nova_group['id'] = 1 + nova_group['description'] = 'default' + nova_group['name'] = 'default' + nova_group['project_id'] = 'openstack' nova_group['rules'] = [] return nova_group -def fake_get_instances_security_groups_bindings(self, context, servers): +def fake_get_instances_security_groups_bindings(self, context, servers, + detailed=False): result = {} for s in servers: result[s.get('id')] = [{'name': 'test'}] return result +def fake_add_to_instance(self, context, instance, security_group_name): + pass + + +def fake_remove_from_instance(self, context, instance, security_group_name): + pass + + +def fake_list(self, context, names=None, ids=None, project=None, + search_opts=None): + return [fake_get()] + + +def fake_get_instance_security_groups(self, context, instance_uuid, + detailed=False): + return [fake_get()] + + +def fake_create_security_group(self, context, name, description): + return fake_get() + + class SecurityGroupsJsonTest(test_servers.ServersSampleBase): extension_name = 'os-security-groups' @@ -44,6 +67,21 @@ class SecurityGroupsJsonTest(test_servers.ServersSampleBase): self.stubs.Set(neutron_driver.SecurityGroupAPI, 'get_instances_security_groups_bindings', fake_get_instances_security_groups_bindings) + self.stubs.Set(neutron_driver.SecurityGroupAPI, + 'add_to_instance', + fake_add_to_instance) + self.stubs.Set(neutron_driver.SecurityGroupAPI, + 'remove_from_instance', + fake_remove_from_instance) + self.stubs.Set(neutron_driver.SecurityGroupAPI, + 'list', + fake_list) + self.stubs.Set(neutron_driver.SecurityGroupAPI, + 'get_instance_security_groups', + fake_get_instance_security_groups) + self.stubs.Set(neutron_driver.SecurityGroupAPI, + 'create_security_group', + fake_create_security_group) def test_server_create(self): self._post_server() @@ -61,3 +99,68 @@ class SecurityGroupsJsonTest(test_servers.ServersSampleBase): subs = self._get_regexes() subs['hostid'] = '[a-f0-9]+' self._verify_response('servers-detail-resp', subs, response, 200) + + def _get_create_subs(self): + return { + 'group_name': 'default', + "description": "default", + } + + def _create_security_group(self): + subs = self._get_create_subs() + return self._do_post('os-security-groups', + 'security-group-post-req', subs) + + def _add_group(self, uuid): + subs = { + 'group_name': 'test' + } + return self._do_post('servers/%s/action' % uuid, + 'security-group-add-post-req', subs) + + def test_security_group_create(self): + response = self._create_security_group() + subs = self._get_create_subs() + self._verify_response('security-groups-create-resp', subs, + response, 200) + + def test_security_groups_list(self): + # Get api sample of security groups get list request. + response = self._do_get('os-security-groups') + subs = self._get_regexes() + self._verify_response('security-groups-list-get-resp', + subs, response, 200) + + def test_security_groups_get(self): + # Get api sample of security groups get request. + security_group_id = '11111111-1111-1111-1111-111111111111' + response = self._do_get('os-security-groups/%s' % security_group_id) + subs = self._get_regexes() + self._verify_response('security-groups-get-resp', subs, response, 200) + + def test_security_groups_list_server(self): + # Get api sample of security groups for a specific server. + uuid = self._post_server() + response = self._do_get('servers/%s/os-security-groups' % uuid) + subs = self._get_regexes() + self._verify_response('server-security-groups-list-resp', + subs, response, 200) + + def test_security_groups_add(self): + self._create_security_group() + uuid = self._post_server() + response = self._add_group(uuid) + self.assertEqual(response.status_code, 202) + self.assertEqual(response.content, '') + + def test_security_groups_remove(self): + self._create_security_group() + uuid = self._post_server() + self._add_group(uuid) + subs = { + 'group_name': 'test' + } + response = self._do_post('servers/%s/action' % uuid, + 'security-group-remove-post-req', subs) + self.assertEqual(response.status_code, 202) + self.assertEqual(response.content, '') |