Adding identity api v2.0 tests
Change-Id: I955392bd462957208a9b7ce58efa5da7e1a2db47
diff --git a/kong/keystone.py b/kong/keystone.py
new file mode 100644
index 0000000..cfd9e82
--- /dev/null
+++ b/kong/keystone.py
@@ -0,0 +1,34 @@
+import json
+
+import kong.common.http
+from kong import exceptions
+
+
+class API(kong.common.http.Client):
+ """Barebones Keystone HTTP API client."""
+
+ def __init__(self, service_host, service_port):
+ super(API, self).__init__(service_host, service_port, 'v2.0')
+
+ #TODO(bcwaldon): This is a hack, we should clean up the superclass
+ self.management_url = self.base_url
+
+ def get_token(self, user, password, tenant_id):
+ headers = {'content-type': 'application/json'}
+
+ body = {
+ "auth": {
+ "passwordCredentials":{
+ "username": user,
+ "password": password,
+ },
+ "tenantId": tenant_id,
+ },
+ }
+
+ response, content = self.request('POST', '/tokens',
+ headers=headers,
+ body=json.dumps(body))
+
+ res_body = json.loads(content)
+ return res_body['access']['token']['id']