summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_backend.py305
-rw-r--r--tests/test_backend_kvs.py37
-rw-r--r--tests/test_backend_ldap.py96
-rw-r--r--tests/test_backend_sql.py60
-rw-r--r--tests/test_backend_templated.py20
-rw-r--r--tests/test_keystoneclient.py24
-rw-r--r--tests/test_keystoneclient_sql.py11
7 files changed, 445 insertions, 108 deletions
diff --git a/tests/test_backend.py b/tests/test_backend.py
index c5404ad3..85cb4c31 100644
--- a/tests/test_backend.py
+++ b/tests/test_backend.py
@@ -24,7 +24,7 @@ class IdentityTests(object):
def test_authenticate_bad_user(self):
self.assertRaises(AssertionError,
self.identity_api.authenticate,
- user_id=self.user_foo['id'] + 'WRONG',
+ user_id=uuid.uuid4().hex,
tenant_id=self.tenant_bar['id'],
password=self.user_foo['password'])
@@ -33,13 +33,13 @@ class IdentityTests(object):
self.identity_api.authenticate,
user_id=self.user_foo['id'],
tenant_id=self.tenant_bar['id'],
- password=self.user_foo['password'] + 'WRONG')
+ password=uuid.uuid4().hex)
- def test_authenticate_invalid_tenant(self):
+ def test_authenticate_bad_tenant(self):
self.assertRaises(AssertionError,
self.identity_api.authenticate,
user_id=self.user_foo['id'],
- tenant_id=self.tenant_bar['id'] + 'WRONG',
+ tenant_id=uuid.uuid4().hex,
password=self.user_foo['password'])
def test_authenticate_no_tenant(self):
@@ -86,30 +86,30 @@ class IdentityTests(object):
user_ref = self.identity_api._get_user(self.user_foo['id'])
self.assertNotEqual(user_ref['password'], self.user_foo['password'])
- def test_get_tenant_bad_tenant(self):
- tenant_ref = self.identity_api.get_tenant(
- tenant_id=self.tenant_bar['id'] + 'WRONG')
- self.assert_(tenant_ref is None)
-
def test_get_tenant(self):
tenant_ref = self.identity_api.get_tenant(
tenant_id=self.tenant_bar['id'])
self.assertDictEqual(tenant_ref, self.tenant_bar)
- def test_get_tenant_by_name_bad_tenant(self):
- tenant_ref = self.identity_api.get_tenant(
- tenant_id=self.tenant_bar['name'] + 'WRONG')
- self.assert_(tenant_ref is None)
+ def test_get_tenant_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant,
+ tenant_id=uuid.uuid4().hex)
def test_get_tenant_by_name(self):
tenant_ref = self.identity_api.get_tenant_by_name(
tenant_name=self.tenant_bar['name'])
self.assertDictEqual(tenant_ref, self.tenant_bar)
- def test_get_user_bad_user(self):
- user_ref = self.identity_api.get_user(
- user_id=self.user_foo['id'] + 'WRONG')
- self.assert_(user_ref is None)
+ def test_get_tenant_by_name_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant,
+ tenant_id=uuid.uuid4().hex)
+
+ def test_get_tenant_users_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant_users,
+ tenant_id=uuid.uuid4().hex)
def test_get_user(self):
user_ref = self.identity_api.get_user(user_id=self.user_foo['id'])
@@ -119,6 +119,11 @@ class IdentityTests(object):
self.user_foo.pop('password')
self.assertDictEqual(user_ref, self.user_foo)
+ def test_get_user_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_user,
+ user_id=uuid.uuid4().hex)
+
def test_get_user_by_name(self):
user_ref = self.identity_api.get_user_by_name(
user_name=self.user_foo['name'])
@@ -128,17 +133,10 @@ class IdentityTests(object):
self.user_foo.pop('password')
self.assertDictEqual(user_ref, self.user_foo)
- def test_get_metadata_bad_user(self):
- metadata_ref = self.identity_api.get_metadata(
- user_id=self.user_foo['id'] + 'WRONG',
- tenant_id=self.tenant_bar['id'])
- self.assert_(metadata_ref == {})
-
- def test_get_metadata_bad_tenant(self):
- metadata_ref = self.identity_api.get_metadata(
- user_id=self.user_foo['id'],
- tenant_id=self.tenant_bar['id'] + 'WRONG')
- self.assert_(metadata_ref == {})
+ def test_get_user_by_name_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_user_by_name,
+ user_name=uuid.uuid4().hex)
def test_get_metadata(self):
metadata_ref = self.identity_api.get_metadata(
@@ -146,12 +144,29 @@ class IdentityTests(object):
tenant_id=self.tenant_bar['id'])
self.assertDictEqual(metadata_ref, self.metadata_foobar)
+ def test_get_metadata_404(self):
+ # FIXME(dolph): these exceptions could be more specific
+ self.assertRaises(exception.NotFound,
+ self.identity_api.get_metadata,
+ user_id=uuid.uuid4().hex,
+ tenant_id=self.tenant_bar['id'])
+
+ self.assertRaises(exception.NotFound,
+ self.identity_api.get_metadata,
+ user_id=self.user_foo['id'],
+ tenant_id=uuid.uuid4().hex)
+
def test_get_role(self):
role_ref = self.identity_api.get_role(
role_id=self.role_keystone_admin['id'])
role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
self.assertDictEqual(role_ref_dict, self.role_keystone_admin)
+ def test_get_role_404(self):
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.get_role,
+ role_id=uuid.uuid4().hex)
+
def test_create_duplicate_role_name_fails(self):
role = {'id': 'fake1',
'name': 'fake1name'}
@@ -170,7 +185,7 @@ class IdentityTests(object):
self.identity_api.create_role('fake1', role1)
self.identity_api.create_role('fake2', role2)
role1['name'] = 'fake2name'
- self.assertRaises(exception.Error,
+ self.assertRaises(exception.Conflict,
self.identity_api.update_role,
'fake1',
role1)
@@ -211,23 +226,27 @@ class IdentityTests(object):
self.identity_api.create_user('fake1', user1)
self.identity_api.create_user('fake2', user2)
user2['name'] = 'fake1'
- self.assertRaises(exception.Error,
+ self.assertRaises(exception.Conflict,
self.identity_api.update_user,
'fake2',
user2)
- def test_update_user_id_does_nothing(self):
+ def test_update_user_id_fails(self):
user = {'id': 'fake1',
'name': 'fake1',
'password': 'fakepass',
'tenants': ['bar']}
self.identity_api.create_user('fake1', user)
user['id'] = 'fake2'
- self.identity_api.update_user('fake1', user)
+ self.assertRaises(exception.ValidationError,
+ self.identity_api.update_user,
+ 'fake1',
+ user)
user_ref = self.identity_api.get_user('fake1')
self.assertEqual(user_ref['id'], 'fake1')
- user_ref = self.identity_api.get_user('fake2')
- self.assert_(user_ref is None)
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_user,
+ 'fake2')
def test_create_duplicate_tenant_id_fails(self):
tenant = {'id': 'fake1', 'name': 'fake1'}
@@ -265,8 +284,9 @@ class IdentityTests(object):
self.identity_api.update_tenant('fake1', tenant)
tenant_ref = self.identity_api.get_tenant('fake1')
self.assertEqual(tenant_ref['id'], 'fake1')
- tenant_ref = self.identity_api.get_tenant('fake2')
- self.assert_(tenant_ref is None)
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant,
+ 'fake2')
def test_get_role_by_user_and_tenant(self):
roles_ref = self.identity_api.get_roles_for_user_and_tenant(
@@ -286,22 +306,160 @@ class IdentityTests(object):
self.assertIn('keystone_admin', roles_ref)
self.assertIn('useless', roles_ref)
- def test_delete_role(self):
- role_id = 'test_role_delete'
- new_role = {'id': role_id, 'name': 'Role to Delete'}
- self.identity_api.create_role(role_id, new_role)
- role_ref = self.identity_api.get_role(role_id)
+ def test_get_roles_for_user_and_tenant_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_roles_for_user_and_tenant,
+ uuid.uuid4().hex,
+ self.tenant_bar['id'])
+
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_roles_for_user_and_tenant,
+ self.user_foo['id'],
+ uuid.uuid4().hex)
+
+ def test_add_role_to_user_and_tenant_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.add_role_to_user_and_tenant,
+ uuid.uuid4().hex,
+ self.tenant_bar['id'],
+ 'keystone_admin')
+
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.add_role_to_user_and_tenant,
+ self.user_foo['id'],
+ uuid.uuid4().hex,
+ 'keystone_admin')
+
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.add_role_to_user_and_tenant,
+ self.user_foo['id'],
+ self.tenant_bar['id'],
+ uuid.uuid4().hex)
+
+ def test_remove_role_from_user_and_tenant(self):
+ self.identity_api.add_role_to_user_and_tenant(
+ self.user_foo['id'], self.tenant_bar['id'], 'useless')
+ self.identity_api.remove_role_from_user_and_tenant(
+ self.user_foo['id'], self.tenant_bar['id'], 'useless')
+ roles_ref = self.identity_api.get_roles_for_user_and_tenant(
+ self.user_foo['id'], self.tenant_bar['id'])
+ self.assertNotIn('useless', roles_ref)
+ self.assertRaises(exception.NotFound,
+ self.identity_api.remove_role_from_user_and_tenant,
+ self.user_foo['id'],
+ self.tenant_bar['id'],
+ 'useless')
+
+ def test_role_crud(self):
+ role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
+ self.identity_api.create_role(role['id'], role)
+ role_ref = self.identity_api.get_role(role['id'])
role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
- self.assertDictEqual(role_ref_dict, new_role)
- self.identity_api.delete_role(role_id)
- role_ref = self.identity_api.get_role(role_id)
- self.assertIsNone(role_ref)
+ self.assertDictEqual(role_ref_dict, role)
+
+ role['name'] = uuid.uuid4().hex
+ self.identity_api.update_role(role['id'], role)
+ role_ref = self.identity_api.get_role(role['id'])
+ role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
+ self.assertDictEqual(role_ref_dict, role)
+
+ self.identity_api.delete_role(role['id'])
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.get_role,
+ role['id'])
+
+ def test_update_role_404(self):
+ role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.update_role,
+ role['id'],
+ role)
def test_add_user_to_tenant(self):
- tenant_id = 'tenent4add'
- self.identity_api.add_user_to_tenant(tenant_id, 'foo')
- tenants = self.identity_api.get_tenants_for_user('foo')
- self.assertIn(tenant_id, tenants)
+ self.identity_api.add_user_to_tenant(self.tenant_bar['id'],
+ self.user_foo['id'])
+ tenants = self.identity_api.get_tenants_for_user(self.user_foo['id'])
+ self.assertIn(self.tenant_bar['id'], tenants)
+
+ def test_add_user_to_tenant_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.add_user_to_tenant,
+ uuid.uuid4().hex,
+ self.user_foo['id'])
+
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.add_user_to_tenant,
+ self.tenant_bar['id'],
+ uuid.uuid4().hex)
+
+ def test_remove_user_from_tenant(self):
+ self.identity_api.add_user_to_tenant(self.tenant_bar['id'],
+ self.user_foo['id'])
+ self.identity_api.remove_user_from_tenant(self.tenant_bar['id'],
+ self.user_foo['id'])
+ tenants = self.identity_api.get_tenants_for_user(self.user_foo['id'])
+ self.assertNotIn(self.tenant_bar['id'], tenants)
+
+ def test_remove_user_from_tenant_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.remove_user_from_tenant,
+ uuid.uuid4().hex,
+ self.user_foo['id'])
+
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.remove_user_from_tenant,
+ self.tenant_bar['id'],
+ uuid.uuid4().hex)
+
+ self.assertRaises(exception.NotFound,
+ self.identity_api.remove_user_from_tenant,
+ self.tenant_baz['id'],
+ self.user_foo['id'])
+
+ def test_get_tenants_for_user_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_tenants_for_user,
+ uuid.uuid4().hex)
+
+ def test_update_tenant_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.update_tenant,
+ uuid.uuid4().hex,
+ dict())
+
+ def test_delete_tenant_404(self):
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.delete_tenant,
+ uuid.uuid4().hex)
+
+ def test_update_user_404(self):
+ user_id = uuid.uuid4().hex
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.update_user,
+ user_id,
+ {'id': user_id})
+
+ def test_delete_user_with_tenant_association(self):
+ user = {'id': uuid.uuid4().hex,
+ 'name': uuid.uuid4().hex,
+ 'password': uuid.uuid4().hex}
+ self.identity_api.create_user(user['id'], user)
+ self.identity_api.add_user_to_tenant(self.tenant_bar['id'],
+ user['id'])
+ self.identity_api.delete_user(user['id'])
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_tenants_for_user,
+ user['id'])
+
+ def test_delete_user_404(self):
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.delete_user,
+ uuid.uuid4().hex)
+
+ def test_delete_role_404(self):
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.delete_role,
+ uuid.uuid4().hex)
def test_create_tenant_long_name_fails(self):
tenant = {'id': 'fake1', 'name': 'a' * 65}
@@ -379,9 +537,19 @@ class TokenTests(object):
self.token_api.delete_token(token_id)
self.assertRaises(exception.TokenNotFound,
+ self.token_api.get_token, token_id)
+ self.assertRaises(exception.TokenNotFound,
self.token_api.delete_token, token_id)
+
+ def test_get_token_404(self):
self.assertRaises(exception.TokenNotFound,
- self.token_api.get_token, token_id)
+ self.token_api.get_token,
+ uuid.uuid4().hex)
+
+ def test_delete_token_404(self):
+ self.assertRaises(exception.TokenNotFound,
+ self.token_api.delete_token,
+ uuid.uuid4().hex)
def test_expired_token(self):
token_id = uuid.uuid4().hex
@@ -403,7 +571,6 @@ class TokenTests(object):
class CatalogTests(object):
-
def test_service_crud(self):
new_service = {'id': 'MY_SERVICE', 'type': 'myservice',
'name': 'My Service', 'description': 'My description'}
@@ -413,9 +580,41 @@ class CatalogTests(object):
service_id = new_service['id']
self.catalog_api.delete_service(service_id)
self.assertRaises(exception.ServiceNotFound,
- self.catalog_api.delete_service, service_id)
+ self.catalog_man.delete_service, {}, service_id)
+ self.assertRaises(exception.ServiceNotFound,
+ self.catalog_man.get_service, {}, service_id)
+
+ def test_get_service_404(self):
+ self.assertRaises(exception.ServiceNotFound,
+ self.catalog_man.get_service,
+ {},
+ uuid.uuid4().hex)
+
+ def test_delete_service_404(self):
+ self.assertRaises(exception.ServiceNotFound,
+ self.catalog_man.delete_service,
+ {},
+ uuid.uuid4().hex)
+
+ def test_create_endpoint_404(self):
+ endpoint = {
+ 'id': uuid.uuid4().hex,
+ 'service_id': uuid.uuid4().hex,
+ }
self.assertRaises(exception.ServiceNotFound,
- self.catalog_api.get_service, service_id)
+ self.catalog_api.create_endpoint,
+ endpoint['id'],
+ endpoint)
+
+ def test_get_endpoint_404(self):
+ self.assertRaises(exception.EndpointNotFound,
+ self.catalog_api.get_endpoint,
+ uuid.uuid4().hex)
+
+ def test_delete_endpoint_404(self):
+ self.assertRaises(exception.EndpointNotFound,
+ self.catalog_api.delete_endpoint,
+ uuid.uuid4().hex)
def test_service_list(self):
services = self.catalog_api.list_services()
diff --git a/tests/test_backend_kvs.py b/tests/test_backend_kvs.py
index 695fcd54..f7edfab1 100644
--- a/tests/test_backend_kvs.py
+++ b/tests/test_backend_kvs.py
@@ -13,11 +13,14 @@
# 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 uuid
+from keystone import exception
from keystone import test
from keystone.identity.backends import kvs as identity_kvs
from keystone.token.backends import kvs as token_kvs
from keystone.catalog.backends import kvs as catalog_kvs
+from keystone import catalog
import test_backend
import default_fixtures
@@ -40,6 +43,7 @@ class KvsCatalog(test.TestCase, test_backend.CatalogTests):
def setUp(self):
super(KvsCatalog, self).setUp()
self.catalog_api = catalog_kvs.Catalog(db={})
+ self.catalog_man = catalog.Manager()
self.load_fixtures(default_fixtures)
self._load_fake_catalog()
@@ -48,14 +52,35 @@ class KvsCatalog(test.TestCase, test_backend.CatalogTests):
'foo', 'bar',
{'RegionFoo': {'service_bar': {'foo': 'bar'}}})
- def test_get_catalog_bad_user(self):
- catalog_ref = self.catalog_api.get_catalog('foo' + 'WRONG', 'bar')
- self.assert_(catalog_ref is None)
+ def test_get_catalog_404(self):
+ # FIXME(dolph): this test should be moved up to test_backend
+ # FIXME(dolph): exceptions should be UserNotFound and TenantNotFound
+ self.assertRaises(exception.NotFound,
+ self.catalog_api.get_catalog,
+ uuid.uuid4().hex,
+ 'bar')
- def test_get_catalog_bad_tenant(self):
- catalog_ref = self.catalog_api.get_catalog('foo', 'bar' + 'WRONG')
- self.assert_(catalog_ref is None)
+ self.assertRaises(exception.NotFound,
+ self.catalog_api.get_catalog,
+ 'foo',
+ uuid.uuid4().hex)
def test_get_catalog(self):
catalog_ref = self.catalog_api.get_catalog('foo', 'bar')
self.assertDictEqual(catalog_ref, self.catalog_foobar)
+
+ def test_create_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.create_endpoint,
+ uuid.uuid4().hex,
+ {})
+
+ def test_get_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.get_endpoint,
+ uuid.uuid4().hex)
+
+ def test_delete_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.delete_endpoint,
+ uuid.uuid4().hex)
diff --git a/tests/test_backend_ldap.py b/tests/test_backend_ldap.py
index 56b2f5cf..2a230fde 100644
--- a/tests/test_backend_ldap.py
+++ b/tests/test_backend_ldap.py
@@ -14,7 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from keystone import config
+from keystone import exception
from keystone import test
from keystone.common.ldap import fakeldap
from keystone.identity.backends import ldap as identity_ldap
@@ -41,5 +44,94 @@ class LDAPIdentity(test.TestCase, test_backend.IdentityTests):
self.identity_api = identity_ldap.Identity()
self.load_fixtures(default_fixtures)
- def tearDown(self):
- test.TestCase.tearDown(self)
+ def test_delete_tenant_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.delete_tenant,
+ uuid.uuid4().hex)
+
+ def test_delete_user_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.delete_user,
+ uuid.uuid4().hex)
+
+ def test_rename_duplicate_role_name_fails(self):
+ role1 = {'id': 'fake1',
+ 'name': 'fake1name'}
+ role2 = {'id': 'fake2',
+ 'name': 'fake2name'}
+ self.identity_api.create_role('fake1', role1)
+ self.identity_api.create_role('fake2', role2)
+ role1['name'] = 'fake2name'
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.update_role,
+ 'fake1',
+ role1)
+
+ def test_rename_duplicate_user_name_fails(self):
+ user1 = {'id': 'fake1',
+ 'name': 'fake1',
+ 'password': 'fakepass',
+ 'tenants': ['bar']}
+ user2 = {'id': 'fake2',
+ 'name': 'fake2',
+ 'password': 'fakepass',
+ 'tenants': ['bar']}
+ self.identity_api.create_user('fake1', user1)
+ self.identity_api.create_user('fake2', user2)
+ user2['name'] = 'fake1'
+ self.assertRaises(exception.ValidationError,
+ self.identity_api.update_user,
+ 'fake2',
+ user2)
+
+ def test_delete_user_with_tenant_association(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.delete_user,
+ uuid.uuid4().hex)
+
+ def test_remove_user_from_tenant(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.remove_user_from_tenant,
+ self.tenant_bar['id'],
+ self.user_foo['id'])
+
+ def test_remove_user_from_tenant_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.remove_user_from_tenant,
+ self.tenant_bar['id'],
+ self.user_foo['id'])
+
+ def test_remove_role_from_user_and_tenant(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.remove_role_from_user_and_tenant,
+ self.tenant_bar['id'],
+ self.user_foo['id'],
+ 'useless')
+
+ def test_role_crud(self):
+ role = {'id': uuid.uuid4().hex, 'name': uuid.uuid4().hex}
+ self.identity_api.create_role(role['id'], role)
+ role_ref = self.identity_api.get_role(role['id'])
+ role_ref_dict = dict((x, role_ref[x]) for x in role_ref)
+ self.assertDictEqual(role_ref_dict, role)
+
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.update_role,
+ role['id'],
+ role)
+
+ self.identity_api.delete_role(role['id'])
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.get_role,
+ role['id'])
+
+ def test_update_role_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.update_role,
+ uuid.uuid4().hex,
+ {})
+
+ def test_get_tenant_users_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.identity_api.get_tenant_users,
+ tenant_id=uuid.uuid4().hex)
diff --git a/tests/test_backend_sql.py b/tests/test_backend_sql.py
index 3f7ea098..65555368 100644
--- a/tests/test_backend_sql.py
+++ b/tests/test_backend_sql.py
@@ -41,15 +41,16 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.load_fixtures(default_fixtures)
def test_delete_user_with_tenant_association(self):
- user = {'id': 'fake',
- 'name': 'fakeuser',
- 'password': 'passwd'}
- self.identity_api.create_user('fake', user)
+ user = {'id': uuid.uuid4().hex,
+ 'name': uuid.uuid4().hex,
+ 'password': uuid.uuid4().hex}
+ self.identity_api.create_user(user['id'], user)
self.identity_api.add_user_to_tenant(self.tenant_bar['id'],
user['id'])
self.identity_api.delete_user(user['id'])
- tenants = self.identity_api.get_tenants_for_user(user['id'])
- self.assertEquals(tenants, [])
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_tenants_for_user,
+ user['id'])
def test_create_null_user_name(self):
user = {'id': uuid.uuid4().hex,
@@ -59,13 +60,12 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.identity_api.create_user,
user['id'],
user)
- # TODO(dolph): can be uncommented pending bug 968519
- #self.assertRaises(exception.UserNotFound,
- # self.identity_api.get_user,
- # user['id'])
- #self.assertRaises(exception.UserNotFound,
- # self.identity_api.get_user_by_name,
- # user['name'])
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_user,
+ user['id'])
+ self.assertRaises(exception.UserNotFound,
+ self.identity_api.get_user_by_name,
+ user['name'])
def test_create_null_tenant_name(self):
tenant = {'id': uuid.uuid4().hex,
@@ -74,13 +74,12 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.identity_api.create_tenant,
tenant['id'],
tenant)
- # TODO(dolph): can be uncommented pending bug 968519
- #self.assertRaises(exception.TenantNotFound,
- # self.identity_api.get_tenant,
- # tenant['id'])
- #self.assertRaises(exception.TenantNotFound,
- # self.identity_api.get_tenant_by_name,
- # tenant['name'])
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant,
+ tenant['id'])
+ self.assertRaises(exception.TenantNotFound,
+ self.identity_api.get_tenant_by_name,
+ tenant['name'])
def test_create_null_role_name(self):
role = {'id': uuid.uuid4().hex,
@@ -89,10 +88,9 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.identity_api.create_role,
role['id'],
role)
- # TODO(dolph): can be uncommented pending bug 968519
- #self.assertRaises(exception.RoleNotFound,
- # self.identity_api.get_role,
- # role['id'])
+ self.assertRaises(exception.RoleNotFound,
+ self.identity_api.get_role,
+ role['id'])
def test_delete_tenant_with_user_association(self):
user = {'id': 'fake',
@@ -114,9 +112,10 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.tenant_bar['id'],
{'extra': 'extra'})
self.identity_api.delete_user(user['id'])
- metadata = self.identity_api.get_metadata(user['id'],
- self.tenant_bar['id'])
- self.assertEquals(metadata, {})
+ self.assertRaises(exception.MetadataNotFound,
+ self.identity_api.get_metadata,
+ user['id'],
+ self.tenant_bar['id'])
def test_delete_tenant_with_metadata(self):
user = {'id': 'fake',
@@ -127,9 +126,10 @@ class SqlIdentity(test.TestCase, test_backend.IdentityTests):
self.tenant_bar['id'],
{'extra': 'extra'})
self.identity_api.delete_tenant(self.tenant_bar['id'])
- metadata = self.identity_api.get_metadata(user['id'],
- self.tenant_bar['id'])
- self.assertEquals(metadata, {})
+ self.assertRaises(exception.MetadataNotFound,
+ self.identity_api.get_metadata,
+ user['id'],
+ self.tenant_bar['id'])
class SqlToken(test.TestCase, test_backend.TokenTests):
diff --git a/tests/test_backend_templated.py b/tests/test_backend_templated.py
index 735b68b7..819cfd73 100644
--- a/tests/test_backend_templated.py
+++ b/tests/test_backend_templated.py
@@ -15,9 +15,12 @@
# under the License.
import os
+import uuid
+from keystone import exception
from keystone import test
from keystone.catalog.backends import templated as catalog_templated
+from keystone import catalog
import test_backend
import default_fixtures
@@ -50,8 +53,25 @@ class TestTemplatedCatalog(test.TestCase, test_backend.CatalogTests):
super(TestTemplatedCatalog, self).setUp()
self.opt_in_group('catalog', template_file=DEFAULT_CATALOG_TEMPLATES)
self.catalog_api = catalog_templated.TemplatedCatalog()
+ self.catalog_man = catalog.Manager()
self.load_fixtures(default_fixtures)
def test_get_catalog(self):
catalog_ref = self.catalog_api.get_catalog('foo', 'bar')
self.assertDictEqual(catalog_ref, self.DEFAULT_FIXTURE)
+
+ def test_create_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.create_endpoint,
+ uuid.uuid4().hex,
+ {})
+
+ def test_get_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.get_endpoint,
+ uuid.uuid4().hex)
+
+ def test_delete_endpoint_404(self):
+ self.assertRaises(exception.NotImplemented,
+ self.catalog_api.delete_endpoint,
+ uuid.uuid4().hex)
diff --git a/tests/test_keystoneclient.py b/tests/test_keystoneclient.py
index dc26c959..8d3f2a4d 100644
--- a/tests/test_keystoneclient.py
+++ b/tests/test_keystoneclient.py
@@ -133,8 +133,9 @@ class KeystoneClientTests(object):
from keystoneclient import exceptions as client_exceptions
client = self.get_client()
token = client.auth_token
- self.assertRaises(client_exceptions.AuthorizationFailure,
- self._client, token=token, tenant_id='baz')
+ self.assertRaises(client_exceptions.Unauthorized,
+ self._client, token=token,
+ tenant_id=uuid.uuid4().hex)
def test_authenticate_token_tenant_name(self):
client = self.get_client()
@@ -284,15 +285,15 @@ class KeystoneClientTests(object):
self.assertRaises(client_exceptions.Unauthorized,
self._client,
username=self.user_foo['name'],
- password='invalid')
+ password=uuid.uuid4().hex)
- def test_invalid_user_password(self):
+ def test_invalid_user_and_password(self):
from keystoneclient import exceptions as client_exceptions
self.assertRaises(client_exceptions.Unauthorized,
self._client,
- username='blah',
- password='blah')
+ username=uuid.uuid4().hex,
+ password=uuid.uuid4().hex)
def test_change_password_invalidates_token(self):
from keystoneclient import exceptions as client_exceptions
@@ -674,17 +675,6 @@ class KeystoneClientTests(object):
client.services.get,
id=uuid.uuid4().hex)
- def test_endpoint_create_404(self):
- from keystoneclient import exceptions as client_exceptions
- client = self.get_client(admin=True)
- self.assertRaises(client_exceptions.NotFound,
- client.endpoints.create,
- region=uuid.uuid4().hex,
- service_id=uuid.uuid4().hex,
- publicurl=uuid.uuid4().hex,
- adminurl=uuid.uuid4().hex,
- internalurl=uuid.uuid4().hex)
-
def test_endpoint_delete_404(self):
# the catalog backend is expected to return Not Implemented
from keystoneclient import exceptions as client_exceptions
diff --git a/tests/test_keystoneclient_sql.py b/tests/test_keystoneclient_sql.py
index a70f7603..38a6cbfe 100644
--- a/tests/test_keystoneclient_sql.py
+++ b/tests/test_keystoneclient_sql.py
@@ -74,6 +74,17 @@ class KcMasterSqlTestCase(test_keystoneclient.KcMasterTestCase):
self.assertRaises(client_exceptions.NotFound, client.endpoints.delete,
id=endpoint.id)
+ def test_endpoint_create_404(self):
+ from keystoneclient import exceptions as client_exceptions
+ client = self.get_client(admin=True)
+ self.assertRaises(client_exceptions.NotFound,
+ client.endpoints.create,
+ region=uuid.uuid4().hex,
+ service_id=uuid.uuid4().hex,
+ publicurl=uuid.uuid4().hex,
+ adminurl=uuid.uuid4().hex,
+ internalurl=uuid.uuid4().hex)
+
def test_endpoint_delete_404(self):
from keystoneclient import exceptions as client_exceptions
client = self.get_client(admin=True)