Skip to content

Commit

Permalink
Test for backend case sensitivity
Browse files Browse the repository at this point in the history
Partial-Bug: 1229093
Change-Id: I912f05de52842fa0e564764c440dd9621e05fcbc
  • Loading branch information
dolph committed Sep 23, 2013
1 parent bdac547 commit e33e6db
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
38 changes: 38 additions & 0 deletions keystone/tests/test_backend.py
Expand Up @@ -1566,6 +1566,19 @@ def test_delete_role_404(self):
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}
Expand Down Expand Up @@ -1632,6 +1645,19 @@ def test_update_project_invalid_name_fails(self):
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}
Expand Down Expand Up @@ -2258,6 +2284,18 @@ def test_domain_crud(self):
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,
Expand Down
10 changes: 10 additions & 0 deletions keystone/tests/test_backend_ldap.py
Expand Up @@ -700,6 +700,16 @@ def test_domain_crud(self):
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,
Expand Down
18 changes: 18 additions & 0 deletions keystone/tests/test_v3_identity.py
Expand Up @@ -103,6 +103,24 @@ def test_create_domain(self):
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)
Expand Down

0 comments on commit e33e6db

Please sign in to comment.