diff options
author | 2018-01-08 14:45:28 +0200 | |
---|---|---|
committer | 2018-01-10 14:12:13 +0200 | |
commit | 7775dccb613b99eca11ef93b8e8317820b023aa3 (patch) | |
tree | 9488437a33f040dc9a4c61299f07177c2f4f2049 /moon_wrapper/tests/unit_python/api | |
parent | 646e77e86cd220f4be02110b16ce802d85c35b27 (diff) |
test case issue
adding more test cases, comments
Change-Id: I8a2c60dc8095f12d4469fef8549b18a7824086af
Signed-off-by: sgdt6900 <rhanafy.ext@orange.com>
Diffstat (limited to 'moon_wrapper/tests/unit_python/api')
-rw-r--r-- | moon_wrapper/tests/unit_python/api/test_wrapper.py | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/moon_wrapper/tests/unit_python/api/test_wrapper.py b/moon_wrapper/tests/unit_python/api/test_wrapper.py index 7e9a7421..be3e8576 100644 --- a/moon_wrapper/tests/unit_python/api/test_wrapper.py +++ b/moon_wrapper/tests/unit_python/api/test_wrapper.py @@ -1,3 +1,8 @@ +# 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 json @@ -20,9 +25,47 @@ def test_authz_true(context): 'rule': context.get('action_name'), 'target': json.dumps(_target), 'credentials': 'null'} - req = client.post("/authz", data=json.dumps(authz_data)) - assert req.status_code == 200 + req = client.post("/authz/oslo", data=json.dumps(authz_data)) + assert req.status_code is 200 assert req.data assert isinstance(req.data, bytes) assert req.data == b"True" +def test_authz_error_response_code(context): + import moon_wrapper.server + server = moon_wrapper.server.main() + client = server.app.test_client() + _target = { + 'target': { + "name": context.get('object_name'), + }, + "project_id": context.get('invalid_project_id'), + "user_id": context.get('subject_name') + } + authz_data = { + 'rule': context.get('action_name'), + 'target': json.dumps(_target), + 'credentials': 'null'} + req = client.post("/authz/oslo", data=json.dumps(authz_data)) + assert req.status_code is 200 + assert req.data + assert isinstance(req.data, bytes) + assert req.data == b"False" + +def test_authz_error_no_interface_key(context): + import moon_wrapper.server + server = moon_wrapper.server.main() + client = server.app.test_client() + _target = { + 'target': { + "name": context.get('object_name'), + }, + "project_id": context.get('project_with_no_interface_key'), + "user_id": context.get('subject_name') + } + authz_data = { + 'rule': context.get('action_name'), + 'target': json.dumps(_target), + 'credentials': 'null'} + req = client.post("/authz/oslo", data=json.dumps(authz_data)) + assert req.status_code == 403
\ No newline at end of file |