Fix Upstream test cases to be case insensitive

In any domain, due to case sensitivity, if a username
for the project and the username in tempest.conf or
accounts.yaml are not identical, then the test cases
are failing.

So, added .lower() method to change the username strings
to be case insensitive.

Closes-Bug: #1836618

Change-Id: Id7d079c881bbfae972d65ef6049f78da7f25fc1d
This commit is contained in:
manasa 2019-07-12 13:29:39 -04:00 committed by manasareddybethi
parent 0a0f5c6e0b
commit 4776b13bab
1 changed files with 27 additions and 4 deletions

View File

@ -43,7 +43,15 @@ class TokensV3Test(base.BaseIdentityV3Test):
self.assertEqual(authenticated_token, token_body)
# test to see if token has been properly authenticated
self.assertEqual(authenticated_token['user']['id'], user_id)
self.assertEqual(authenticated_token['user']['name'], username)
# NOTE: resource name that are case-sensitive in keystone
# depends on backends such as MySQL or LDAP which are
# case-insensitive, case-preserving. Resource name is
# returned as it is stored in the backend, not as it is
# requested. Verifying the username with both lower-case to
# avoid failure on different backends
self.assertEqual(
authenticated_token['user']['name'].lower(), username.lower())
self.non_admin_client.delete_token(subject_token)
self.assertRaises(
lib_exc.NotFound, self.non_admin_client.show_token, subject_token)
@ -84,10 +92,17 @@ class TokensV3Test(base.BaseIdentityV3Test):
self.assertIsNotNone(subject_id, 'Expected user ID in token.')
subject_name = resp['user']['name']
if username:
self.assertEqual(subject_name, username)
# NOTE: resource name that are case-sensitive in keystone
# depends on backends such as MySQL or LDAP which are
# case-insensitive, case-preserving. Resource name is
# returned as it is stored in the backend, not as it is
# requested. Verifying the username with both lower-case to
# avoid failure on different backends
self.assertEqual(subject_name.lower(), username.lower())
else:
# Expect a user name, but don't know what it will be.
# Expect a user name, but don't know what it will be
self.assertIsNotNone(subject_name, 'Expected user name in token.')
self.assertEqual(resp['methods'][0], 'password')
@ -110,7 +125,15 @@ class TokensV3Test(base.BaseIdentityV3Test):
subject_token)['token']
self.assertEqual(resp['x-subject-token'], subject_token)
self.assertEqual(token_details['user']['id'], user.user_id)
self.assertEqual(token_details['user']['name'], user.username)
# NOTE: resource name that are case-sensitive in keystone
# depends on backends such as MySQL or LDAP which are
# case-insensitive, case-preserving. Resource name is
# returned as it is stored in the backend, not as it is
# requested. Verifying the username with both lower-case to
# avoid failure on different backends
self.assertEqual(
token_details['user']['name'].lower(),
user.username.lower())
# Perform Delete Token
self.non_admin_client.delete_token(subject_token)
self.assertRaises(lib_exc.NotFound,