diff options
author | 2017-12-14 16:42:24 +0000 | |
---|---|---|
committer | 2017-12-14 16:42:24 +0000 | |
commit | 40144450de989888ab6f0957dd455a2a32d70da7 (patch) | |
tree | 972f6716acee5684ae1f1c1c063aff751105c525 /moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py | |
parent | eba6e45dfe531102c0bb7c3f14778965abaef2aa (diff) | |
parent | b15b137b81bbdb7f6db0824dafdc62e27f5e562b (diff) |
Merge "Add unittests for moon_wrapper"
Diffstat (limited to 'moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py')
-rw-r--r-- | moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py b/moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py new file mode 100644 index 00000000..7e9a7421 --- /dev/null +++ b/moonv4/moon_wrapper/tests/unit_python/api/test_wrapper.py @@ -0,0 +1,28 @@ +import json + + +def get_json(data): + return json.loads(data.decode("utf-8")) + + +def test_authz_true(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_id'), + "user_id": context.get('subject_name') + } + authz_data = { + '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 + assert req.data + assert isinstance(req.data, bytes) + assert req.data == b"True" + |