aboutsummaryrefslogtreecommitdiffstats
path: root/moon_interface/tests/unit_python/api/test_authz.py
diff options
context:
space:
mode:
authorThomas Duval <thomas.duval@orange.com>2020-06-03 10:06:52 +0200
committerThomas Duval <thomas.duval@orange.com>2020-06-03 10:06:52 +0200
commit7bb53c64da2dcf88894bfd31503accdd81498f3d (patch)
tree4310e12366818af27947b5e2c80cb162da93a4b5 /moon_interface/tests/unit_python/api/test_authz.py
parentcbea4e360e9bfaa9698cf7c61c83c96a1ba89b8c (diff)
Update to new version 5.4HEADstable/jermamaster
Signed-off-by: Thomas Duval <thomas.duval@orange.com> Change-Id: Idcd868133d75928a1ffd74d749ce98503e0555ea
Diffstat (limited to 'moon_interface/tests/unit_python/api/test_authz.py')
-rw-r--r--moon_interface/tests/unit_python/api/test_authz.py83
1 files changed, 0 insertions, 83 deletions
diff --git a/moon_interface/tests/unit_python/api/test_authz.py b/moon_interface/tests/unit_python/api/test_authz.py
deleted file mode 100644
index a227a303..00000000
--- a/moon_interface/tests/unit_python/api/test_authz.py
+++ /dev/null
@@ -1,83 +0,0 @@
-import json
-import conftest
-
-
-def get_json(data):
- return json.loads(data.decode("utf-8"))
-
-
-def test_authz_true(context):
-
- import moon_interface.server
- server = moon_interface.server.create_server()
- client = server.app.test_client()
- req = client.get("/authz/{p_id}/{s_id}/{o_id}/{a_id}".format(
- p_id=context["pdp_id"],
- s_id=context["subject_name"],
- o_id=context["object_name"],
- a_id=context["action_name"],
- ))
- assert req.status_code == 200
- data = get_json(req.data)
- assert data
- assert "result" in data
- assert data['result'] is True
-
-
-def test_authz_false(context):
- import moon_interface.server
- server = moon_interface.server.create_server()
- client = server.app.test_client()
-
- req = client.get("/authz/{p_id}/{s_id}/{o_id}/{a_id}".format(
- p_id=None,
- s_id=context["subject_name"],
- o_id=context["object_name"],
- a_id=context["action_name"],
- ))
- assert req.status_code == 403
- data = get_json(req.data)
- assert data
- assert "result" in data
- assert data['result'] is False
-
-
-def test_authz_effect_unset(context, set_consul_and_db):
- import moon_interface.server
- server = moon_interface.server.create_server()
- client = server.app.test_client()
-
- set_consul_and_db.register_uri(
- 'POST', 'http://127.0.0.1:8081/authz',
- content=conftest.get_pickled_context_invalid()
- )
-
- req = client.get("/authz/{p_id}/{s_id}/{o_id}/{a_id}".format(
- p_id=context["pdp_id"],
- s_id=context["subject_name"],
- o_id=context["object_name"],
- a_id=context["action_name"],
- ))
- assert req.status_code == 401
- data = get_json(req.data)
- assert data
- assert "result" in data
- assert data['result'] is False
-
-
-def test_authz_invalid_ip(context, set_consul_and_db):
- import moon_interface.server
- server = moon_interface.server.create_server()
- client = server.app.test_client()
-
- set_consul_and_db.register_uri(
- 'POST', 'http://127.0.0.1:8081/authz', status_code=500
- )
-
- req = client.get("/authz/{p_id}/{s_id}/{o_id}/{a_id}".format(
- p_id=context["pdp_id"],
- s_id=context["subject_name"],
- o_id=context["object_name"],
- a_id=context["action_name"],
- ))
- assert req.status_code == 403