Merge "Test for backend case sensitivity"

This commit is contained in:
Jenkins 2013-09-26 08:22:03 +00:00 committed by Gerrit Code Review
commit fa6f25898a
3 changed files with 66 additions and 0 deletions

View File

@ -1593,6 +1593,19 @@ class IdentityTests(object):
self.identity_api.delete_role,
uuid.uuid4().hex)
def test_create_project_case_sensitivity(self):
# create a ref with a lowercase name
ref = {
'id': uuid.uuid4().hex,
'name': uuid.uuid4().hex.lower(),
'domain_id': DEFAULT_DOMAIN_ID}
self.assignment_api.create_project(ref['id'], ref)
# assign a new ID with the same name, but this time in uppercase
ref['id'] = uuid.uuid4().hex
ref['name'] = ref['name'].upper()
self.assignment_api.create_project(ref['id'], ref)
def test_create_project_long_name_fails(self):
tenant = {'id': 'fake1', 'name': 'a' * 65,
'domain_id': DEFAULT_DOMAIN_ID}
@ -1659,6 +1672,19 @@ class IdentityTests(object):
tenant['id'],
tenant)
def test_create_user_case_sensitivity(self):
# create a ref with a lowercase name
ref = {
'id': uuid.uuid4().hex,
'name': uuid.uuid4().hex.lower(),
'domain_id': DEFAULT_DOMAIN_ID}
self.identity_api.create_user(ref['id'], ref)
# assign a new ID with the same name, but this time in uppercase
ref['id'] = uuid.uuid4().hex
ref['name'] = ref['name'].upper()
self.identity_api.create_user(ref['id'], ref)
def test_create_user_long_name_fails(self):
user = {'id': 'fake1', 'name': 'a' * 256,
'domain_id': DEFAULT_DOMAIN_ID}
@ -2318,6 +2344,18 @@ class IdentityTests(object):
self.identity_api.get_domain,
domain['id'])
def test_create_domain_case_sensitivity(self):
# create a ref with a lowercase name
ref = {
'id': uuid.uuid4().hex,
'name': uuid.uuid4().hex.lower()}
self.assignment_api.create_domain(ref['id'], ref)
# assign a new ID with the same name, but this time in uppercase
ref['id'] = uuid.uuid4().hex
ref['name'] = ref['name'].upper()
self.assignment_api.create_domain(ref['id'], ref)
def test_user_crud(self):
user = {'domain_id': CONF.identity.default_domain_id,
'id': uuid.uuid4().hex,

View File

@ -703,6 +703,16 @@ class LDAPIdentity(tests.TestCase, BaseLDAPIdentity):
self.identity_api.get_domain,
domain['id'])
def test_create_domain_case_sensitivity(self):
# domains are read-only, so case sensitivity isn't an issue
ref = {
'id': uuid.uuid4().hex,
'name': uuid.uuid4().hex}
self.assertRaises(exception.Forbidden,
self.assignment_api.create_domain,
ref['id'],
ref)
def test_cache_layer_domain_crud(self):
# TODO(morganfainberg): This also needs to be removed when full LDAP
# implementation is submitted. No need to duplicate the above test,

View File

@ -105,6 +105,24 @@ class IdentityTestCase(test_v3.RestfulTestCase):
body={'domain': ref})
return self.assertValidDomainResponse(r, ref)
def test_create_domain_case_sensitivity(self):
"""Call `POST /domains`` twice with upper() and lower() cased name."""
ref = self.new_domain_ref()
# ensure the name is lowercase
ref['name'] = ref['name'].lower()
r = self.post(
'/domains',
body={'domain': ref})
self.assertValidDomainResponse(r, ref)
# ensure the name is uppercase
ref['name'] = ref['name'].upper()
r = self.post(
'/domains',
body={'domain': ref})
self.assertValidDomainResponse(r, ref)
def test_create_domain_400(self):
"""Call ``POST /domains``."""
self.post('/domains', body={'domain': {}}, expected_status=400)