Skip to content

Commit

Permalink
Make apiKeyCreds fail like it does in PROD.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokunbo committed Feb 13, 2015
1 parent fca4a25 commit 8a571d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 8 additions & 4 deletions mimic/rest/auth_api.py
Expand Up @@ -130,12 +130,16 @@ def rax_kskey_apikeycredentials(self, request, user_id):
"""
Support, such as it is, for the apiKeysCredentials call.
"""
username = "mimic_userid_"+user_id
username = None
if user_id in self.core.sessions._userid_to_session:
username = self.core.sessions._userid_to_session[user_id].username.decode('ascii')
apikey = '7fc56270e7a70fa81a5935b72eacbe29' # echo -n A | md5sum
return json.dumps({'RAX-KSKEY:apiKeyCredentials': {'username': username,
'apiKey': apikey}})
apikey = '7fc56270e7a70fa81a5935b72eacbe29' # echo -n A | md5sum
return json.dumps({'RAX-KSKEY:apiKeyCredentials': {'username': username,
'apiKey': apikey}})
else:
request.setResponseCode(404)
return json.dumps({'itemNotFound':
{'code': 404, 'message': 'User '+user_id+' not found'}})

@app.route('/v2.0/RAX-AUTH/impersonation-tokens', methods=['POST'])
def get_impersonation_token(self, request):
Expand Down
5 changes: 2 additions & 3 deletions mimic/test/test_auth.py
Expand Up @@ -635,9 +635,8 @@ def test_rax_kskey_apikeycredentials(self):
self, root, "GET",
"/identity/v2.0/users/1/OS-KSADM/credentials/RAX-KSKEY:apiKeyCredentials"
))
self.assertEqual(response.code, 200)
self.assertEqual(json_body['RAX-KSKEY:apiKeyCredentials']['username'],
'mimic_userid_1')
self.assertEqual(response.code, 404)
self.assertEqual(json_body['itemNotFound']['message'], 'User 1 not found')
creds = {
"auth": {
"passwordCredentials": {
Expand Down

0 comments on commit 8a571d6

Please sign in to comment.