ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 16 | from oslo_log import log as logging |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 17 | |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 18 | from tempest.common.utils import data_utils |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 19 | from tempest import config |
Jordan Pittier | 9e227c5 | 2016-02-09 14:35:18 +0100 | [diff] [blame] | 20 | from tempest.lib.common.utils import test_utils |
Attila Fazekas | dc21642 | 2013-01-29 15:12:14 +0100 | [diff] [blame] | 21 | import tempest.test |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 22 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 23 | CONF = config.CONF |
Masayuki Igawa | 630a3fa | 2014-03-12 19:51:45 +0900 | [diff] [blame] | 24 | LOG = logging.getLogger(__name__) |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 25 | |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 26 | |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 27 | class BaseIdentityTest(tempest.test.BaseTestCase): |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 28 | |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 29 | @classmethod |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 30 | def disable_user(cls, user_name): |
| 31 | user = cls.get_user_by_name(user_name) |
ghanshyam | 9c257a7 | 2016-06-21 10:15:10 +0900 | [diff] [blame] | 32 | cls.users_client.update_user_enabled(user['id'], enabled=False) |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 33 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 34 | @classmethod |
| 35 | def disable_tenant(cls, tenant_name): |
| 36 | tenant = cls.get_tenant_by_name(tenant_name) |
Daniel Mellado | b04da90 | 2015-11-20 17:43:12 +0100 | [diff] [blame] | 37 | cls.tenants_client.update_tenant(tenant['id'], enabled=False) |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 38 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 39 | @classmethod |
Tom Cocozzello | 5544c17 | 2016-02-23 17:50:28 -0600 | [diff] [blame] | 40 | def get_user_by_name(cls, name, domain_id=None): |
| 41 | if domain_id: |
| 42 | params = {'domain_id': domain_id} |
| 43 | users = cls.users_client.list_users(params)['users'] |
| 44 | else: |
| 45 | users = cls.users_client.list_users()['users'] |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 46 | user = [u for u in users if u['name'] == name] |
| 47 | if len(user) > 0: |
| 48 | return user[0] |
| 49 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 50 | @classmethod |
| 51 | def get_tenant_by_name(cls, name): |
| 52 | try: |
Daniel Mellado | b04da90 | 2015-11-20 17:43:12 +0100 | [diff] [blame] | 53 | tenants = cls.tenants_client.list_tenants()['tenants'] |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 54 | except AttributeError: |
Yaroslav Lobankov | 47a93ab | 2016-02-07 16:32:49 -0600 | [diff] [blame] | 55 | tenants = cls.projects_client.list_projects()['projects'] |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 56 | tenant = [t for t in tenants if t['name'] == name] |
| 57 | if len(tenant) > 0: |
| 58 | return tenant[0] |
| 59 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 60 | @classmethod |
| 61 | def get_role_by_name(cls, name): |
Daniel Mellado | 6b16b92 | 2015-12-07 12:43:08 +0000 | [diff] [blame] | 62 | roles = cls.roles_client.list_roles()['roles'] |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 63 | role = [r for r in roles if r['name'] == name] |
| 64 | if len(role) > 0: |
| 65 | return role[0] |
| 66 | |
| 67 | |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 68 | class BaseIdentityV2Test(BaseIdentityTest): |
| 69 | |
Andrea Frittoli | b21de6c | 2015-02-06 20:12:38 +0000 | [diff] [blame] | 70 | credentials = ['primary'] |
| 71 | |
Andrea Frittoli (andreaf) | 4160141 | 2015-05-12 16:39:03 +0100 | [diff] [blame] | 72 | # identity v2 tests should obtain tokens and create accounts via v2 |
| 73 | # regardless of the configured CONF.identity.auth_version |
| 74 | identity_version = 'v2' |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 75 | |
| 76 | @classmethod |
| 77 | def setup_clients(cls): |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 78 | super(BaseIdentityV2Test, cls).setup_clients() |
Jane Zadorozhna | bfc7237 | 2015-06-16 17:32:59 +0300 | [diff] [blame] | 79 | cls.non_admin_client = cls.os.identity_public_client |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 80 | cls.non_admin_token_client = cls.os.token_client |
Daniel Mellado | b04da90 | 2015-11-20 17:43:12 +0100 | [diff] [blame] | 81 | cls.non_admin_tenants_client = cls.os.tenants_public_client |
Daniel Mellado | 82c83a5 | 2015-12-09 15:16:49 +0000 | [diff] [blame] | 82 | cls.non_admin_users_client = cls.os.users_public_client |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 83 | |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 84 | |
| 85 | class BaseIdentityV2AdminTest(BaseIdentityV2Test): |
| 86 | |
Andrea Frittoli (andreaf) | 4160141 | 2015-05-12 16:39:03 +0100 | [diff] [blame] | 87 | credentials = ['primary', 'admin'] |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 88 | |
| 89 | @classmethod |
| 90 | def setup_clients(cls): |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 91 | super(BaseIdentityV2AdminTest, cls).setup_clients() |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 92 | cls.client = cls.os_adm.identity_client |
Jane Zadorozhna | bfc7237 | 2015-06-16 17:32:59 +0300 | [diff] [blame] | 93 | cls.non_admin_client = cls.os.identity_client |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 94 | cls.token_client = cls.os_adm.token_client |
Daniel Mellado | b04da90 | 2015-11-20 17:43:12 +0100 | [diff] [blame] | 95 | cls.tenants_client = cls.os_adm.tenants_client |
| 96 | cls.non_admin_tenants_client = cls.os.tenants_client |
Daniel Mellado | 6b16b92 | 2015-12-07 12:43:08 +0000 | [diff] [blame] | 97 | cls.roles_client = cls.os_adm.roles_client |
| 98 | cls.non_admin_roles_client = cls.os.roles_client |
Daniel Mellado | 82c83a5 | 2015-12-09 15:16:49 +0000 | [diff] [blame] | 99 | cls.users_client = cls.os_adm.users_client |
| 100 | cls.non_admin_users_client = cls.os.users_client |
Yaroslav Lobankov | f6906e1 | 2016-02-26 19:44:53 -0600 | [diff] [blame] | 101 | cls.services_client = cls.os_adm.identity_services_client |
| 102 | cls.endpoints_client = cls.os_adm.endpoints_client |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 103 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 104 | @classmethod |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 105 | def resource_setup(cls): |
| 106 | super(BaseIdentityV2AdminTest, cls).resource_setup() |
Arx Cruz | 24bcb88 | 2016-02-10 15:20:16 +0100 | [diff] [blame] | 107 | cls.data = DataGeneratorV2(cls.tenants_client, cls.users_client, |
| 108 | cls.roles_client) |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 109 | |
| 110 | @classmethod |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 111 | def resource_cleanup(cls): |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 112 | cls.data.teardown_all() |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 113 | super(BaseIdentityV2AdminTest, cls).resource_cleanup() |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 114 | |
| 115 | |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 116 | class BaseIdentityV3Test(BaseIdentityTest): |
| 117 | |
Andrea Frittoli | b21de6c | 2015-02-06 20:12:38 +0000 | [diff] [blame] | 118 | credentials = ['primary'] |
| 119 | |
Andrea Frittoli (andreaf) | 4160141 | 2015-05-12 16:39:03 +0100 | [diff] [blame] | 120 | # identity v3 tests should obtain tokens and create accounts via v3 |
| 121 | # regardless of the configured CONF.identity.auth_version |
| 122 | identity_version = 'v3' |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 123 | |
| 124 | @classmethod |
| 125 | def setup_clients(cls): |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 126 | super(BaseIdentityV3Test, cls).setup_clients() |
| 127 | cls.non_admin_client = cls.os.identity_v3_client |
Daniel Mellado | 7aea534 | 2016-02-09 09:10:12 +0000 | [diff] [blame] | 128 | cls.non_admin_users_client = cls.os.users_v3_client |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 129 | cls.non_admin_token = cls.os.token_v3_client |
Yaroslav Lobankov | 47a93ab | 2016-02-07 16:32:49 -0600 | [diff] [blame] | 130 | cls.non_admin_projects_client = cls.os.projects_client |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 131 | |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 132 | |
| 133 | class BaseIdentityV3AdminTest(BaseIdentityV3Test): |
| 134 | |
Andrea Frittoli (andreaf) | 4160141 | 2015-05-12 16:39:03 +0100 | [diff] [blame] | 135 | credentials = ['primary', 'admin'] |
Chris Hoge | 4f6117a | 2015-03-20 12:39:33 -0500 | [diff] [blame] | 136 | |
| 137 | @classmethod |
| 138 | def setup_clients(cls): |
Rohan Kanade | b645e17 | 2015-02-05 17:38:59 +0530 | [diff] [blame] | 139 | super(BaseIdentityV3AdminTest, cls).setup_clients() |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 140 | cls.client = cls.os_adm.identity_v3_client |
Daniel Mellado | 91a26b6 | 2016-02-11 11:13:04 +0000 | [diff] [blame] | 141 | cls.domains_client = cls.os_adm.domains_client |
Daniel Mellado | 7aea534 | 2016-02-09 09:10:12 +0000 | [diff] [blame] | 142 | cls.users_client = cls.os_adm.users_v3_client |
Daniel Mellado | 7640539 | 2016-02-11 12:47:12 +0000 | [diff] [blame] | 143 | cls.trusts_client = cls.os_adm.trusts_client |
Arx Cruz | 24bcb88 | 2016-02-10 15:20:16 +0100 | [diff] [blame] | 144 | cls.roles_client = cls.os_adm.roles_v3_client |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 145 | cls.token = cls.os_adm.token_v3_client |
Yaroslav Lobankov | f6906e1 | 2016-02-26 19:44:53 -0600 | [diff] [blame] | 146 | cls.endpoints_client = cls.os_adm.endpoints_v3_client |
Yaroslav Lobankov | 757d1a2 | 2015-12-18 11:43:02 +0300 | [diff] [blame] | 147 | cls.regions_client = cls.os_adm.regions_client |
Yaroslav Lobankov | f6906e1 | 2016-02-26 19:44:53 -0600 | [diff] [blame] | 148 | cls.services_client = cls.os_adm.identity_services_v3_client |
Yaroslav Lobankov | ed4d15c | 2015-12-18 11:30:10 +0300 | [diff] [blame] | 149 | cls.policies_client = cls.os_adm.policies_client |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 150 | cls.creds_client = cls.os_adm.credentials_client |
Yaroslav Lobankov | 997a145 | 2015-11-19 17:11:37 +0300 | [diff] [blame] | 151 | cls.groups_client = cls.os_adm.groups_client |
Yaroslav Lobankov | 47a93ab | 2016-02-07 16:32:49 -0600 | [diff] [blame] | 152 | cls.projects_client = cls.os_adm.projects_client |
Andrea Frittoli (andreaf) | 100d18d | 2016-05-05 23:34:52 +0100 | [diff] [blame] | 153 | if CONF.identity.admin_domain_scope: |
| 154 | # NOTE(andreaf) When keystone policy requires it, the identity |
| 155 | # admin clients for these tests shall use 'domain' scoped tokens. |
| 156 | # As the client manager is already created by the base class, |
| 157 | # we set the scope for the inner auth provider. |
| 158 | cls.os_adm.auth_provider.scope = 'domain' |
Yaroslav Lobankov | 997a145 | 2015-11-19 17:11:37 +0300 | [diff] [blame] | 159 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 160 | @classmethod |
| 161 | def resource_setup(cls): |
| 162 | super(BaseIdentityV3AdminTest, cls).resource_setup() |
Arx Cruz | 24bcb88 | 2016-02-10 15:20:16 +0100 | [diff] [blame] | 163 | cls.data = DataGeneratorV3(cls.projects_client, cls.users_client, |
| 164 | cls.roles_client, cls.domains_client) |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 165 | |
| 166 | @classmethod |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 167 | def resource_cleanup(cls): |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 168 | cls.data.teardown_all() |
Andrea Frittoli | 7688e74 | 2014-09-15 12:38:22 +0100 | [diff] [blame] | 169 | super(BaseIdentityV3AdminTest, cls).resource_cleanup() |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 170 | |
David Kranz | d8ccb79 | 2014-12-29 11:32:05 -0500 | [diff] [blame] | 171 | @classmethod |
Tom Cocozzello | 5544c17 | 2016-02-23 17:50:28 -0600 | [diff] [blame] | 172 | def disable_user(cls, user_name, domain_id=None): |
| 173 | user = cls.get_user_by_name(user_name, domain_id) |
Daniel Mellado | 7aea534 | 2016-02-09 09:10:12 +0000 | [diff] [blame] | 174 | cls.users_client.update_user(user['id'], user_name, enabled=False) |
BinBin Cong | c6e8ef5 | 2015-11-20 02:08:46 -0500 | [diff] [blame] | 175 | |
Martin Pavlasek | 4c3f2ab | 2014-04-15 17:15:15 +0200 | [diff] [blame] | 176 | def delete_domain(self, domain_id): |
| 177 | # NOTE(mpavlase) It is necessary to disable the domain before deleting |
| 178 | # otherwise it raises Forbidden exception |
Daniel Mellado | 91a26b6 | 2016-02-11 11:13:04 +0000 | [diff] [blame] | 179 | self.domains_client.update_domain(domain_id, enabled=False) |
| 180 | self.domains_client.delete_domain(domain_id) |
Martin Pavlasek | 4c3f2ab | 2014-04-15 17:15:15 +0200 | [diff] [blame] | 181 | |
Matthew Treinish | db2c597 | 2014-01-31 22:18:59 +0000 | [diff] [blame] | 182 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 183 | class BaseDataGenerator(object): |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 184 | |
Arx Cruz | 24bcb88 | 2016-02-10 15:20:16 +0100 | [diff] [blame] | 185 | def __init__(self, projects_client, users_client, roles_client, |
| 186 | domains_client=None): |
Yaroslav Lobankov | 47a93ab | 2016-02-07 16:32:49 -0600 | [diff] [blame] | 187 | self.projects_client = projects_client |
Daniel Mellado | 7aea534 | 2016-02-09 09:10:12 +0000 | [diff] [blame] | 188 | self.users_client = users_client |
Arx Cruz | 24bcb88 | 2016-02-10 15:20:16 +0100 | [diff] [blame] | 189 | self.roles_client = roles_client |
Daniel Mellado | 91a26b6 | 2016-02-11 11:13:04 +0000 | [diff] [blame] | 190 | self.domains_client = domains_client |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 191 | |
Yaroslav Lobankov | 95aa3f7 | 2016-01-28 15:39:49 -0600 | [diff] [blame] | 192 | self.user_password = None |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 193 | self.user = None |
| 194 | self.tenant = None |
| 195 | self.project = None |
| 196 | self.role = None |
| 197 | self.domain = None |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 198 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 199 | self.users = [] |
| 200 | self.tenants = [] |
| 201 | self.projects = [] |
| 202 | self.roles = [] |
| 203 | self.domains = [] |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 204 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 205 | def _create_test_user(self, **kwargs): |
Yaroslav Lobankov | 95aa3f7 | 2016-01-28 15:39:49 -0600 | [diff] [blame] | 206 | self.user_password = data_utils.rand_password() |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 207 | self.user = self.users_client.create_user( |
ghanshyam | e1c6c1c | 2016-06-15 14:50:41 +0900 | [diff] [blame] | 208 | password=self.user_password, |
| 209 | **kwargs)['user'] |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 210 | self.users.append(self.user) |
Rohit Karajgi | 6b1e154 | 2012-05-14 05:55:54 -0700 | [diff] [blame] | 211 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 212 | def setup_test_role(self): |
| 213 | """Set up a test role.""" |
Yaroslav Lobankov | 95aa3f7 | 2016-01-28 15:39:49 -0600 | [diff] [blame] | 214 | self.role = self.roles_client.create_role( |
| 215 | name=data_utils.rand_name('test_role'))['role'] |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 216 | self.roles.append(self.role) |
Nayna Patel | e633136 | 2013-08-12 06:59:48 +0000 | [diff] [blame] | 217 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 218 | def teardown_all(self): |
| 219 | for user in self.users: |
Matthew Treinish | 03f09f9 | 2016-06-23 15:32:33 -0400 | [diff] [blame] | 220 | test_utils.call_and_ignore_notfound_exc( |
| 221 | self.users_client.delete_user, user) |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 222 | for tenant in self.tenants: |
Matthew Treinish | 03f09f9 | 2016-06-23 15:32:33 -0400 | [diff] [blame] | 223 | test_utils.call_and_ignore_notfound_exc( |
| 224 | self.projects_client.delete_tenant, tenant) |
Brant Knudson | e77b689 | 2016-06-23 13:07:47 -0500 | [diff] [blame] | 225 | for project in reversed(self.projects): |
Matthew Treinish | 03f09f9 | 2016-06-23 15:32:33 -0400 | [diff] [blame] | 226 | test_utils.call_and_ignore_notfound_exc( |
| 227 | self.projects_client.delete_project, project) |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 228 | for role in self.roles: |
Matthew Treinish | 03f09f9 | 2016-06-23 15:32:33 -0400 | [diff] [blame] | 229 | test_utils.call_and_ignore_notfound_exc( |
| 230 | self.roles_client.delete_role, role) |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 231 | for domain in self.domains: |
Matthew Treinish | 03f09f9 | 2016-06-23 15:32:33 -0400 | [diff] [blame] | 232 | test_utils.call_and_ignore_notfound_exc( |
| 233 | self.domains_client.update_domain, domain, enabled=False) |
| 234 | test_utils.call_and_ignore_notfound_exc( |
| 235 | self.domains_client.delete_domain, domain) |
Nayna Patel | e633136 | 2013-08-12 06:59:48 +0000 | [diff] [blame] | 236 | |
nayna-patel | 2db83b3 | 2014-05-15 11:41:03 +0000 | [diff] [blame] | 237 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 238 | class DataGeneratorV2(BaseDataGenerator): |
Masayuki Igawa | 630a3fa | 2014-03-12 19:51:45 +0900 | [diff] [blame] | 239 | |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 240 | def setup_test_user(self): |
| 241 | """Set up a test user.""" |
| 242 | self.setup_test_tenant() |
ghanshyam | e1c6c1c | 2016-06-15 14:50:41 +0900 | [diff] [blame] | 243 | username = data_utils.rand_name('test_user') |
| 244 | email = username + '@testmail.tm' |
| 245 | self._create_test_user(name=username, email=email, |
| 246 | tenantId=self.tenant['id']) |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 247 | |
| 248 | def setup_test_tenant(self): |
| 249 | """Set up a test tenant.""" |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 250 | self.tenant = self.projects_client.create_tenant( |
Yaroslav Lobankov | 95aa3f7 | 2016-01-28 15:39:49 -0600 | [diff] [blame] | 251 | name=data_utils.rand_name('test_tenant'), |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 252 | description=data_utils.rand_name('desc'))['tenant'] |
| 253 | self.tenants.append(self.tenant) |
| 254 | |
| 255 | |
| 256 | class DataGeneratorV3(BaseDataGenerator): |
| 257 | |
| 258 | def setup_test_user(self): |
| 259 | """Set up a test user.""" |
| 260 | self.setup_test_project() |
ghanshyam | e1c6c1c | 2016-06-15 14:50:41 +0900 | [diff] [blame] | 261 | username = data_utils.rand_name('test_user') |
| 262 | email = username + '@testmail.tm' |
| 263 | self._create_test_user(user_name=username, email=email, |
| 264 | project_id=self.project['id']) |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 265 | |
| 266 | def setup_test_project(self): |
| 267 | """Set up a test project.""" |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 268 | self.project = self.projects_client.create_project( |
Yaroslav Lobankov | 95aa3f7 | 2016-01-28 15:39:49 -0600 | [diff] [blame] | 269 | name=data_utils.rand_name('test_project'), |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 270 | description=data_utils.rand_name('desc'))['project'] |
| 271 | self.projects.append(self.project) |
| 272 | |
| 273 | def setup_test_domain(self): |
| 274 | """Set up a test domain.""" |
Daniel Mellado | 91a26b6 | 2016-02-11 11:13:04 +0000 | [diff] [blame] | 275 | self.domain = self.domains_client.create_domain( |
Yaroslav Lobankov | 2c2f036 | 2016-01-13 18:07:22 +0300 | [diff] [blame] | 276 | name=data_utils.rand_name('test_domain'), |
| 277 | description=data_utils.rand_name('desc'))['domain'] |
| 278 | self.domains.append(self.domain) |