From 6a2786097505f55e698f5273106cc094d6aa8e19 Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Mon, 18 Dec 2017 19:01:37 +0100 Subject: Update the test directory structure Change-Id: I94a206632c1ace1b26e01cf8c8a7bc3e18dbdde4 --- .../moon_authz/tests/unit_python/api/__init__.py | 0 .../moon_authz/tests/unit_python/api/test_authz.py | 49 ---------------------- 2 files changed, 49 deletions(-) delete mode 100644 moonv4/moon_authz/tests/unit_python/api/__init__.py delete mode 100644 moonv4/moon_authz/tests/unit_python/api/test_authz.py (limited to 'moonv4/moon_authz/tests/unit_python/api') diff --git a/moonv4/moon_authz/tests/unit_python/api/__init__.py b/moonv4/moon_authz/tests/unit_python/api/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/moonv4/moon_authz/tests/unit_python/api/test_authz.py b/moonv4/moon_authz/tests/unit_python/api/test_authz.py deleted file mode 100644 index d092ce07..00000000 --- a/moonv4/moon_authz/tests/unit_python/api/test_authz.py +++ /dev/null @@ -1,49 +0,0 @@ -import json -import pickle - - -def get_data(data): - return pickle.loads(data) - - -def get_json(data): - return json.loads(data.decode("utf-8")) - - -def test_authz_true(context): - import moon_authz.server - from moon_utilities.security_functions import Context - from moon_utilities.cache import Cache - server = moon_authz.server.main() - client = server.app.test_client() - CACHE = Cache() - CACHE.update() - _context = Context(context, CACHE) - req = client.post("/authz", data=pickle.dumps(_context)) - assert req.status_code == 200 - data = get_data(req.data) - assert data - assert isinstance(data, Context) - policy_id = data.headers[0] - assert policy_id - assert "effect" in data.pdp_set[policy_id] - assert data.pdp_set[policy_id]['effect'] == "grant" - - -def test_user_not_allowed(context): - import moon_authz.server - from moon_utilities.security_functions import Context - from moon_utilities.cache import Cache - server = moon_authz.server.main() - client = server.app.test_client() - CACHE = Cache() - CACHE.update() - context['subject_name'] = "user_not_allowed" - _context = Context(context, CACHE) - req = client.post("/authz", data=pickle.dumps(_context)) - assert req.status_code == 400 - data = get_json(req.data) - assert data - assert isinstance(data, dict) - assert "message" in data - assert data["message"] == "Cannot find subject user_not_allowed" -- cgit 1.2.3-korg