aboutsummaryrefslogtreecommitdiffstats
path: root/keystone-moon/keystone/tests
diff options
context:
space:
mode:
authorasteroide <thomas.duval@orange.com>2016-04-25 11:25:28 +0200
committerasteroide <thomas.duval@orange.com>2016-04-25 11:25:28 +0200
commit8d291f5a3de6fdffea6144b4c0f5ed44411285f5 (patch)
treef9edcf68d61cbe2cf0eb9807403964cdbf9d3730 /keystone-moon/keystone/tests
parent8c6291c915bd9f806600642b188f2bbb5fc716bc (diff)
Add the /moon/auth/tokens API
Change-Id: I4c0dd7c0e3f4dcae8d122c466cf93ac28d7c37f6
Diffstat (limited to 'keystone-moon/keystone/tests')
-rw-r--r--keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py b/keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py
new file mode 100644
index 00000000..56132609
--- /dev/null
+++ b/keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py
@@ -0,0 +1,48 @@
+# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
+# This software is distributed under the terms and conditions of the 'Apache-2.0'
+# license which can be found in the file 'LICENSE' in this package distribution
+# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+
+import unittest
+import json
+import requests
+
+
+class AuthTest(unittest.TestCase):
+
+ def setUp(self):
+ self.data_auth = {
+ "username": "",
+ "password": ""
+ }
+
+ def tearDown(self):
+ pass
+
+ def test_authz(self):
+ self.data_auth['username'] = 'admin'
+ self.data_auth['password'] = ''
+ req = requests.post("http://localhost:5000/moon/auth/tokens",
+ json=self.data_auth,
+ headers={"Content-Type": "application/json"}
+ )
+ self.assertIn(req.status_code, (200, 201))
+ result = req.json()
+ self.assertIn("token", result.keys())
+ self.assertEqual(result["token"], None)
+
+ self.data_auth['username'] = 'admin'
+ self.data_auth['password'] = 'nomoresecrete'
+ req = requests.post("http://localhost:5000/moon/auth/tokens",
+ json=self.data_auth,
+ headers={"Content-Type": "application/json"}
+ )
+ self.assertIn(req.status_code, (200, 201))
+ result = req.json()
+ self.assertIn("token", result.keys())
+ self.assertNotEqual(result["token"], None)
+
+if __name__ == "__main__":
+ unittest.main()
+
+