diff options
Diffstat (limited to 'keystone-moon/keystone/tests')
-rw-r--r-- | keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py | 48 |
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() + + |