diff options
author | ReemMahmoud <rfawzy.ext@orange.com> | 2018-01-08 15:58:01 +0200 |
---|---|---|
committer | ReemMahmoud <rfawzy.ext@orange.com> | 2018-01-08 15:58:01 +0200 |
commit | 272ad1b600710f06285a5da8803369cb3a6fa744 (patch) | |
tree | 1a149764b6db6e5057f1a62582dc7480e6ebbe78 /moon_authz/tests/unit_python | |
parent | 48857b80be18bb0985aab643f5c8c899194d636b (diff) |
Add tests to test_authz
Change-Id: I8d0aef33ec8f78d69d30e56c80c56d8aa655f586
Signed-off-by: ReemMahmoud <rfawzy.ext@orange.com>
Diffstat (limited to 'moon_authz/tests/unit_python')
-rw-r--r-- | moon_authz/tests/unit_python/test_authz.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/moon_authz/tests/unit_python/test_authz.py b/moon_authz/tests/unit_python/test_authz.py index 50493c9f..cf37cfdf 100644 --- a/moon_authz/tests/unit_python/test_authz.py +++ b/moon_authz/tests/unit_python/test_authz.py @@ -48,3 +48,44 @@ def test_user_not_allowed(context): assert isinstance(data, dict) assert "message" in data assert data["message"] == "Cannot find subject user_not_allowed" + + +def test_object_not_allowed(context): + import moon_authz.server + from python_moonutilities.context import Context + from python_moonutilities.cache import Cache + server = moon_authz.server.create_server() + client = server.app.test_client() + CACHE = Cache() + CACHE.update() + context['subject_name'] = "testuser" + context['object_name'] = "invalid" + _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 object invalid" + + +def test_action_not_allowed(context): + import moon_authz.server + from python_moonutilities.context import Context + from python_moonutilities.cache import Cache + server = moon_authz.server.create_server() + client = server.app.test_client() + CACHE = Cache() + CACHE.update() + context['subject_name'] = "testuser" + context['object_name'] = "vm1" + context['action_name'] = "invalid" + _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 action invalid" |