Skip to content

Commit

Permalink
Adding RAX-KSKEY:apiKeyCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokunbo committed Feb 6, 2015
1 parent 0dc8f4b commit be8c8e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mimic/rest/auth_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ def get_username(self, request, tenant_id):
session = self.core.sessions.session_for_tenant_id(tenant_id)
return json.dumps(dict(user=dict(id=session.username)))

@app.route('/v2.0/users/<string:userid>/OS-KSADM/credentials/RAX-KSKEY:apiKeyCredentials',
methods=['GET'])
def rax_kskey_apikeycredentials(self, request, userid):
"""
Support, such as it is, for the apiKeysCredentials call.
"""
apikey = '1337133713371337133713371337'
username = 'mimicuser'
return json.dumps({'RAX-KSKEY:apiKeyCredentials': {'username': username,
'apiKey': apikey}})

@app.route('/v2.0/RAX-AUTH/impersonation-tokens', methods=['POST'])
def get_impersonation_token(self, request):
"""
Expand Down
14 changes: 14 additions & 0 deletions mimic/test/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,20 @@ def test_token_and_catalog_for_password_credentials_wrong_tenant(self):
}
})

def test_rax_kskey_apikeycredentials(self):
"""
Test apiKeyCredentials
"""
core = MimicCore(Clock(), [ExampleAPI()])
root = MimicRoot(core).app.resource()
(response, json_body) = self.successResultOf(json_request(
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'],
'mimicuser')

def test_token_and_catalog_for_api_credentials_wrong_tenant(self):
"""
Tenant ID is validated when provided in api-key auth.
Expand Down

0 comments on commit be8c8e5

Please sign in to comment.