Skip to content

Commit

Permalink
Enhance tests for assignment create_grant when no user or group
Browse files Browse the repository at this point in the history
There were no tests that show the behavior of create_grant when
the user or group doesn't exist. Turns out the behavior is
different depending on the backend (sql vs kvs vs ldap).

Change-Id: I71c3e2b94aaa44e40c8a891b49cc2a9961cee16f
Related-Bug: #1239476
  • Loading branch information
Brant Knudson committed Oct 31, 2013
1 parent edcfe99 commit 065bd57
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
16 changes: 16 additions & 0 deletions keystone/tests/test_backend.py
Expand Up @@ -2705,6 +2705,22 @@ def test_updated_arbitrary_attributes_are_returned_from_update_user(self):

self.assertEqual(updated_user['arbitrary_attr'], new_attr_value)

def test_create_grant_no_user(self):
# If call create_grant with a user that doesn't exist, doesn't fail.
# The behavior is different depending on the backend, see bug #1239476.
self.assignment_api.create_grant(
self.role_other['id'],
user_id=uuid.uuid4().hex,
project_id=self.tenant_bar['id'])

def test_create_grant_no_group(self):
# If call create_grant with a group that doesn't exist, doesn't fail.
# The behavior is different depending on the backend, see bug #1239476.
self.assignment_api.create_grant(
self.role_other['id'],
group_id=uuid.uuid4().hex,
project_id=self.tenant_bar['id'])


class TokenTests(object):
def _create_token_id(self):
Expand Down
14 changes: 14 additions & 0 deletions keystone/tests/test_backend_kvs.py
Expand Up @@ -75,6 +75,20 @@ def test_delete_group_grant_no_group(self):
exception.GroupNotFound,
super(KvsIdentity, self).test_delete_group_grant_no_group)

def test_create_grant_no_user(self):
# If call create_grant on KVS backend with a user that doesn't exist,
# raises UserNotFound.
# The behavior is different depending on the backend, see bug #1239476.
self.assertRaises(exception.UserNotFound,
super(KvsIdentity, self).test_create_grant_no_user)

def test_create_grant_no_group(self):
# If call create_grant on KVS backend with a group that doesn't exist,
# raises GroupNotFound.
# The behavior is different depending on the backend, see bug #1239476.
self.assertRaises(exception.GroupNotFound,
super(KvsIdentity, self).test_create_grant_no_group)


class KvsToken(tests.TestCase, test_backend.TokenTests):
def setUp(self):
Expand Down
12 changes: 12 additions & 0 deletions keystone/tests/test_backend_ldap.py
Expand Up @@ -894,6 +894,18 @@ def test_list_projects_for_alternate_domain(self):
self.skipTest(
'N/A: LDAP does not support multiple domains')

def test_create_grant_no_user(self):
# The LDAP assignment backend doesn't implement create_grant.
self.assertRaises(
exception.NotImplemented,
super(BaseLDAPIdentity, self).test_create_grant_no_user)

def test_create_grant_no_group(self):
# The LDAP assignment backend doesn't implement create_grant.
self.assertRaises(
exception.NotImplemented,
super(BaseLDAPIdentity, self).test_create_grant_no_group)


class LDAPIdentityEnabledEmulation(LDAPIdentity):
def setUp(self):
Expand Down

0 comments on commit 065bd57

Please sign in to comment.