Skip to content
Snippets Groups Projects
Commit 6574658f authored by Dmitrii Valuiskii (EPAM)'s avatar Dmitrii Valuiskii (EPAM) Committed by Siarhei Khaletski (EPAM)
Browse files

GONRG-782: add support custom acl and legal tag. update tests.

parent e0146e3d
No related branches found
No related tags found
1 merge request!7R3 ingestion updates
...@@ -30,8 +30,6 @@ import tenacity ...@@ -30,8 +30,6 @@ import tenacity
from airflow.models import BaseOperator, Variable from airflow.models import BaseOperator, Variable
from libs.refresh_token import AirflowTokenRefresher, refresh_token from libs.refresh_token import AirflowTokenRefresher, refresh_token
ACL_DICT = eval(Variable.get("acl"))
LEGAL_DICT = eval(Variable.get("legal"))
config = configparser.RawConfigParser() config = configparser.RawConfigParser()
config.read(Variable.get("dataload_config_path")) config.read(Variable.get("dataload_config_path"))
...@@ -65,12 +63,12 @@ class FileType(enum.Enum): ...@@ -65,12 +63,12 @@ class FileType(enum.Enum):
def dataload(**kwargs): def dataload(**kwargs):
data_conf = kwargs['dag_run'].conf data_conf = kwargs['dag_run'].conf
conf_payload = kwargs["dag_run"].conf["Payload"]
loaded_conf = { loaded_conf = {
"acl": ACL_DICT, "acl": conf_payload["acl"],
"legal_tag": LEGAL_DICT, "legal_tag": conf_payload["legal"],
"data_object": data_conf "data_object": data_conf
} }
conf_payload = kwargs["dag_run"].conf["Payload"]
return loaded_conf, conf_payload return loaded_conf, conf_payload
......
...@@ -108,7 +108,13 @@ ...@@ -108,7 +108,13 @@
"Payload": { "Payload": {
"authorization": "Bearer foo", "authorization": "Bearer foo",
"data-partition-id": "common", "data-partition-id": "common",
"AppKey": "test" "AppKey": "test",
"acl": {
"viewers": ["data.default.viewers"],
"owners": ["data.default.owners"]},
"legal": {
"legaltags": ["odes-demo-legaltag"],
"otherRelevantDataCountries": ["FR", "US", "CA"]}
}, },
"WorkflowID": "foo" "WorkflowID": "foo"
} }
...@@ -15,6 +15,18 @@ ...@@ -15,6 +15,18 @@
{ {
"Payload": {
"authorization": "Bearer test",
"data-partition-id": "test",
"AppKey": "test",
"kind_version": "3.0.0",
"acl": {
"viewers": ["data.default.viewers"],
"owners": ["data.default.owners"]},
"legal": {
"legaltags": ["odes-demo-legaltag"],
"otherRelevantDataCountries": ["FR", "US", "CA"]}
},
"WorkProduct": { "WorkProduct": {
"ResourceTypeID": "srn:type:work-product/WellLog:", "ResourceTypeID": "srn:type:work-product/WellLog:",
"ResourceSecurityClassification": "srn:reference-data/ResourceSecurityClassification:RESTRICTED:", "ResourceSecurityClassification": "srn:reference-data/ResourceSecurityClassification:RESTRICTED:",
...@@ -106,12 +118,6 @@ ...@@ -106,12 +118,6 @@
] ]
} }
], ],
"Payload": {
"authorization": "Bearer test",
"data-partition-id": "test",
"AppKey": "test",
"kind_version": "3.0.0"
},
"Files": [ "Files": [
{ {
"ResourceTypeID": "srn:type:file/las2:", "ResourceTypeID": "srn:type:file/las2:",
......
...@@ -55,7 +55,13 @@ CONF = { ...@@ -55,7 +55,13 @@ CONF = {
"authorization": "Bearer test", "authorization": "Bearer test",
"data-partition-id": "test", "data-partition-id": "test",
"AppKey": "test", "AppKey": "test",
"kind_version": "3.0.0" "kind_version": "3.0.0",
"acl": {
"viewers": ["data.default.viewers@odes.osdu.joonix.net"],
"owners": ["data.default.owners@odes.osdu.joonix.net"]},
"legal": {
"legaltags": ["odes-demo-legaltag"],
"otherRelevantDataCountries": ["FR", "US", "CA"]}
}, },
"Files": [ "Files": [
{ {
...@@ -104,3 +110,13 @@ LOADED_CONF = { ...@@ -104,3 +110,13 @@ LOADED_CONF = {
} }
CONF_PAYLOAD = CONF["Payload"] CONF_PAYLOAD = CONF["Payload"]
class DAG_RUN:
def __init__(self):
self.conf = CONF
DAG_RUN_CONF = {
"dag_run": DAG_RUN()
}
...@@ -58,3 +58,15 @@ def test_process_file_items(data_type, loaded_conf, conf_payload, expected_file_ ...@@ -58,3 +58,15 @@ def test_process_file_items(data_type, loaded_conf, conf_payload, expected_file_
assert file_id_regex.match(i[0]["data"]["ResourceID"]) assert file_id_regex.match(i[0]["data"]["ResourceID"])
i[0]["data"]["ResourceID"] = "" i[0]["data"]["ResourceID"] = ""
assert file_list == expected_file_list assert file_list == expected_file_list
@pytest.mark.parametrize(
"dag_run",
[
(test_data.DAG_RUN_CONF)
]
)
def test_dataload_conf(dag_run):
loaded_conf, conf_payload = process_manifest_r2.dataload(**dag_run)
assert loaded_conf["acl"] == test_data.CONF["Payload"]["acl"]
assert loaded_conf["legal_tag"] == test_data.CONF["Payload"]["legal"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment