aboutsummaryrefslogtreecommitdiffstats
path: root/python_moonclient/tests
diff options
context:
space:
mode:
Diffstat (limited to 'python_moonclient/tests')
-rw-r--r--python_moonclient/tests/unit_python/__init__.py0
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_action_assignments.py51
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_action_categories.py32
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_action_data.py66
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_actions.py111
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_all.py1
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_meta_rules.py44
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_models.py94
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_object_assignments.py51
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_object_categories.py31
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_object_data.py67
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_objects.py112
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_pdps.py95
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_policies.py78
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_projects.py44
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_rules.py46
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_subject_assignments.py51
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_subject_categories.py30
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_subject_data.py67
-rw-r--r--python_moonclient/tests/unit_python/conf/conf_subjects.py112
-rw-r--r--python_moonclient/tests/unit_python/conftest.py52
-rw-r--r--python_moonclient/tests/unit_python/mock_config.py64
-rw-r--r--python_moonclient/tests/unit_python/requirements.txt2
-rw-r--r--python_moonclient/tests/unit_python/test_config.py8
-rw-r--r--python_moonclient/tests/unit_python/test_models.py38
-rw-r--r--python_moonclient/tests/unit_python/test_pdp.py17
-rw-r--r--python_moonclient/tests/unit_python/test_policies.py161
-rw-r--r--python_moonclient/tests/unit_python/utilities.py153
28 files changed, 0 insertions, 1678 deletions
diff --git a/python_moonclient/tests/unit_python/__init__.py b/python_moonclient/tests/unit_python/__init__.py
deleted file mode 100644
index e69de29b..00000000
--- a/python_moonclient/tests/unit_python/__init__.py
+++ /dev/null
diff --git a/python_moonclient/tests/unit_python/conf/conf_action_assignments.py b/python_moonclient/tests/unit_python/conf/conf_action_assignments.py
deleted file mode 100644
index 43c4db59..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_action_assignments.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from .conf_all import *
-
-POST_ACTION_ASSIGNMENT = {
- "action_assignments":{
- "1":{
- "policy_id": "1",
- "action_id": "2",
- "category_id": "1",
- "assignments": ["1"]
- }
- }
-}
-
-POST_OTHER_ACTION_ASSIGNMENT = {
- "action_assignments":{
- "2":{
- "policy_id": "1",
- "action_id": "2",
- "category_id": "1",
- "assignments": ["2"]
- }
- }
-}
-
-DELETE_ACTION_ASSIGNMENT = {
- "action_assignments":{
-
- }
-}
-
-
-def conf_action_assignments(m):
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/action_assignments/2/1/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_ACTION_ASSIGNMENT},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_ACTION_ASSIGNMENT}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/action_assignments/2/1/2',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OTHER_ACTION_ASSIGNMENT
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/action_assignments',
- headers={'X-Subject-Token': "111111111"},
- json=POST_ACTION_ASSIGNMENT
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/action_assignments/2/1/1',
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_action_categories.py b/python_moonclient/tests/unit_python/conf/conf_action_categories.py
deleted file mode 100644
index 909befb2..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_action_categories.py
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-ACTION_CATEGORIES = {
- "action_categories": {
- "1": {
- "name": "action_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-POST_ACTION_CATEGORIES = {
- "action_categories": {
- "1": {
- "name": "action_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-
-def conf_action_categories(m):
- m.register_uri(
- 'GET', 'http://manager:30001/action_categories',
- headers={'X-Subject-Token': "111111111"},
- json=ACTION_CATEGORIES
- )
- m.register_uri(
- 'POST', 'http://manager:30001/action_categories',
- headers={'X-Subject-Token': "111111111"},
- json=POST_ACTION_CATEGORIES
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_action_data.py b/python_moonclient/tests/unit_python/conf/conf_action_data.py
deleted file mode 100644
index fb6f501c..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_action_data.py
+++ /dev/null
@@ -1,66 +0,0 @@
-from .conf_all import *
-
-ACTION_DATA = {
- "action_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }]
-}
-
-POST_ACTION_DATA = {
- "action_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-POST_OTHER_ACTION_DATA = {
- "action_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "2": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-DELETE_ACTION_DATA= {
- "action_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data":{}
- }]
-}
-
-
-def conf_action_data(m):
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/action_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_ACTION_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': POST_OTHER_ACTION_DATA}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/action_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': ACTION_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_ACTION_DATA}]
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/action_data/1/1',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_actions.py b/python_moonclient/tests/unit_python/conf/conf_actions.py
deleted file mode 100644
index 4e6784dd..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_actions.py
+++ /dev/null
@@ -1,111 +0,0 @@
-from .conf_all import *
-
-ACTIONS = {
- "actions":{
- "1": {
- "name": "name of the action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- }
- }
-}
-
-ACTIONS_AFTER_POST = {
- "actions":{
- "1": {
- "name": "name of the action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-ACTIONS_AFTER_PATCH = {
- "actions":{
- "1": {
- "name": "name of the action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-
-POST_ACTIONS = {
- "actions":{
- "2": {
- "name": "test_action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-PATCH_ACTIONS = {
- "actions":{
- "2": {
- "name": "test_action",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-def conf_actions(m):
- m.register_uri(
- 'GET', 'http://manager:30001/actions',
- headers={'X-Subject-Token': "111111111"},
- json=ACTIONS
- )
- m.register_uri(
- 'POST', 'http://manager:30001/actions',
- headers={'X-Subject-Token': "111111111"},
- json=POST_ACTIONS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/actions/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/policies/2/actions/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_ACTIONS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/actions',
- headers={'X-Subject-Token': "111111111"},
- json=ACTIONS_AFTER_PATCH
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/actions',
- headers={'X-Subject-Token': "111111111"},
- json=POST_ACTIONS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/actions/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_ACTIONS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/actions/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_all.py b/python_moonclient/tests/unit_python/conf/conf_all.py
deleted file mode 100644
index b87d4fe7..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_all.py
+++ /dev/null
@@ -1 +0,0 @@
-RESULT_OK = {"result": "OK"}
diff --git a/python_moonclient/tests/unit_python/conf/conf_meta_rules.py b/python_moonclient/tests/unit_python/conf/conf_meta_rules.py
deleted file mode 100644
index 67c14ddf..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_meta_rules.py
+++ /dev/null
@@ -1,44 +0,0 @@
-from .conf_all import *
-
-
-META_RULES = {
- "meta_rules": {
- "1": {
- "name": "test_meta_rule",
- "algorithm": "name of the meta rule algorithm",
- "subject_categories": ["1"],
- "object_categories": ["1"],
- "action_categories": ["1"]
- }
- }
-}
-
-POST_META_RULES = {
- "meta_rules": {
- "1": {
- "name": "test_meta_rule",
- "algorithm": "name of the meta rule algorithm",
- "subject_categories": ["1"],
- "object_categories": ["1"],
- "action_categories": ["1"]
- }
- }
-}
-
-
-def conf_meta_rules(m):
- m.register_uri(
- 'GET', 'http://manager:30001/meta_rules',
- headers={'X-Subject-Token': "111111111"},
- json=META_RULES
- )
- m.register_uri(
- 'POST', 'http://manager:30001/meta_rules',
- headers={'X-Subject-Token': "111111111"},
- json=POST_META_RULES
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/meta_rules/1',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_models.py b/python_moonclient/tests/unit_python/conf/conf_models.py
deleted file mode 100644
index 930af88f..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_models.py
+++ /dev/null
@@ -1,94 +0,0 @@
-from .conf_all import *
-
-
-MODELS = {
- "models": {
- "1": {
- "name": "model 1",
- "description": "description model 1",
- "meta_rules": [{
- "meta_rule_id": "1"
- }, {
- "meta_rule_id": "2"
- }]
- },
- "2": {
- "name": "model 2",
- "description": "description model 2",
- "meta_rules": ["2"]
- },
- "3": {
- "name": "test_model",
- "description": "description model 3",
- "meta_rules": ["2"]
- }
- }
-}
-
-POST_MODEL = {
- "models": {
- "3": {
- "name": "test_model",
- "description": "description model 3",
- "meta_rules": ["2"]
- }
- }
-}
-
-PATCH_MODEL = {
- "models": {
- "3": {
- "name": "test_model",
- "description": "description model 3",
- "meta_rules": ["2", "1"]
- }
- }
-}
-
-
-MODELS_AFTER_POST = {
-"models": {
- "1": {
- "name": "model 1",
- "description": "description model 1",
- "meta_rules": [{
- "meta_rule_id": "1"
- }, {
- "meta_rule_id": "2"
- }]
- },
- "2": {
- "name": "model 2",
- "description": "description model 2",
- "meta_rules": ["2"]
- },
- "3": {
- "name": "test_model",
- "description": "description model 3",
- "meta_rules": ["1", "2"]
- }
- }
-}
-
-
-def conf_models(m):
- m.register_uri(
- 'GET', 'http://manager:30001/models',
- [{'json': MODELS, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': MODELS_AFTER_POST, 'headers': {'X-Subject-Token': "111111111"}}]
- )
- m.register_uri(
- 'POST', 'http://manager:30001/models',
- headers={'X-Subject-Token': "111111111"},
- json=POST_MODEL
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/models/3',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_MODEL
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/models/3',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_object_assignments.py b/python_moonclient/tests/unit_python/conf/conf_object_assignments.py
deleted file mode 100644
index 9e88e03e..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_object_assignments.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from .conf_all import *
-
-POST_OBJECT_ASSIGNMENT = {
- "object_assignments":{
- "1":{
- "policy_id": "1",
- "object_id": "2",
- "category_id": "1",
- "assignments": ["1"]
- }
- }
-}
-
-POST_OTHER_OBJECT_ASSIGNMENT = {
- "object_assignments":{
- "2":{
- "policy_id": "1",
- "object_id": "2",
- "category_id": "1",
- "assignments": ["2"]
- }
- }
-}
-
-DELETE_OBJECT_ASSIGNMENT = {
- "object_assignments":{
-
- }
-}
-
-
-def conf_object_assignments(m):
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/object_assignments/2/1/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_OBJECT_ASSIGNMENT},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_OBJECT_ASSIGNMENT}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/object_assignments/2/1/2',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OTHER_OBJECT_ASSIGNMENT
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/object_assignments',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OBJECT_ASSIGNMENT
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/object_assignments/2/1/1',
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_object_categories.py b/python_moonclient/tests/unit_python/conf/conf_object_categories.py
deleted file mode 100644
index a942f9c6..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_object_categories.py
+++ /dev/null
@@ -1,31 +0,0 @@
-
-OBJECT_CATEGORIES = {
- "object_categories": {
- "1": {
- "name": "object_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-POST_OBJECT_CATEGORIES = {
- "object_categories": {
- "1": {
- "name": "object_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-
-def conf_object_categories(m):
- m.register_uri(
- 'GET', 'http://manager:30001/object_categories',
- headers={'X-Subject-Token': "111111111"},
- json=OBJECT_CATEGORIES
- )
- m.register_uri(
- 'POST', 'http://manager:30001/object_categories',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OBJECT_CATEGORIES
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_object_data.py b/python_moonclient/tests/unit_python/conf/conf_object_data.py
deleted file mode 100644
index 8fa81d69..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_object_data.py
+++ /dev/null
@@ -1,67 +0,0 @@
-
-from .conf_all import *
-
-OBJECT_DATA = {
- "object_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }]
-}
-
-POST_OBJECT_DATA = {
- "object_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-POST_OTHER_OBJECT_DATA = {
- "object_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "2": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-DELETE_OBJECT_DATA= {
- "object_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data":{}
- }]
-}
-
-
-def conf_object_data(m):
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/object_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_OBJECT_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': POST_OTHER_OBJECT_DATA}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/object_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': OBJECT_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_OBJECT_DATA}]
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/object_data/1/1',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_objects.py b/python_moonclient/tests/unit_python/conf/conf_objects.py
deleted file mode 100644
index cf3e7aa4..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_objects.py
+++ /dev/null
@@ -1,112 +0,0 @@
-from .conf_all import *
-
-OBJECTS = {
- "objects":{
- "1": {
- "name": "name of the object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- }
- }
-}
-
-OBJECTS_AFTER_POST = {
- "objects":{
- "1": {
- "name": "name of the object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-OBJECTS_AFTER_PATCH = {
- "objects":{
- "1": {
- "name": "name of the object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-
-POST_OBJECTS = {
- "objects":{
- "2": {
- "name": "test_object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-PATCH_OBJECTS = {
- "objects":{
- "2": {
- "name": "test_object",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-def conf_objects(m):
- m.register_uri(
- 'GET', 'http://manager:30001/objects',
- [{'json': OBJECTS, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': OBJECTS_AFTER_POST, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': OBJECTS, 'headers': {'X-Subject-Token': "111111111"}}]
- )
- m.register_uri(
- 'POST', 'http://manager:30001/objects',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OBJECTS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/objects/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/policies/2/objects/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_OBJECTS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/objects',
- headers={'X-Subject-Token': "111111111"},
- json=OBJECTS_AFTER_PATCH
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/objects',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OBJECTS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/objects/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_OBJECTS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/objects/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_pdps.py b/python_moonclient/tests/unit_python/conf/conf_pdps.py
deleted file mode 100644
index 1090fccb..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_pdps.py
+++ /dev/null
@@ -1,95 +0,0 @@
-from .conf_all import *
-
-PDPS = {
- "pdps": {
- "1": {
- "name": "...",
- "security_pipeline": [],
- "keystone_project_id": "",
- "description": "...",
- }
- }
- }
-
-
-POST_PDP = {
- "pdps": {
- "2": {
- "name": "test_pdp",
- "security_pipeline": [],
- "keystone_project_id": "",
- "description": "..."
- }
- }
- }
-
-PATCH_PDP = {
- "pdps": {
- "2": {
- "name": "test_pdp",
- "security_pipeline": [],
- "keystone_project_id": "0c4e939acacf4376bdcd1129f1a054ad",
- "description": "..."
- }
- }
- }
-
-PDPS_AFTER_POST = {
- "pdps": {
- "1": {
- "name": "...",
- "security_pipeline": [],
- "keystone_project_id": "",
- "description": "...",
- },
-
- "2": {
- "name": "test_pdp",
- "security_pipeline": [],
- "keystone_project_id": "",
- "description": "...",
- }
- }
- }
-
-PDPS_AFTER_PATCH = {
- "pdps": {
- "1": {
- "name": "...",
- "security_pipeline": [],
- "keystone_project_id": "",
- "description": "...",
- },
-
- "2": {
- "name": "test_pdp",
- "security_pipeline": [],
- "keystone_project_id": "0c4e939acacf4376bdcd1129f1a054ad",
- "description": "...",
- }
- }
- }
-
-def conf_pdps(m):
- m.register_uri(
- 'GET', 'http://manager:30001/pdp',
- [{'json': PDPS, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': PDPS_AFTER_POST, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': PDPS_AFTER_PATCH, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': PDPS, 'headers': {'X-Subject-Token': "111111111"}}]
- )
- m.register_uri(
- 'POST', 'http://manager:30001/pdp',
- headers={'X-Subject-Token': "111111111"},
- json=POST_PDP
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/pdp/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_PDP
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/pdp/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_policies.py b/python_moonclient/tests/unit_python/conf/conf_policies.py
deleted file mode 100644
index bf6883bc..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_policies.py
+++ /dev/null
@@ -1,78 +0,0 @@
-from .conf_all import *
-
-POLICIES = {
- "policies":{
- "1": {
- "name": "test_policy",
- "model_id": "1",
- "genre": "authz",
- "description": "Description of the policy",
- }
- }
-}
-
-POLICIES_AFTER_POST= {
- "policies":{
- "1": {
- "name": "test_policy",
- "model_id": "1",
- "genre": "authz",
- "description": "Description of the policy",
- },
- "2": {
- "name": "test_policy",
- "model_id": "",
- "genre": "",
- "description": "Description of the policy",
- }
- }
-}
-
-
-POST_POLICIES ={
- "policies":{
- "2": {
- "name": "test_policy",
- "model_id": "",
- "genre": "",
- "description": "Description of the policy",
- }
- }
-}
-
-
-PATCH_POLICIES ={
- "policies":{
- "2": {
- "name": "test_policy",
- "model_id": "3",
- "genre": "authz",
- "description": "Description of the policy",
- }
- }
-}
-
-
-def conf_policies(m):
- m.register_uri(
- 'GET', 'http://manager:30001/policies',
- [{'json': POLICIES, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': POLICIES_AFTER_POST, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': POLICIES, 'headers': {'X-Subject-Token': "111111111"}}]
-
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies',
- headers={'X-Subject-Token': "111111111"},
- json=POST_POLICIES
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/policies/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_POLICIES
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_projects.py b/python_moonclient/tests/unit_python/conf/conf_projects.py
deleted file mode 100644
index 63be05e0..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_projects.py
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-PROJECTS = {
- "projects": [
- {
- "is_domain": False,
- "description": None,
- "domain_id": "admin",
- "enabled": True,
- "id": "0c4e939acacf4376bdcd1129f1a054ad",
- "links": {
- "self": "http://example.com/identity/v3/projects/0c4e939acacf4376bdcd1129f1a054ad"
- },
- "name": "admin",
- "parent_id": None,
- "tags": []
- },
- {
- "is_domain": False,
- "description": None,
- "domain_id": "default",
- "enabled": True,
- "id": "0cbd49cbf76d405d9c86562e1d579bd3",
- "links": {
- "self": "http://example.com/identity/v3/projects/0cbd49cbf76d405d9c86562e1d579bd3"
- },
- "name": "demo",
- "parent_id": None,
- "tags": []
- }
- ]
-}
-
-
-def conf_projects(m):
- m.register_uri(
- 'GET', 'http://keystone:5000/v3/projects',
- headers={'X-Subject-Token': "111111111"},
- json=PROJECTS
- )
- m.register_uri(
- 'POST', 'http://keystone:5000/v3/auth/tokens',
- headers={'X-Subject-Token': "111111111"}
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_rules.py b/python_moonclient/tests/unit_python/conf/conf_rules.py
deleted file mode 100644
index 30b8c682..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_rules.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from .conf_all import *
-
-RULES = {
- "rules":{
- "policy_id": "2",
- "rules": [{
- "meta_rule_id": "1",
- "id": "1",
- "rule": ["1", "1", "1"]
- }]
- }
-}
-
-POST_RULES = {
- "rules":{
- "1":{
- "policy_id": "2",
- "meta_rule_id": "1",
- "rule": ["1", "1", "1"]
- }
- }
-}
-
-DELETE_RULES = {
- "rules":{
- "policy_id": "2",
- "rules": []
- }
-}
-
-
-def conf_rule_assignments(m):
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/rules',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': RULES},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_RULES}]
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/rules',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_RULES}]
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/rules/1',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_subject_assignments.py b/python_moonclient/tests/unit_python/conf/conf_subject_assignments.py
deleted file mode 100644
index 92b689c0..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_subject_assignments.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from .conf_all import *
-
-POST_SUBJECT_ASSIGNMENT = {
- "subject_assignments":{
- "1":{
- "policy_id": "1",
- "subject_id": "2",
- "category_id": "1",
- "assignments": ["1"]
- }
- }
-}
-
-DELETE_SUBJECT_ASSIGNMENT = {
- "subject_assignments":{
-
- }
-}
-
-POST_OTHER_SUBJECT_ASSIGNMENT = {
- "subject_assignments":{
- "2":{
- "policy_id": "1",
- "subject_id": "2",
- "category_id": "1",
- "assignments": ["2"]
- }
- }
-}
-
-
-def conf_subject_assignments(m):
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/subject_assignments/2/1/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_SUBJECT_ASSIGNMENT},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_SUBJECT_ASSIGNMENT}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/subject_assignments/2/1/2',
- headers={'X-Subject-Token': "111111111"},
- json=POST_OTHER_SUBJECT_ASSIGNMENT
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/subject_assignments',
- headers={'X-Subject-Token': "111111111"},
- json=POST_SUBJECT_ASSIGNMENT
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/subject_assignments/2/1/1',
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_subject_categories.py b/python_moonclient/tests/unit_python/conf/conf_subject_categories.py
deleted file mode 100644
index e59a458a..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_subject_categories.py
+++ /dev/null
@@ -1,30 +0,0 @@
-
-SUBJECT_CATEGORIES = {
- "subject_categories": {
- "1": {
- "name": "subject_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-POST_SUBJECT_CATEGORIES = {
- "subject_categories": {
- "1": {
- "name": "subject_cat_1",
- "description": "description of the category"
- }
- }
-}
-
-def conf_subject_categories(m):
- m.register_uri(
- 'GET', 'http://manager:30001/subject_categories',
- headers={'X-Subject-Token': "111111111"},
- json=SUBJECT_CATEGORIES
- )
- m.register_uri(
- 'POST', 'http://manager:30001/subject_categories',
- headers={'X-Subject-Token': "111111111"},
- json=POST_SUBJECT_CATEGORIES
- )
diff --git a/python_moonclient/tests/unit_python/conf/conf_subject_data.py b/python_moonclient/tests/unit_python/conf/conf_subject_data.py
deleted file mode 100644
index 19db217d..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_subject_data.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from .conf_all import *
-
-SUBJECT_DATA = {
- "subject_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }]
-}
-
-POST_SUBJECT_DATA = {
- "subject_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "1": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-
-POST_OTHER_SUBJECT_DATA = {
- "subject_data":{
- "policy_id": "1",
- "category_id": "1",
- "data": {
- "2": {
- "name": "name of the data",
- "description": "description of the data"
- }
- }
- }
-}
-
-DELETE_SUBJECT_DATA= {
- "subject_data":[{
- "policy_id": "1",
- "category_id": "1",
- "data":{}
- }]
-}
-
-
-def conf_subject_data(m):
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/subject_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': POST_SUBJECT_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': POST_OTHER_SUBJECT_DATA}]
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/subject_data/1',
- [{'headers': {'X-Subject-Token': "111111111"}, 'json': SUBJECT_DATA},
- {'headers': {'X-Subject-Token': "111111111"}, 'json': DELETE_SUBJECT_DATA}]
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/subject_data/1/1',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conf/conf_subjects.py b/python_moonclient/tests/unit_python/conf/conf_subjects.py
deleted file mode 100644
index bde6093f..00000000
--- a/python_moonclient/tests/unit_python/conf/conf_subjects.py
+++ /dev/null
@@ -1,112 +0,0 @@
-from .conf_all import *
-
-SUBJECTS = {
- "subjects":{
- "1": {
- "name": "name of the subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- }
- }
-}
-
-SUBJECTS_AFTER_POST= {
- "subjects":{
- "1": {
- "name": "name of the subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-SUBJECTS_AFTER_PATCH= {
- "subjects":{
- "1": {
- "name": "name of the subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["1"]
- },
- "2": {
- "name": "test_subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-POST_SUBJECTS = {
- "subjects":{
- "2": {
- "name": "test_subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": []
- }
- }
-}
-
-
-PATCH_SUBJECTS = {
- "subjects":{
- "2": {
- "name": "test_subject",
- "keystone_id": "1",
- "description": "a description",
- "policy_list": ["2"]
- }
- }
-}
-
-def conf_subjects(m):
- m.register_uri(
- 'GET', 'http://manager:30001/subjects',
- [{'json': SUBJECTS, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': SUBJECTS_AFTER_POST, 'headers': {'X-Subject-Token': "111111111"}},
- {'json': SUBJECTS, 'headers': {'X-Subject-Token': "111111111"}}]
- )
- m.register_uri(
- 'POST', 'http://manager:30001/subjects',
- headers={'X-Subject-Token': "111111111"},
- json=POST_SUBJECTS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/subjects/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- )
- m.register_uri(
- 'PATCH', 'http://manager:30001/policies/2/subjects/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_SUBJECTS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/subjects',
- headers={'X-Subject-Token': "111111111"},
- json=SUBJECTS_AFTER_PATCH
- )
- m.register_uri(
- 'POST', 'http://manager:30001/policies/2/subjects',
- headers={'X-Subject-Token': "111111111"},
- json=POST_SUBJECTS
- )
- m.register_uri(
- 'GET', 'http://manager:30001/policies/2/subjects/2',
- headers={'X-Subject-Token': "111111111"},
- json=PATCH_SUBJECTS
- )
- m.register_uri(
- 'DELETE', 'http://manager:30001/policies/2/subjects/2',
- headers={'X-Subject-Token': "111111111"},
- json=RESULT_OK
- ) \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/conftest.py b/python_moonclient/tests/unit_python/conftest.py
deleted file mode 100644
index bd3e5f4d..00000000
--- a/python_moonclient/tests/unit_python/conftest.py
+++ /dev/null
@@ -1,52 +0,0 @@
-import pytest
-import requests_mock
-from . import mock_config
-
-from .conf.conf_projects import *
-from .conf.conf_models import *
-from .conf.conf_pdps import *
-from .conf.conf_action_categories import *
-from .conf.conf_object_categories import *
-from .conf.conf_subject_categories import *
-from .conf.conf_meta_rules import *
-from .conf.conf_action_assignments import *
-from .conf.conf_object_assignments import *
-from .conf.conf_subject_assignments import *
-from .conf.conf_policies import *
-from .conf.conf_subjects import *
-from .conf.conf_objects import *
-from .conf.conf_actions import *
-from .conf.conf_subject_data import *
-from .conf.conf_object_data import *
-from .conf.conf_action_data import *
-from .conf.conf_rules import *
-
-
-@pytest.fixture(autouse=True)
-def no_requests(monkeypatch):
- """ Modify the response from Requests module
- """
- with requests_mock.Mocker(real_http=True) as m:
- mock_config.register_consul(m)
-
- conf_projects(m)
- conf_models(m)
- conf_pdps(m)
- conf_action_categories(m)
- conf_object_categories(m)
- conf_subject_categories(m)
- conf_meta_rules(m)
- conf_policies(m)
- conf_subjects(m)
- conf_objects(m)
- conf_actions(m)
- conf_object_data(m)
- conf_subject_data(m)
- conf_action_data(m)
- conf_action_assignments(m)
- conf_object_assignments(m)
- conf_subject_assignments(m)
- conf_rule_assignments(m)
- yield m
-
-
diff --git a/python_moonclient/tests/unit_python/mock_config.py b/python_moonclient/tests/unit_python/mock_config.py
deleted file mode 100644
index b6c42d76..00000000
--- a/python_moonclient/tests/unit_python/mock_config.py
+++ /dev/null
@@ -1,64 +0,0 @@
-from . import utilities
-
-
-components_manager_mock = {
- "port": 8082,
- "bind": "0.0.0.0",
- "hostname": "manager",
- "container": "wukongsun/moon_manager:v4.3.1",
- "external": {
- "port": 30001,
- "hostname": "88.88.88.2"
- }
-}
-
-
-openstack_keystone_mock = {
- "url": "http://keystone:5000/v3",
- "user": "admin",
- "password": "p4ssw0rd",
- "domain": "default",
- "project": "admin",
- "check_token": False,
- "certificate": False,
- "external": {
- "url": "http://88.88.88.2:30006/v3"
- }
-}
-
-
-def register_consul(m):
- for component in utilities.COMPONENTS:
- m.register_uri(
- 'GET', 'http://consul:8500/v1/kv/{}'.format(component),
- json=[{'Key': component, 'Value': utilities.get_b64_conf(component)}]
- )
-
- m.register_uri(
- 'GET', 'http://manager:30001',
- json={}
- )
- m.register_uri(
- 'GET', 'http://keystone:5000/v3',
- json={}
- )
- m.register_uri(
- 'POST', 'http://keystone:5000/v3/auth/tokens',
- headers={'X-Subject-Token': "111111111"}
- )
- m.register_uri(
- 'DELETE', 'http://keystone:5000/v3/auth/tokens',
- headers={'X-Subject-Token': "111111111"}
- )
- m.register_uri(
- 'POST', 'http://keystone:5000/v3/users?name=testuser&domain_id=default',
- json={"users": {}}
- )
- m.register_uri(
- 'GET', 'http://keystone:5000/v3/users?name=testuser&domain_id=default',
- json={"users": {}}
- )
- m.register_uri(
- 'POST', 'http://keystone:5000/v3/users/',
- json={"users": [{"id": "1111111111111"}]}
- )
diff --git a/python_moonclient/tests/unit_python/requirements.txt b/python_moonclient/tests/unit_python/requirements.txt
deleted file mode 100644
index 3c1ad607..00000000
--- a/python_moonclient/tests/unit_python/requirements.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-pytest
-requests_mock \ No newline at end of file
diff --git a/python_moonclient/tests/unit_python/test_config.py b/python_moonclient/tests/unit_python/test_config.py
deleted file mode 100644
index e4effec6..00000000
--- a/python_moonclient/tests/unit_python/test_config.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from python_moonclient.core.cli_exceptions import MoonCliException
-
-
-def test_authz_request():
- from python_moonclient.core import config
- conf_data = config.get_config_data("consul", 8500)
- if not isinstance(conf_data, dict):
- raise MoonCliException("Unexpected error : the conf data is not a dictionnary")
diff --git a/python_moonclient/tests/unit_python/test_models.py b/python_moonclient/tests/unit_python/test_models.py
deleted file mode 100644
index fed889e3..00000000
--- a/python_moonclient/tests/unit_python/test_models.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from python_moonclient.core.models import *
-
-
-def test_models():
- init("consul", 8500)
- check_model()
- model_id = add_model()
- check_model(model_id)
- delete_model(model_id)
-
-
-def test_meta_data_subject():
- category_id = add_subject_category()
- check_subject_category(category_id)
- # TODO (asteroide): must implement the deletion of linked data
- # delete_subject_category(category_id)
-
-
-def test_meta_data_object():
- category_id = add_object_category()
- check_object_category(category_id)
- # TODO (asteroide): must implement the deletion of linked data
- # delete_object_category(category_id)
-
-
-def test_meta_data_action():
- category_id = add_action_category()
- check_action_category(category_id)
- # TODO (asteroide): must implement the deletion of linked data
- # delete_action_category(category_id)
-
-
-def test_meta_rule():
- meta_rule_id, scat_id, ocat_id, acat_id = add_categories_and_meta_rule()
- check_meta_rule(meta_rule_id, scat_id, ocat_id, acat_id)
- delete_meta_rule(meta_rule_id)
-
-
diff --git a/python_moonclient/tests/unit_python/test_pdp.py b/python_moonclient/tests/unit_python/test_pdp.py
deleted file mode 100644
index e979aeae..00000000
--- a/python_moonclient/tests/unit_python/test_pdp.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from python_moonclient.core.pdp import *
-
-def test_pdp():
- init("consul", 8500)
- projects = get_keystone_projects()
- admin_project_id = None
- for _project in projects['projects']:
- if _project['name'] == "admin":
- admin_project_id = _project['id']
- if admin_project_id is None:
- raise MoonCliException("Unexpected results, could not find the admin project")
- check_pdp()
- pdp_id = add_pdp()
- check_pdp(pdp_id)
- map_to_keystone(pdp_id=pdp_id, keystone_project_id=admin_project_id)
- check_pdp(pdp_id=pdp_id, keystone_project_id=admin_project_id)
- delete_pdp(pdp_id)
diff --git a/python_moonclient/tests/unit_python/test_policies.py b/python_moonclient/tests/unit_python/test_policies.py
deleted file mode 100644
index 9ab9003e..00000000
--- a/python_moonclient/tests/unit_python/test_policies.py
+++ /dev/null
@@ -1,161 +0,0 @@
-from python_moonclient.core.policies import *
-from python_moonclient.core.models import *
-from python_moonclient.core import policies
-from python_moonclient.core import models
-
-
-def test_policies():
- policies.init("consul", 8500)
- models.init("consul", 8500)
- check_policy()
- policy_id = add_policy()
- check_policy(policy_id)
- delete_policy(policy_id)
-
-
-def test_subjects():
- policy_id = add_policy()
- subject_id = add_subject()
-
- update_subject(subject_id=subject_id, policy_id=policy_id)
-
- check_subject(subject_id=subject_id, policy_id=policy_id)
-
- delete_subject(subject_id, policy_id=policy_id)
- delete_subject(subject_id)
-
-
-def test_objects():
- policy_id = add_policy()
- object_id = add_object()
-
- update_object(object_id=object_id, policy_id=policy_id)
- check_object(object_id=object_id, policy_id=policy_id)
-
- delete_object(object_id=object_id, policy_id=policy_id)
- delete_object(object_id=object_id)
-
-
-def test_actions():
- policy_id = add_policy()
- action_id = add_action()
-
- update_action(action_id=action_id, policy_id=policy_id)
- check_action(action_id=action_id, policy_id=policy_id)
-
- delete_action(action_id=action_id, policy_id=policy_id)
- delete_action(action_id=action_id)
-
-
-def test_subject_data():
- policy_id = add_policy()
-
- model_id = add_model()
-
- update_policy(policy_id, model_id)
-
- meta_rule_id, subject_cat_id, object_cat_id, action_cat_id = add_categories_and_meta_rule()
- add_meta_rule_to_model(model_id, meta_rule_id)
-
- 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():
- policy_id = add_policy()
-
- model_id = add_model()
-
- update_policy(policy_id, model_id)
-
- meta_rule_id, object_cat_id, object_cat_id, action_cat_id = add_categories_and_meta_rule()
- add_meta_rule_to_model(model_id, meta_rule_id)
-
- 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)
- print('ok')
-
-def test_action_data():
- policy_id = add_policy()
-
- model_id = add_model()
-
- update_policy(policy_id, model_id)
-
- meta_rule_id, action_cat_id, action_cat_id, action_cat_id = add_categories_and_meta_rule()
- add_meta_rule_to_model(model_id, meta_rule_id)
-
- 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():
- policy_id = add_policy()
-
- model_id = add_model()
-
- update_policy(policy_id, model_id)
-
- meta_rule_id, subject_cat_id, object_cat_id, action_cat_id = add_categories_and_meta_rule()
- add_meta_rule_to_model(model_id, meta_rule_id)
-
- subject_data_id = add_subject_data(policy_id=policy_id, category_id=subject_cat_id)
- subject_data_id_bis = add_subject_data(policy_id=policy_id, category_id=subject_cat_id)
- object_data_id = add_object_data(policy_id=policy_id, category_id=object_cat_id)
- object_data_id_bis = add_object_data(policy_id=policy_id, category_id=object_cat_id)
- action_data_id = add_action_data(policy_id=policy_id, category_id=action_cat_id)
- action_data_id_bis = add_action_data(policy_id=policy_id, category_id=action_cat_id)
-
- subject_id = add_subject(policy_id)
- object_id = add_object(policy_id)
- action_id = add_action(policy_id)
-
- add_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id)
- add_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id_bis)
- add_object_assignments(policy_id, object_id, object_cat_id, object_data_id)
- add_object_assignments(policy_id, object_id, object_cat_id, object_data_id_bis)
- add_action_assignments(policy_id, action_id, action_cat_id, action_data_id)
- add_action_assignments(policy_id, action_id, action_cat_id, action_data_id_bis)
-
- check_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id)
- check_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id_bis)
- check_object_assignments(policy_id, object_id, object_cat_id, object_data_id)
- check_object_assignments(policy_id, object_id, object_cat_id, object_data_id_bis)
- check_action_assignments(policy_id, action_id, action_cat_id, action_data_id)
- check_action_assignments(policy_id, action_id, action_cat_id, action_data_id_bis)
-
- delete_subject_assignment(policy_id, subject_id, subject_cat_id, subject_data_id)
- delete_object_assignment(policy_id, object_id, object_cat_id, object_data_id)
- delete_action_assignment(policy_id, action_id, action_cat_id, action_data_id)
-
-
-def test_rule():
- policy_id = add_policy()
-
- model_id = add_model()
-
- update_policy(policy_id, model_id)
-
- meta_rule_id, subject_cat_id, object_cat_id, action_cat_id = add_categories_and_meta_rule()
- add_meta_rule_to_model(model_id, meta_rule_id)
-
- subject_data_id = add_subject_data(policy_id=policy_id, category_id=subject_cat_id)
- object_data_id = add_object_data(policy_id=policy_id, category_id=object_cat_id)
- action_data_id = add_action_data(policy_id=policy_id, category_id=action_cat_id)
-
- subject_id = add_subject(policy_id)
- object_id = add_object(policy_id)
- action_id = add_action(policy_id)
-
- add_subject_assignments(policy_id, subject_id, subject_cat_id, subject_data_id)
- add_object_assignments(policy_id, object_id, object_cat_id, object_data_id)
- add_action_assignments(policy_id, action_id, action_cat_id, action_data_id)
-
- rule_id = add_rule(policy_id, meta_rule_id, [subject_data_id, object_data_id, action_data_id])
- check_rule(policy_id, meta_rule_id, rule_id, [subject_data_id, object_data_id, action_data_id])
-
- delete_rule(policy_id, rule_id)
-
diff --git a/python_moonclient/tests/unit_python/utilities.py b/python_moonclient/tests/unit_python/utilities.py
deleted file mode 100644
index ae2932c7..00000000
--- a/python_moonclient/tests/unit_python/utilities.py
+++ /dev/null
@@ -1,153 +0,0 @@
-import base64
-import json
-
-CONF = {
- "openstack": {
- "keystone": {
- "url": "http://keystone:5000/v3",
- "user": "admin",
- "check_token": False,
- "password": "p4ssw0rd",
- "domain": "default",
- "certificate": False,
- "project": "admin",
- "external": {
- "url": "http://keystone:5000/v3",
- }
- }
- },
- "components": {
- "wrapper": {
- "bind": "0.0.0.0",
- "port": 8080,
- "container": "wukongsun/moon_wrapper:v4.3",
- "timeout": 5,
- "hostname": "wrapper"
- },
- "manager": {
- "bind": "0.0.0.0",
- "port": 8082,
- "container": "wukongsun/moon_manager:v4.3",
- "hostname": "manager",
- "external": {
- "hostname": "manager",
- "port": 30001
- }
- },
- "port_start": 31001,
- "orchestrator": {
- "bind": "0.0.0.0",
- "port": 8083,
- "container": "wukongsun/moon_orchestrator:v4.3",
- "hostname": "orchestrator"
- },
- "interface": {
- "bind": "0.0.0.0",
- "port": 8080,
- "container": "wukongsun/moon_interface:v4.3",
- "hostname": "interface"
- }
- },
- "plugins": {
- "session": {
- "port": 8082,
- "container": "asteroide/session:latest"
- },
- "authz": {
- "port": 8081,
- "container": "wukongsun/moon_authz:v4.3"
- }
- },
- "logging": {
- "handlers": {
- "file": {
- "filename": "/tmp/moon.log",
- "class": "logging.handlers.RotatingFileHandler",
- "level": "DEBUG",
- "formatter": "custom",
- "backupCount": 3,
- "maxBytes": 1048576
- },
- "console": {
- "class": "logging.StreamHandler",
- "formatter": "brief",
- "level": "INFO",
- "stream": "ext://sys.stdout"
- }
- },
- "formatters": {
- "brief": {
- "format": "%(levelname)s %(name)s %(message)-30s"
- },
- "custom": {
- "format": "%(asctime)-15s %(levelname)s %(name)s %(message)s"
- }
- },
- "root": {
- "handlers": [
- "console"
- ],
- "level": "ERROR"
- },
- "version": 1,
- "loggers": {
- "moon": {
- "handlers": [
- "console",
- "file"
- ],
- "propagate": False,
- "level": "DEBUG"
- }
- }
- },
- "slave": {
- "name": None,
- "master": {
- "url": None,
- "login": None,
- "password": None
- }
- },
- "docker": {
- "url": "tcp://172.88.88.1:2376",
- "network": "moon"
- },
- "database": {
- "url": "sqlite:///database.db",
- # "url": "mysql+pymysql://moon:p4sswOrd1@db/moon",
- "driver": "sql"
- },
- "messenger": {
- "url": "rabbit://moon:p4sswOrd1@messenger:5672/moon"
- }
-}
-
-COMPONENTS = (
- "logging",
- "openstack/keystone",
- "database",
- "slave",
- "components/manager",
- "components/orchestrator",
- "components/interface",
- "components/wrapper",
-)
-
-
-def get_b64_conf(component=None):
- if component == "components":
- return base64.b64encode(
- json.dumps(CONF["components"]).encode('utf-8')+b"\n").decode('utf-8')
- elif component in CONF:
- return base64.b64encode(
- json.dumps(
- CONF[component]).encode('utf-8')+b"\n").decode('utf-8')
- elif not component:
- return base64.b64encode(
- json.dumps(CONF).encode('utf-8')+b"\n").decode('utf-8')
- elif "/" in component:
- key1, _, key2 = component.partition("/")
- return base64.b64encode(
- json.dumps(
- CONF[key1][key2]).encode('utf-8')+b"\n").decode('utf-8')