aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_interface/tests/apitests
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4/moon_interface/tests/apitests')
-rw-r--r--moonv4/moon_interface/tests/apitests/test_policies.py3
-rw-r--r--moonv4/moon_interface/tests/apitests/utils/policies.py39
2 files changed, 42 insertions, 0 deletions
diff --git a/moonv4/moon_interface/tests/apitests/test_policies.py b/moonv4/moon_interface/tests/apitests/test_policies.py
index 310aad66..8f26d72d 100644
--- a/moonv4/moon_interface/tests/apitests/test_policies.py
+++ b/moonv4/moon_interface/tests/apitests/test_policies.py
@@ -55,6 +55,7 @@ def test_subject_data():
subject_data_id = add_subject_data(policy_id=policy_id, category_id=subject_cat_id)
check_subject_data(policy_id=policy_id, data_id=subject_data_id, category_id=subject_cat_id)
+ delete_subject_data(policy_id=policy_id, data_id=subject_data_id, category_id=subject_cat_id)
def test_object_data():
@@ -69,6 +70,7 @@ def test_object_data():
object_data_id = add_object_data(policy_id=policy_id, category_id=object_cat_id)
check_object_data(policy_id=policy_id, data_id=object_data_id, category_id=object_cat_id)
+ delete_object_data(policy_id=policy_id, data_id=object_data_id, category_id=object_cat_id)
def test_action_data():
@@ -83,6 +85,7 @@ def test_action_data():
action_data_id = add_action_data(policy_id=policy_id, category_id=action_cat_id)
check_action_data(policy_id=policy_id, data_id=action_data_id, category_id=action_cat_id)
+ delete_action_data(policy_id=policy_id, data_id=action_data_id, category_id=action_cat_id)
def test_assignments():
diff --git a/moonv4/moon_interface/tests/apitests/utils/policies.py b/moonv4/moon_interface/tests/apitests/utils/policies.py
index 969ab70b..7b345fad 100644
--- a/moonv4/moon_interface/tests/apitests/utils/policies.py
+++ b/moonv4/moon_interface/tests/apitests/utils/policies.py
@@ -330,6 +330,19 @@ def check_subject_data(policy_id, data_id, category_id):
assert category_id == _data["category_id"]
+def delete_subject_data(policy_id, category_id, data_id):
+ req = requests.delete(URL.format("/policies/{}/subject_data/{}/{}".format(policy_id, category_id, data_id)),
+ headers=HEADERS)
+ assert req.status_code == 200
+ req = requests.get(URL.format("/policies/{}/subject_data/{}".format(policy_id, category_id)))
+ assert req.status_code == 200
+ result = req.json()
+ assert "subject_data" in result
+ for _data in result['subject_data']:
+ assert data_id not in list(_data['data'].keys())
+ assert category_id == _data["category_id"]
+
+
def add_object_data(policy_id, category_id, name="object_data1"):
object_data_template['name'] = name
req = requests.post(URL.format("/policies/{}/object_data/{}".format(policy_id, category_id)),
@@ -351,6 +364,19 @@ def check_object_data(policy_id, data_id, category_id):
assert category_id == _data["category_id"]
+def delete_object_data(policy_id, category_id, data_id):
+ req = requests.delete(URL.format("/policies/{}/object_data/{}/{}".format(policy_id, category_id, data_id)),
+ headers=HEADERS)
+ assert req.status_code == 200
+ req = requests.get(URL.format("/policies/{}/object_data/{}".format(policy_id, category_id)))
+ assert req.status_code == 200
+ result = req.json()
+ assert "object_data" in result
+ for _data in result['object_data']:
+ assert data_id not in list(_data['data'].keys())
+ assert category_id == _data["category_id"]
+
+
def add_action_data(policy_id, category_id, name="action_data1"):
action_data_template['name'] = name
req = requests.post(URL.format("/policies/{}/action_data/{}".format(policy_id, category_id)),
@@ -372,6 +398,19 @@ def check_action_data(policy_id, data_id, category_id):
assert category_id == _data["category_id"]
+def delete_action_data(policy_id, category_id, data_id):
+ req = requests.delete(URL.format("/policies/{}/action_data/{}/{}".format(policy_id, category_id, data_id)),
+ headers=HEADERS)
+ assert req.status_code == 200
+ req = requests.get(URL.format("/policies/{}/action_data/{}".format(policy_id, category_id)))
+ assert req.status_code == 200
+ result = req.json()
+ assert "action_data" in result
+ for _data in result['action_data']:
+ assert data_id not in list(_data['data'].keys())
+ assert category_id == _data["category_id"]
+
+
def add_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id):
req = requests.post(URL.format("/policies/{}/subject_assignments".format(policy_id)),
json={