aboutsummaryrefslogtreecommitdiffstats
path: root/moon_authz/tests
diff options
context:
space:
mode:
authorReemMahmoud <rfawzy.ext@orange.com>2018-01-09 12:34:35 +0200
committerReemMahmoud <rfawzy.ext@orange.com>2018-01-09 12:35:48 +0200
commitdc368bed1ff75f19553046570e1fad2990177783 (patch)
tree4b1d373a0756895bf6aea3d2a9803768e25acce9 /moon_authz/tests
parent36cff999e58711a32efef8daff540b09e67554af (diff)
Add test in moon_authz
Change-Id: Ie423ac92866a6abd49cad2741a96809361660e20 Signed-off-by: ReemMahmoud <rfawzy.ext@orange.com>
Diffstat (limited to 'moon_authz/tests')
-rw-r--r--moon_authz/tests/unit_python/test_authz.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/moon_authz/tests/unit_python/test_authz.py b/moon_authz/tests/unit_python/test_authz.py
index cf37cfdf..2352fe06 100644
--- a/moon_authz/tests/unit_python/test_authz.py
+++ b/moon_authz/tests/unit_python/test_authz.py
@@ -1,5 +1,6 @@
import json
import pickle
+import pytest
def get_data(data):
@@ -10,6 +11,13 @@ def get_json(data):
return json.loads(data.decode("utf-8"))
+def run(component_data, cache, context):
+ from moon_authz.api.authorization import Authz
+ authz = Authz(component_data=component_data, cache=cache)
+ authz.context = context
+ authz.run()
+
+
def test_authz_true(context):
import moon_authz.server
from python_moonutilities.context import Context
@@ -89,3 +97,20 @@ def test_action_not_allowed(context):
assert isinstance(data, dict)
assert "message" in data
assert data["message"] == "Cannot find action invalid"
+
+
+def test_authz_with_empty_pdp_set(context):
+ from python_moonutilities.context import Context
+ from python_moonutilities.cache import Cache
+ CACHE = Cache()
+ CACHE.update()
+ _context = Context(context, CACHE)
+ component_data = {
+ 'component_id': 'component_id1',
+ 'pdp_id': 'pdp_id1',
+ 'meta_rule_id': 'meta_rule_id1',
+ 'keystone_project_id': 'keystone_project_id1',
+ }
+ with pytest.raises(Exception) as exception_info:
+ run(component_data, CACHE, _context)
+ assert str(exception_info.value) == '400: Pdp Unknown'