From 8d291f5a3de6fdffea6144b4c0f5ed44411285f5 Mon Sep 17 00:00:00 2001 From: asteroide Date: Mon, 25 Apr 2016 11:25:28 +0200 Subject: Add the /moon/auth/tokens API Change-Id: I4c0dd7c0e3f4dcae8d122c466cf93ac28d7c37f6 --- .../tests/moon/func/test_func_moon_auth.py | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 keystone-moon/keystone/tests/moon/func/test_func_moon_auth.py (limited to 'keystone-moon/keystone/tests') 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() + + -- cgit 1.2.3-korg