Skip to content

Commit 81bb5bc

Browse files
committed
CMR-10388: Checking return type from access control
1 parent b4a8c25 commit 81bb5bc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

subscription/src/access_control.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def get_url_from_parameter_store(self):
6666
port = env_vars.get_var(name=port_param_name)
6767
host = env_vars.get_var(name=host_param_name)
6868
context = env_vars.get_var(name=context_param_name)
69-
self.url = f"{protocol}://{host}:{port}/{context}"
69+
70+
# The context already contains the forward / so we don't need it here.
71+
self.url = f"{protocol}://{host}:{port}{context}"
7072
logger.debug(f"Subscription Worker Access-Control URL: {self.url}")
7173

7274
def get_url(self):
@@ -110,10 +112,11 @@ def has_read_permission(self, subscriber_id, collection_concept_id):
110112

111113
try:
112114
# Call the get_permissions function
113-
permissions = self.get_permissions(subscriber_id, collection_concept_id)
114-
logger.info(f"The type of object the permissions is: {type(permissions)}")
115-
logger.info(f"If its json then turn it into a Dictionary: {json.load(permissions)}")
115+
permissions_str = self.get_permissions(subscriber_id, collection_concept_id)
116+
logger.info(f"The type of object the permissions is: {type(permissions_str)}")
117+
logger.info(f"If its json then turn it into a Dictionary: {json.loads(permissions_str)}")
116118

119+
permissions = json.loads(permissions_str)
117120

118121
# Check if the permissions is a dictionary
119122
if isinstance(permissions, dict):

subscription/test/access_control_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_get_url_from_parameter_store_local(self):
2020
def test_get_url_from_parameter_store_aws(self, mock_env_vars):
2121
mock_env_vars_instance = MagicMock()
2222
mock_env_vars_instance.get_var.side_effect = [
23-
"https", "3011", "cmr.sit.earthdata.nasa.gov", "access-control"
23+
"https", "3011", "cmr.sit.earthdata.nasa.gov", "/access-control"
2424
]
2525
mock_env_vars.return_value = mock_env_vars_instance
2626

0 commit comments

Comments
 (0)