summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/identity/v2
diff options
context:
space:
mode:
authorSteve Martinelli <s.martinelli@gmail.com>2016-09-05 20:35:06 -0700
committerSteve Martinelli <s.martinelli@gmail.com>2016-09-09 03:29:47 +0000
commitc14d3efe6162a58cb3cdcb2834ad2508e2525018 (patch)
tree084f7a998a410957299db58a2449dbfb1dce20a9 /openstackclient/tests/functional/identity/v2
parent39839def2e356e8d145be89380c73a71423cf06d (diff)
downloadpython-openstackclient-c14d3efe6162a58cb3cdcb2834ad2508e2525018.tar.gz
move all functional tests to tests module
functional tests should be grouped with other tests (unit and integration tests). as part of this commit the "common" module was renamed to just "base", this was done for simplicity. the post_test_hook.sh file was also copied to the functional module since it should live there. a separate change to the infra repo will be made to call the new location, once that is merged we can remove the old one (a new change will also be posted for that) Needed-By: I49d54f009021d65c1ae49faf6b3f0a7acdadd7b3 Change-Id: Ie8c334f6223373b8e06df8bd8466500d2a2c8ede
Diffstat (limited to 'openstackclient/tests/functional/identity/v2')
-rw-r--r--openstackclient/tests/functional/identity/v2/__init__.py0
-rw-r--r--openstackclient/tests/functional/identity/v2/common.py181
-rw-r--r--openstackclient/tests/functional/identity/v2/test_catalog.py42
-rw-r--r--openstackclient/tests/functional/identity/v2/test_ec2_credentials.py48
-rw-r--r--openstackclient/tests/functional/identity/v2/test_endpoint.py45
-rw-r--r--openstackclient/tests/functional/identity/v2/test_project.py86
-rw-r--r--openstackclient/tests/functional/identity/v2/test_role.py110
-rw-r--r--openstackclient/tests/functional/identity/v2/test_service.py44
-rw-r--r--openstackclient/tests/functional/identity/v2/test_token.py24
-rw-r--r--openstackclient/tests/functional/identity/v2/test_user.py60
10 files changed, 640 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/identity/v2/__init__.py b/openstackclient/tests/functional/identity/v2/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/__init__.py
diff --git a/openstackclient/tests/functional/identity/v2/common.py b/openstackclient/tests/functional/identity/v2/common.py
new file mode 100644
index 00000000..b390c5bc
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/common.py
@@ -0,0 +1,181 @@
+# 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 os
+
+from tempest.lib.common.utils import data_utils
+
+from openstackclient.tests.functional import base
+
+BASIC_LIST_HEADERS = ['ID', 'Name']
+
+
+class IdentityTests(base.TestCase):
+ """Functional tests for Identity commands. """
+
+ USER_FIELDS = ['email', 'enabled', 'id', 'name', 'project_id',
+ 'username', 'domain_id', 'default_project_id']
+ PROJECT_FIELDS = ['enabled', 'id', 'name', 'description', 'domain_id']
+ TOKEN_FIELDS = ['expires', 'id', 'project_id', 'user_id']
+ ROLE_FIELDS = ['id', 'name', 'links', 'domain_id']
+ SERVICE_FIELDS = ['id', 'enabled', 'name', 'type', 'description']
+ ENDPOINT_FIELDS = ['id', 'region', 'service_id', 'service_name',
+ 'service_type', 'enabled', 'publicurl',
+ 'adminurl', 'internalurl']
+
+ EC2_CREDENTIALS_FIELDS = ['access', 'project_id', 'secret',
+ 'trust_id', 'user_id']
+ EC2_CREDENTIALS_LIST_HEADERS = ['Access', 'Secret',
+ 'Project ID', 'User ID']
+ CATALOG_LIST_HEADERS = ['Name', 'Type', 'Endpoints']
+ ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type']
+
+ @classmethod
+ def setUpClass(cls):
+ # prepare v2 env
+ os.environ['OS_IDENTITY_API_VERSION'] = '2.0'
+ auth_url = os.environ.get('OS_AUTH_URL')
+ auth_url = auth_url.replace('v3', 'v2.0')
+ os.environ['OS_AUTH_URL'] = auth_url
+
+ # create dummy project
+ cls.project_name = data_utils.rand_name('TestProject')
+ cls.project_description = data_utils.rand_name('description')
+ cls.openstack(
+ 'project create '
+ '--description %(description)s '
+ '--enable '
+ '%(name)s' % {'description': cls.project_description,
+ 'name': cls.project_name})
+
+ @classmethod
+ def tearDownClass(cls):
+ cls.openstack('project delete %s' % cls.project_name)
+
+ def _create_dummy_project(self, add_clean_up=True):
+ project_name = data_utils.rand_name('TestProject')
+ project_description = data_utils.rand_name('description')
+ raw_output = self.openstack(
+ 'project create '
+ '--description %(description)s '
+ '--enable %(name)s' % {'description': project_description,
+ 'name': project_name})
+ project = self.parse_show_as_object(raw_output)
+ if add_clean_up:
+ self.addCleanup(
+ self.openstack,
+ 'project delete %s' % project['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.PROJECT_FIELDS)
+ return project_name
+
+ def _create_dummy_user(self, add_clean_up=True):
+ username = data_utils.rand_name('TestUser')
+ password = data_utils.rand_name('password')
+ email = data_utils.rand_name() + '@example.com'
+ raw_output = self.openstack(
+ 'user create '
+ '--project %(project)s '
+ '--password %(password)s '
+ '--email %(email)s '
+ '--enable '
+ '%(name)s' % {'project': self.project_name,
+ 'email': email,
+ 'password': password,
+ 'name': username})
+ if add_clean_up:
+ self.addCleanup(
+ self.openstack,
+ 'user delete %s' % self.parse_show_as_object(raw_output)['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.USER_FIELDS)
+ return username
+
+ def _create_dummy_role(self, add_clean_up=True):
+ role_name = data_utils.rand_name('TestRole')
+ raw_output = self.openstack('role create %s' % role_name)
+ role = self.parse_show_as_object(raw_output)
+ if add_clean_up:
+ self.addCleanup(
+ self.openstack,
+ 'role delete %s' % role['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ROLE_FIELDS)
+ self.assertEqual(role_name, role['name'])
+ return role_name
+
+ def _create_dummy_ec2_credentials(self, add_clean_up=True):
+ raw_output = self.openstack('ec2 credentials create')
+ ec2_credentials = self.parse_show_as_object(raw_output)
+ access_key = ec2_credentials['access']
+ if add_clean_up:
+ self.addCleanup(
+ self.openstack,
+ 'ec2 credentials delete %s' % access_key)
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
+ return access_key
+
+ def _create_dummy_token(self, add_clean_up=True):
+ raw_output = self.openstack('token issue')
+ token = self.parse_show_as_object(raw_output)
+ if add_clean_up:
+ self.addCleanup(self.openstack,
+ 'token revoke %s' % token['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.TOKEN_FIELDS)
+ return token['id']
+
+ def _create_dummy_service(self, add_clean_up=True):
+ service_name = data_utils.rand_name('TestService')
+ description = data_utils.rand_name('description')
+ type_name = data_utils.rand_name('TestType')
+ raw_output = self.openstack(
+ 'service create '
+ '--name %(name)s '
+ '--description %(description)s '
+ '%(type)s' % {'name': service_name,
+ 'description': description,
+ 'type': type_name})
+ if add_clean_up:
+ service = self.parse_show_as_object(raw_output)
+ self.addCleanup(self.openstack,
+ 'service delete %s' % service['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.SERVICE_FIELDS)
+ return service_name
+
+ def _create_dummy_endpoint(self, add_clean_up=True):
+ region_id = data_utils.rand_name('TestRegion')
+ service_name = self._create_dummy_service()
+ public_url = data_utils.rand_url()
+ admin_url = data_utils.rand_url()
+ internal_url = data_utils.rand_url()
+ raw_output = self.openstack(
+ 'endpoint create '
+ '--publicurl %(publicurl)s '
+ '--adminurl %(adminurl)s '
+ '--internalurl %(internalurl)s '
+ '--region %(region)s '
+ '%(service)s' % {'publicurl': public_url,
+ 'adminurl': admin_url,
+ 'internalurl': internal_url,
+ 'region': region_id,
+ 'service': service_name})
+ endpoint = self.parse_show_as_object(raw_output)
+ if add_clean_up:
+ self.addCleanup(
+ self.openstack,
+ 'endpoint delete %s' % endpoint['id'])
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ENDPOINT_FIELDS)
+ return endpoint['id']
diff --git a/openstackclient/tests/functional/identity/v2/test_catalog.py b/openstackclient/tests/functional/identity/v2/test_catalog.py
new file mode 100644
index 00000000..f403fbfc
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_catalog.py
@@ -0,0 +1,42 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class CatalogTests(common.IdentityTests):
+
+ def test_catalog_list(self):
+ raw_output = self.openstack('catalog list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, self.CATALOG_LIST_HEADERS)
+
+ def test_catalog_show(self):
+ """test catalog show command
+
+ The output example:
+ +-----------+-------------------------------------------+
+ | Field | Value |
+ +-----------+-------------------------------------------+
+ | endpoints | test1 |
+ | | publicURL: http://localhost:5000/v2.0 |
+ | | internalURL: http://localhost:5000/v2.0 |
+ | | adminURL: http://localhost:5000/v2.0 |
+ | | |
+ | name | keystone |
+ | type | identity |
+ +-----------+-------------------------------------------+
+ """
+ raw_output = self.openstack('catalog show %s' % 'identity')
+ items = self.parse_show(raw_output)
+ # items may have multiple endpoint urls with empty key
+ self.assert_show_fields(items, ['endpoints', 'name', 'type', ''])
diff --git a/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py b/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py
new file mode 100644
index 00000000..43dff91f
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_ec2_credentials.py
@@ -0,0 +1,48 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class EC2CredentialsTests(common.IdentityTests):
+
+ def test_ec2_credentials_create(self):
+ self._create_dummy_ec2_credentials()
+
+ def test_ec2_credentials_delete(self):
+ access_key = self._create_dummy_ec2_credentials(add_clean_up=False)
+ raw_output = self.openstack(
+ 'ec2 credentials delete %s' % access_key,
+ )
+ self.assertEqual(0, len(raw_output))
+
+ def test_ec2_credentials_multi_delete(self):
+ access_key_1 = self._create_dummy_ec2_credentials(add_clean_up=False)
+ access_key_2 = self._create_dummy_ec2_credentials(add_clean_up=False)
+ raw_output = self.openstack(
+ 'ec2 credentials delete ' + access_key_1 + ' ' + access_key_2
+ )
+ self.assertEqual(0, len(raw_output))
+
+ def test_ec2_credentials_list(self):
+ self._create_dummy_ec2_credentials()
+ raw_output = self.openstack('ec2 credentials list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, self.EC2_CREDENTIALS_LIST_HEADERS)
+
+ def test_ec2_credentials_show(self):
+ access_key = self._create_dummy_ec2_credentials()
+ show_output = self.openstack(
+ 'ec2 credentials show %s' % access_key,
+ )
+ items = self.parse_show(show_output)
+ self.assert_show_fields(items, self.EC2_CREDENTIALS_FIELDS)
diff --git a/openstackclient/tests/functional/identity/v2/test_endpoint.py b/openstackclient/tests/functional/identity/v2/test_endpoint.py
new file mode 100644
index 00000000..9df5ca8a
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_endpoint.py
@@ -0,0 +1,45 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class EndpointTests(common.IdentityTests):
+
+ def test_endpoint_create(self):
+ self._create_dummy_endpoint()
+
+ def test_endpoint_delete(self):
+ endpoint_id = self._create_dummy_endpoint(add_clean_up=False)
+ raw_output = self.openstack(
+ 'endpoint delete %s' % endpoint_id)
+ self.assertEqual(0, len(raw_output))
+
+ def test_endpoint_multi_delete(self):
+ endpoint_id_1 = self._create_dummy_endpoint(add_clean_up=False)
+ endpoint_id_2 = self._create_dummy_endpoint(add_clean_up=False)
+ raw_output = self.openstack(
+ 'endpoint delete ' + endpoint_id_1 + ' ' + endpoint_id_2)
+ self.assertEqual(0, len(raw_output))
+
+ def test_endpoint_list(self):
+ endpoint_id = self._create_dummy_endpoint()
+ raw_output = self.openstack('endpoint list')
+ self.assertIn(endpoint_id, raw_output)
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS)
+
+ def test_endpoint_show(self):
+ endpoint_id = self._create_dummy_endpoint()
+ raw_output = self.openstack('endpoint show %s' % endpoint_id)
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ENDPOINT_FIELDS)
diff --git a/openstackclient/tests/functional/identity/v2/test_project.py b/openstackclient/tests/functional/identity/v2/test_project.py
new file mode 100644
index 00000000..b6222a1b
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_project.py
@@ -0,0 +1,86 @@
+# 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.
+
+from tempest.lib.common.utils import data_utils
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class ProjectTests(common.IdentityTests):
+
+ def test_project_create(self):
+ project_name = data_utils.rand_name('TestProject')
+ description = data_utils.rand_name('description')
+ raw_output = self.openstack(
+ 'project create '
+ '--description %(description)s '
+ '--enable '
+ '--property k1=v1 '
+ '--property k2=v2 '
+ '%(name)s' % {'description': description,
+ 'name': project_name})
+ self.addCleanup(
+ self.openstack,
+ 'project delete %s' % project_name
+ )
+ items = self.parse_show(raw_output)
+ show_fields = list(self.PROJECT_FIELDS)
+ show_fields.extend(['k1', 'k2'])
+ self.assert_show_fields(items, show_fields)
+ project = self.parse_show_as_object(raw_output)
+ self.assertEqual('v1', project['k1'])
+ self.assertEqual('v2', project['k2'])
+
+ def test_project_delete(self):
+ project_name = self._create_dummy_project(add_clean_up=False)
+ raw_output = self.openstack(
+ 'project delete %s' % project_name)
+ self.assertEqual(0, len(raw_output))
+
+ def test_project_list(self):
+ raw_output = self.openstack('project list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
+
+ def test_project_set(self):
+ project_name = self._create_dummy_project()
+ new_project_name = data_utils.rand_name('NewTestProject')
+ raw_output = self.openstack(
+ 'project set '
+ '--name %(new_name)s '
+ '--disable '
+ '--property k0=v0 '
+ '%(name)s' % {'new_name': new_project_name,
+ 'name': project_name})
+ self.assertEqual(0, len(raw_output))
+ # check project details
+ raw_output = self.openstack(
+ 'project show %s' % new_project_name
+ )
+ items = self.parse_show(raw_output)
+ fields = list(self.PROJECT_FIELDS)
+ fields.extend(['properties'])
+ self.assert_show_fields(items, fields)
+ project = self.parse_show_as_object(raw_output)
+ self.assertEqual(new_project_name, project['name'])
+ self.assertEqual('False', project['enabled'])
+ self.assertEqual("k0='v0'", project['properties'])
+
+ def test_project_show(self):
+ project_name = self._create_dummy_project()
+ raw_output = self.openstack(
+ 'project show %s' % project_name
+ )
+ items = self.parse_show(raw_output)
+ fields = list(self.PROJECT_FIELDS)
+ fields.extend(['properties'])
+ self.assert_show_fields(items, fields)
diff --git a/openstackclient/tests/functional/identity/v2/test_role.py b/openstackclient/tests/functional/identity/v2/test_role.py
new file mode 100644
index 00000000..82e19aab
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_role.py
@@ -0,0 +1,110 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class RoleTests(common.IdentityTests):
+
+ def test_role_create(self):
+ self._create_dummy_role()
+
+ def test_role_delete(self):
+ role_name = self._create_dummy_role(add_clean_up=False)
+ raw_output = self.openstack('role delete %s' % role_name)
+ self.assertEqual(0, len(raw_output))
+
+ def test_role_list(self):
+ self._create_dummy_role()
+ raw_output = self.openstack('role list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
+
+ def test_role_list_with_user_project(self):
+ project_name = self._create_dummy_project()
+ role_name = self._create_dummy_role()
+ username = self._create_dummy_user()
+ raw_output = self.openstack(
+ 'role add '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': project_name,
+ 'user': username,
+ 'role': role_name})
+ self.addCleanup(
+ self.openstack,
+ 'role remove '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': project_name,
+ 'user': username,
+ 'role': role_name})
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ROLE_FIELDS)
+
+ raw_output = self.openstack(
+ 'role list '
+ '--project %(project)s '
+ '--user %(user)s '
+ '' % {'project': project_name,
+ 'user': username})
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
+ self.assertEqual(1, len(items))
+
+ def test_role_show(self):
+ role_name = self._create_dummy_role()
+ raw_output = self.openstack('role show %s' % role_name)
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ROLE_FIELDS)
+
+ def test_role_add(self):
+ role_name = self._create_dummy_role()
+ username = self._create_dummy_user()
+ raw_output = self.openstack(
+ 'role add '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': self.project_name,
+ 'user': username,
+ 'role': role_name})
+ self.addCleanup(
+ self.openstack,
+ 'role remove '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': self.project_name,
+ 'user': username,
+ 'role': role_name})
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.ROLE_FIELDS)
+
+ def test_role_remove(self):
+ role_name = self._create_dummy_role()
+ username = self._create_dummy_user()
+ add_raw_output = self.openstack(
+ 'role add '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': self.project_name,
+ 'user': username,
+ 'role': role_name})
+ del_raw_output = self.openstack(
+ 'role remove '
+ '--project %(project)s '
+ '--user %(user)s '
+ '%(role)s' % {'project': self.project_name,
+ 'user': username,
+ 'role': role_name})
+ items = self.parse_show(add_raw_output)
+ self.assert_show_fields(items, self.ROLE_FIELDS)
+ self.assertEqual(0, len(del_raw_output))
diff --git a/openstackclient/tests/functional/identity/v2/test_service.py b/openstackclient/tests/functional/identity/v2/test_service.py
new file mode 100644
index 00000000..d0e03804
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_service.py
@@ -0,0 +1,44 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class ServiceTests(common.IdentityTests):
+
+ def test_service_create(self):
+ self._create_dummy_service()
+
+ def test_service_delete(self):
+ service_name = self._create_dummy_service(add_clean_up=False)
+ raw_output = self.openstack('service delete %s' % service_name)
+ self.assertEqual(0, len(raw_output))
+
+ def test_service_multi_delete(self):
+ service_name_1 = self._create_dummy_service(add_clean_up=False)
+ service_name_2 = self._create_dummy_service(add_clean_up=False)
+ raw_output = self.openstack(
+ 'service delete ' + service_name_1 + ' ' + service_name_2)
+ self.assertEqual(0, len(raw_output))
+
+ def test_service_list(self):
+ self._create_dummy_service()
+ raw_output = self.openstack('service list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
+
+ def test_service_show(self):
+ service_name = self._create_dummy_service()
+ raw_output = self.openstack(
+ 'service show %s' % service_name)
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.SERVICE_FIELDS)
diff --git a/openstackclient/tests/functional/identity/v2/test_token.py b/openstackclient/tests/functional/identity/v2/test_token.py
new file mode 100644
index 00000000..f8569744
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_token.py
@@ -0,0 +1,24 @@
+# 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.
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class TokenTests(common.IdentityTests):
+
+ def test_token_issue(self):
+ self._create_dummy_token()
+
+ def test_token_revoke(self):
+ token_id = self._create_dummy_token(add_clean_up=False)
+ raw_output = self.openstack('token revoke %s' % token_id)
+ self.assertEqual(0, len(raw_output))
diff --git a/openstackclient/tests/functional/identity/v2/test_user.py b/openstackclient/tests/functional/identity/v2/test_user.py
new file mode 100644
index 00000000..ac609b94
--- /dev/null
+++ b/openstackclient/tests/functional/identity/v2/test_user.py
@@ -0,0 +1,60 @@
+# 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.
+
+from tempest.lib.common.utils import data_utils
+from tempest.lib import exceptions
+
+from openstackclient.tests.functional.identity.v2 import common
+
+
+class UserTests(common.IdentityTests):
+
+ def test_user_create(self):
+ self._create_dummy_user()
+
+ def test_user_delete(self):
+ username = self._create_dummy_user(add_clean_up=False)
+ raw_output = self.openstack('user delete %s' % username)
+ self.assertEqual(0, len(raw_output))
+
+ def test_user_list(self):
+ raw_output = self.openstack('user list')
+ items = self.parse_listing(raw_output)
+ self.assert_table_structure(items, common.BASIC_LIST_HEADERS)
+
+ def test_user_set(self):
+ username = self._create_dummy_user()
+ raw_output = self.openstack('user show %s' % username)
+ user = self.parse_show_as_object(raw_output)
+ new_username = data_utils.rand_name('NewTestUser')
+ new_email = data_utils.rand_name() + '@example.com'
+ raw_output = self.openstack('user set '
+ '--email %(email)s '
+ '--name %(new_name)s '
+ '%(id)s' % {'email': new_email,
+ 'new_name': new_username,
+ 'id': user['id']})
+ self.assertEqual(0, len(raw_output))
+ raw_output = self.openstack('user show %s' % new_username)
+ new_user = self.parse_show_as_object(raw_output)
+ self.assertEqual(user['id'], new_user['id'])
+ self.assertEqual(new_email, new_user['email'])
+
+ def test_user_show(self):
+ username = self._create_dummy_user()
+ raw_output = self.openstack('user show %s' % username)
+ items = self.parse_show(raw_output)
+ self.assert_show_fields(items, self.USER_FIELDS)
+
+ def test_bad_user_command(self):
+ self.assertRaises(exceptions.CommandFailed,
+ self.openstack, 'user unlist')