diff options
author | WuKong <rebirthmonkey@gmail.com> | 2017-12-23 21:49:35 +0100 |
---|---|---|
committer | WuKong <rebirthmonkey@gmail.com> | 2017-12-23 21:49:58 +0100 |
commit | 1100c66ce03a059ebe7ece9734e799b49b3a5a9e (patch) | |
tree | a057e7e7511f6675a9327b79e6919f07c5f89f07 /moonv4/moon_authz/tests/unit_python/test_authz.py | |
parent | 7a4dfdde6314476ae2a1a1c881ff1e3c430f790e (diff) |
moonv4 cleanup
Change-Id: Icef927f3236d985ac13ff7376f6ce6314b2b39b0
Signed-off-by: WuKong <rebirthmonkey@gmail.com>
Diffstat (limited to 'moonv4/moon_authz/tests/unit_python/test_authz.py')
-rw-r--r-- | moonv4/moon_authz/tests/unit_python/test_authz.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/moonv4/moon_authz/tests/unit_python/test_authz.py b/moonv4/moon_authz/tests/unit_python/test_authz.py deleted file mode 100644 index f98abebc..00000000 --- a/moonv4/moon_authz/tests/unit_python/test_authz.py +++ /dev/null @@ -1,50 +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 python_moonutilities.security_functions import Context - from python_moonutilities.cache import Cache - server = moon_authz.server.main() - client = server.app.test_client() - CACHE = Cache() - CACHE.update() - print(CACHE.pdp) - _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 python_moonutilities.security_functions import Context - from python_moonutilities.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" |