Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 1 | # Copyright 2014 Hewlett-Packard Development Company, L.P. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | import hashlib |
| 16 | import os |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 17 | |
| 18 | import mock |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 19 | from oslo_concurrency.fixture import lockutils as lockutils_fixtures |
| 20 | from oslo_config import cfg |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 21 | from oslotest import mockpatch |
| 22 | |
| 23 | from tempest import auth |
| 24 | from tempest.common import accounts |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 25 | from tempest import config |
| 26 | from tempest import exceptions |
Jamie Lennox | c429e6a | 2015-02-24 10:42:42 +1100 | [diff] [blame] | 27 | from tempest.services.identity.v2.json import token_client |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 28 | from tempest.tests import base |
| 29 | from tempest.tests import fake_config |
| 30 | from tempest.tests import fake_identity |
| 31 | |
| 32 | |
| 33 | class TestAccount(base.TestCase): |
| 34 | |
| 35 | def setUp(self): |
| 36 | super(TestAccount, self).setUp() |
| 37 | self.useFixture(fake_config.ConfigFixture()) |
| 38 | self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 39 | self.useFixture(lockutils_fixtures.ExternalLockFixture()) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 40 | self.test_accounts = [ |
| 41 | {'username': 'test_user1', 'tenant_name': 'test_tenant1', |
| 42 | 'password': 'p'}, |
| 43 | {'username': 'test_user2', 'tenant_name': 'test_tenant2', |
| 44 | 'password': 'p'}, |
| 45 | {'username': 'test_user3', 'tenant_name': 'test_tenant3', |
| 46 | 'password': 'p'}, |
| 47 | {'username': 'test_user4', 'tenant_name': 'test_tenant4', |
| 48 | 'password': 'p'}, |
| 49 | {'username': 'test_user5', 'tenant_name': 'test_tenant5', |
| 50 | 'password': 'p'}, |
| 51 | {'username': 'test_user6', 'tenant_name': 'test_tenant6', |
Matthew Treinish | 976e8df | 2014-12-19 14:21:54 -0500 | [diff] [blame] | 52 | 'password': 'p', 'roles': ['role1', 'role2']}, |
| 53 | {'username': 'test_user7', 'tenant_name': 'test_tenant7', |
| 54 | 'password': 'p', 'roles': ['role2', 'role3']}, |
| 55 | {'username': 'test_user8', 'tenant_name': 'test_tenant8', |
| 56 | 'password': 'p', 'roles': ['role4', 'role1']}, |
| 57 | {'username': 'test_user9', 'tenant_name': 'test_tenant9', |
| 58 | 'password': 'p', 'roles': ['role1', 'role2', 'role3', 'role4']}, |
| 59 | {'username': 'test_user10', 'tenant_name': 'test_tenant10', |
| 60 | 'password': 'p', 'roles': ['role1', 'role2', 'role3', 'role4']}, |
| 61 | {'username': 'test_user11', 'tenant_name': 'test_tenant11', |
| 62 | 'password': 'p', 'roles': [cfg.CONF.identity.admin_role]}, |
| 63 | {'username': 'test_user12', 'tenant_name': 'test_tenant12', |
| 64 | 'password': 'p', 'roles': [cfg.CONF.identity.admin_role]}, |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 65 | ] |
| 66 | self.useFixture(mockpatch.Patch( |
| 67 | 'tempest.common.accounts.read_accounts_yaml', |
| 68 | return_value=self.test_accounts)) |
| 69 | cfg.CONF.set_default('test_accounts_file', '', group='auth') |
Matthew Treinish | b19eeb8 | 2014-09-04 09:57:46 -0400 | [diff] [blame] | 70 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 71 | |
| 72 | def _get_hash_list(self, accounts_list): |
| 73 | hash_list = [] |
| 74 | for account in accounts_list: |
| 75 | hash = hashlib.md5() |
| 76 | hash.update(str(account)) |
Matthew Treinish | 976e8df | 2014-12-19 14:21:54 -0500 | [diff] [blame] | 77 | temp_hash = hash.hexdigest() |
| 78 | hash_list.append(temp_hash) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 79 | return hash_list |
| 80 | |
| 81 | def test_get_hash(self): |
ghanshyam | c0edda0 | 2015-02-06 15:51:40 +0900 | [diff] [blame] | 82 | self.stubs.Set(token_client.TokenClientJSON, 'raw_request', |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 83 | fake_identity._fake_v2_response) |
| 84 | test_account_class = accounts.Accounts('test_name') |
| 85 | hash_list = self._get_hash_list(self.test_accounts) |
| 86 | test_cred_dict = self.test_accounts[3] |
ghanshyam | 5ff763f | 2015-02-18 16:15:58 +0900 | [diff] [blame] | 87 | test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL, |
| 88 | **test_cred_dict) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 89 | results = test_account_class.get_hash(test_creds) |
| 90 | self.assertEqual(hash_list[3], results) |
| 91 | |
| 92 | def test_get_hash_dict(self): |
| 93 | test_account_class = accounts.Accounts('test_name') |
| 94 | hash_dict = test_account_class.get_hash_dict(self.test_accounts) |
| 95 | hash_list = self._get_hash_list(self.test_accounts) |
| 96 | for hash in hash_list: |
Matthew Treinish | 976e8df | 2014-12-19 14:21:54 -0500 | [diff] [blame] | 97 | self.assertIn(hash, hash_dict['creds'].keys()) |
| 98 | self.assertIn(hash_dict['creds'][hash], self.test_accounts) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 99 | |
| 100 | def test_create_hash_file_previous_file(self): |
| 101 | # Emulate the lock existing on the filesystem |
| 102 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
| 103 | with mock.patch('__builtin__.open', mock.mock_open(), create=True): |
| 104 | test_account_class = accounts.Accounts('test_name') |
| 105 | res = test_account_class._create_hash_file('12345') |
| 106 | self.assertFalse(res, "_create_hash_file should return False if the " |
| 107 | "pseudo-lock file already exists") |
| 108 | |
| 109 | def test_create_hash_file_no_previous_file(self): |
| 110 | # Emulate the lock not existing on the filesystem |
| 111 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False)) |
| 112 | with mock.patch('__builtin__.open', mock.mock_open(), create=True): |
| 113 | test_account_class = accounts.Accounts('test_name') |
| 114 | res = test_account_class._create_hash_file('12345') |
| 115 | self.assertTrue(res, "_create_hash_file should return True if the " |
| 116 | "pseudo-lock doesn't already exist") |
| 117 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 118 | @mock.patch('oslo_concurrency.lockutils.lock') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 119 | def test_get_free_hash_no_previous_accounts(self, lock_mock): |
| 120 | # Emulate no pre-existing lock |
| 121 | self.useFixture(mockpatch.Patch('os.path.isdir', return_value=False)) |
| 122 | hash_list = self._get_hash_list(self.test_accounts) |
| 123 | mkdir_mock = self.useFixture(mockpatch.Patch('os.mkdir')) |
| 124 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=False)) |
| 125 | test_account_class = accounts.Accounts('test_name') |
| 126 | with mock.patch('__builtin__.open', mock.mock_open(), |
| 127 | create=True) as open_mock: |
| 128 | test_account_class._get_free_hash(hash_list) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 129 | # FIXME(dhellmann): The configuration option is not part |
| 130 | # of the API of the library, because if we change the |
| 131 | # option name or group it will break this use. Tempest |
| 132 | # needs to set this value somewhere that it owns, and then |
| 133 | # use lockutils.set_defaults() to tell oslo.concurrency |
| 134 | # what value to use. |
| 135 | lock_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 136 | 'test_accounts', |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 137 | hash_list[0]) |
| 138 | open_mock.assert_called_once_with(lock_path, 'w') |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 139 | mkdir_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 140 | 'test_accounts') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 141 | mkdir_mock.mock.assert_called_once_with(mkdir_path) |
| 142 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 143 | @mock.patch('oslo_concurrency.lockutils.lock') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 144 | def test_get_free_hash_no_free_accounts(self, lock_mock): |
| 145 | hash_list = self._get_hash_list(self.test_accounts) |
| 146 | # Emulate pre-existing lock dir |
| 147 | self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True)) |
| 148 | # Emulate all lcoks in list are in use |
| 149 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
| 150 | test_account_class = accounts.Accounts('test_name') |
Matthew Treinish | 4041b26 | 2015-02-27 11:18:54 -0500 | [diff] [blame] | 151 | with mock.patch('__builtin__.open', mock.mock_open(), create=True): |
| 152 | self.assertRaises(exceptions.InvalidConfiguration, |
| 153 | test_account_class._get_free_hash, hash_list) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 154 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 155 | @mock.patch('oslo_concurrency.lockutils.lock') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 156 | def test_get_free_hash_some_in_use_accounts(self, lock_mock): |
| 157 | # Emulate no pre-existing lock |
| 158 | self.useFixture(mockpatch.Patch('os.path.isdir', return_value=True)) |
| 159 | hash_list = self._get_hash_list(self.test_accounts) |
| 160 | test_account_class = accounts.Accounts('test_name') |
| 161 | |
| 162 | def _fake_is_file(path): |
| 163 | # Fake isfile() to return that the path exists unless a specific |
| 164 | # hash is in the path |
| 165 | if hash_list[3] in path: |
| 166 | return False |
| 167 | return True |
| 168 | |
| 169 | self.stubs.Set(os.path, 'isfile', _fake_is_file) |
| 170 | with mock.patch('__builtin__.open', mock.mock_open(), |
| 171 | create=True) as open_mock: |
| 172 | test_account_class._get_free_hash(hash_list) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 173 | # FIXME(dhellmann): The configuration option is not part |
| 174 | # of the API of the library, because if we change the |
| 175 | # option name or group it will break this use. Tempest |
| 176 | # needs to set this value somewhere that it owns, and then |
| 177 | # use lockutils.set_defaults() to tell oslo.concurrency |
| 178 | # what value to use. |
| 179 | lock_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 180 | 'test_accounts', |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 181 | hash_list[3]) |
Matthew Treinish | 4041b26 | 2015-02-27 11:18:54 -0500 | [diff] [blame] | 182 | open_mock.assert_has_calls([mock.call(lock_path, 'w')]) |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 183 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 184 | @mock.patch('oslo_concurrency.lockutils.lock') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 185 | def test_remove_hash_last_account(self, lock_mock): |
| 186 | hash_list = self._get_hash_list(self.test_accounts) |
| 187 | # Pretend the pseudo-lock is there |
| 188 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
| 189 | # Pretend the lock dir is empty |
| 190 | self.useFixture(mockpatch.Patch('os.listdir', return_value=[])) |
| 191 | test_account_class = accounts.Accounts('test_name') |
| 192 | remove_mock = self.useFixture(mockpatch.Patch('os.remove')) |
| 193 | rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir')) |
| 194 | test_account_class.remove_hash(hash_list[2]) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 195 | # FIXME(dhellmann): The configuration option is not part of |
| 196 | # the API of the library, because if we change the option name |
| 197 | # or group it will break this use. Tempest needs to set this |
| 198 | # value somewhere that it owns, and then use |
| 199 | # lockutils.set_defaults() to tell oslo.concurrency what value |
| 200 | # to use. |
| 201 | hash_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 202 | 'test_accounts', |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 203 | hash_list[2]) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 204 | lock_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 205 | 'test_accounts') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 206 | remove_mock.mock.assert_called_once_with(hash_path) |
| 207 | rmdir_mock.mock.assert_called_once_with(lock_path) |
| 208 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 209 | @mock.patch('oslo_concurrency.lockutils.lock') |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 210 | def test_remove_hash_not_last_account(self, lock_mock): |
| 211 | hash_list = self._get_hash_list(self.test_accounts) |
| 212 | # Pretend the pseudo-lock is there |
| 213 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
| 214 | # Pretend the lock dir is empty |
| 215 | self.useFixture(mockpatch.Patch('os.listdir', return_value=[ |
| 216 | hash_list[1], hash_list[4]])) |
| 217 | test_account_class = accounts.Accounts('test_name') |
| 218 | remove_mock = self.useFixture(mockpatch.Patch('os.remove')) |
| 219 | rmdir_mock = self.useFixture(mockpatch.Patch('os.rmdir')) |
| 220 | test_account_class.remove_hash(hash_list[2]) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 221 | # FIXME(dhellmann): The configuration option is not part of |
| 222 | # the API of the library, because if we change the option name |
| 223 | # or group it will break this use. Tempest needs to set this |
| 224 | # value somewhere that it owns, and then use |
| 225 | # lockutils.set_defaults() to tell oslo.concurrency what value |
| 226 | # to use. |
| 227 | hash_path = os.path.join(accounts.CONF.oslo_concurrency.lock_path, |
| 228 | 'test_accounts', |
Matthew Treinish | c791ac4 | 2014-07-16 09:15:23 -0400 | [diff] [blame] | 229 | hash_list[2]) |
| 230 | remove_mock.mock.assert_called_once_with(hash_path) |
| 231 | rmdir_mock.mock.assert_not_called() |
Matthew Treinish | 09f1783 | 2014-08-15 15:22:50 -0400 | [diff] [blame] | 232 | |
| 233 | def test_is_multi_user(self): |
| 234 | test_accounts_class = accounts.Accounts('test_name') |
| 235 | self.assertTrue(test_accounts_class.is_multi_user()) |
| 236 | |
| 237 | def test_is_not_multi_user(self): |
| 238 | self.test_accounts = [self.test_accounts[0]] |
| 239 | self.useFixture(mockpatch.Patch( |
| 240 | 'tempest.common.accounts.read_accounts_yaml', |
| 241 | return_value=self.test_accounts)) |
| 242 | test_accounts_class = accounts.Accounts('test_name') |
| 243 | self.assertFalse(test_accounts_class.is_multi_user()) |
Andrea Frittoli | b1c23fc | 2014-09-03 13:40:08 +0100 | [diff] [blame] | 244 | |
Matthew Treinish | 976e8df | 2014-12-19 14:21:54 -0500 | [diff] [blame] | 245 | def test__get_creds_by_roles_one_role(self): |
| 246 | self.useFixture(mockpatch.Patch( |
| 247 | 'tempest.common.accounts.read_accounts_yaml', |
| 248 | return_value=self.test_accounts)) |
| 249 | test_accounts_class = accounts.Accounts('test_name') |
| 250 | hashes = test_accounts_class.hash_dict['roles']['role4'] |
| 251 | temp_hash = hashes[0] |
| 252 | get_free_hash_mock = self.useFixture(mockpatch.PatchObject( |
| 253 | test_accounts_class, '_get_free_hash', return_value=temp_hash)) |
| 254 | # Test a single role returns all matching roles |
| 255 | test_accounts_class._get_creds(roles=['role4']) |
| 256 | calls = get_free_hash_mock.mock.mock_calls |
| 257 | self.assertEqual(len(calls), 1) |
| 258 | args = calls[0][1][0] |
| 259 | for i in hashes: |
| 260 | self.assertIn(i, args) |
| 261 | |
| 262 | def test__get_creds_by_roles_list_role(self): |
| 263 | self.useFixture(mockpatch.Patch( |
| 264 | 'tempest.common.accounts.read_accounts_yaml', |
| 265 | return_value=self.test_accounts)) |
| 266 | test_accounts_class = accounts.Accounts('test_name') |
| 267 | hashes = test_accounts_class.hash_dict['roles']['role4'] |
| 268 | hashes2 = test_accounts_class.hash_dict['roles']['role2'] |
| 269 | hashes = list(set(hashes) & set(hashes2)) |
| 270 | temp_hash = hashes[0] |
| 271 | get_free_hash_mock = self.useFixture(mockpatch.PatchObject( |
| 272 | test_accounts_class, '_get_free_hash', return_value=temp_hash)) |
| 273 | # Test an intersection of multiple roles |
| 274 | test_accounts_class._get_creds(roles=['role2', 'role4']) |
| 275 | calls = get_free_hash_mock.mock.mock_calls |
| 276 | self.assertEqual(len(calls), 1) |
| 277 | args = calls[0][1][0] |
| 278 | for i in hashes: |
| 279 | self.assertIn(i, args) |
| 280 | |
| 281 | def test__get_creds_by_roles_no_admin(self): |
| 282 | self.useFixture(mockpatch.Patch( |
| 283 | 'tempest.common.accounts.read_accounts_yaml', |
| 284 | return_value=self.test_accounts)) |
| 285 | test_accounts_class = accounts.Accounts('test_name') |
| 286 | hashes = test_accounts_class.hash_dict['creds'].keys() |
| 287 | admin_hashes = test_accounts_class.hash_dict['roles'][ |
| 288 | cfg.CONF.identity.admin_role] |
| 289 | temp_hash = hashes[0] |
| 290 | get_free_hash_mock = self.useFixture(mockpatch.PatchObject( |
| 291 | test_accounts_class, '_get_free_hash', return_value=temp_hash)) |
| 292 | # Test an intersection of multiple roles |
| 293 | test_accounts_class._get_creds() |
| 294 | calls = get_free_hash_mock.mock.mock_calls |
| 295 | self.assertEqual(len(calls), 1) |
| 296 | args = calls[0][1][0] |
| 297 | self.assertEqual(len(args), 10) |
| 298 | for i in admin_hashes: |
| 299 | self.assertNotIn(i, args) |
| 300 | |
Andrea Frittoli | b1c23fc | 2014-09-03 13:40:08 +0100 | [diff] [blame] | 301 | |
| 302 | class TestNotLockingAccount(base.TestCase): |
| 303 | |
| 304 | def setUp(self): |
| 305 | super(TestNotLockingAccount, self).setUp() |
| 306 | self.useFixture(fake_config.ConfigFixture()) |
| 307 | self.stubs.Set(config, 'TempestConfigPrivate', fake_config.FakePrivate) |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 308 | self.useFixture(lockutils_fixtures.ExternalLockFixture()) |
Andrea Frittoli | b1c23fc | 2014-09-03 13:40:08 +0100 | [diff] [blame] | 309 | self.test_accounts = [ |
| 310 | {'username': 'test_user1', 'tenant_name': 'test_tenant1', |
| 311 | 'password': 'p'}, |
| 312 | {'username': 'test_user2', 'tenant_name': 'test_tenant2', |
| 313 | 'password': 'p'}, |
| 314 | {'username': 'test_user3', 'tenant_name': 'test_tenant3', |
| 315 | 'password': 'p'}, |
| 316 | ] |
| 317 | self.useFixture(mockpatch.Patch( |
| 318 | 'tempest.common.accounts.read_accounts_yaml', |
| 319 | return_value=self.test_accounts)) |
| 320 | cfg.CONF.set_default('test_accounts_file', '', group='auth') |
Matthew Treinish | b19eeb8 | 2014-09-04 09:57:46 -0400 | [diff] [blame] | 321 | self.useFixture(mockpatch.Patch('os.path.isfile', return_value=True)) |
Andrea Frittoli | b1c23fc | 2014-09-03 13:40:08 +0100 | [diff] [blame] | 322 | |
| 323 | def test_get_creds(self): |
| 324 | test_accounts_class = accounts.NotLockingAccounts('test_name') |
| 325 | for i in xrange(len(self.test_accounts)): |
| 326 | creds = test_accounts_class.get_creds(i) |
| 327 | msg = "Empty credentials returned for ID %s" % str(i) |
| 328 | self.assertIsNotNone(creds, msg) |
| 329 | self.assertRaises(exceptions.InvalidConfiguration, |
| 330 | test_accounts_class.get_creds, |
Matthew Treinish | b19eeb8 | 2014-09-04 09:57:46 -0400 | [diff] [blame] | 331 | id=len(self.test_accounts)) |