Skip to content

feat: Delete granule endpoint #485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: wrong authorization action
  • Loading branch information
wphyojpl committed Dec 16, 2024
commit 93dfa3da3278636c29a057e9b25abc0e9a7b97ea
2 changes: 1 addition & 1 deletion cumulus_lambda_functions/uds_api/granules_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async def delete_single_granule_dapa(request: Request, collection_id: str, granu
)
auth_info = FastApiUtils.get_authorization_info(request)
collection_identifier = UdsCollections.decode_identifier(collection_id)
if not authorizer.is_authorized_for_collection(DBConstants.read, collection_id,
if not authorizer.is_authorized_for_collection(DBConstants.delete, collection_id,
auth_info['ldap_groups'],
collection_identifier.tenant,
collection_identifier.venue):
Expand Down
30 changes: 15 additions & 15 deletions tests/integration_tests/test_granules_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ def setUp(self) -> None:

self.tenant = 'UDS_LOCAL_TEST_3' # 'uds_local_test' # 'uds_sandbox'
self.tenant_venue = 'DEV' # 'DEV1' # 'dev'
self.collection_name = 'AAA' # 'uds_collection' # 'sbx_collection'
self.collection_version = '24.03.20.14.40'.replace('.', '') # '2402011200'
self.collection_name = 'AAA-04' # 'uds_collection' # 'sbx_collection'
self.collection_version = '08'.replace('.', '') # '2402011200'
return

def test_query_all(self):
collection_id = f'URN:NASA:UNITY:{self.tenant}:{self.tenant_venue}:{self.collection_name}-01___001'
granule_id = f'{collection_id}:test_file01'
def test_delete_all(self):
collection_id = f'URN:NASA:UNITY:{self.tenant}:{self.tenant_venue}:{self.collection_name}___001'
post_url = f'{self.uds_url}collections/{collection_id}/items/' # MCP Dev
headers = {
'Authorization': f'Bearer {self.bearer_token}',
Expand All @@ -49,19 +48,20 @@ def test_query_all(self):
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
response_json = json.loads(query_result.text)
print(json.dumps(response_json, indent=4))
return
self.assertTrue(len(response_json['features']) > 0, f'empty collection :(')
deleting_granule_id = response_json['features'][0]['id']

def test_delete_01(self):
collection_id = f'URN:NASA:UNITY:{self.tenant}:{self.tenant_venue}:{self.collection_name}-01___001'
granule_id = f'{collection_id}:test_file01'
post_url = f'{self.uds_url}collections/{collection_id}/items/{granule_id}' # MCP Dev
headers = {
'Authorization': f'Bearer {self.bearer_token}',
}
post_url = f'{self.uds_url}collections/{collection_id}/items/{deleting_granule_id}' # MCP Dev
print(post_url)
query_result = requests.delete(url=post_url,
headers=headers,
)
headers=headers,
)
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
response_json = json.loads(query_result.text)
print(json.dumps(response_json, indent=4))

post_url = f'{self.uds_url}collections/{collection_id}/items/' # MCP Dev
query_result = requests.get(url=post_url, headers=headers,)
self.assertEqual(query_result.status_code, 200, f'wrong status code. {query_result.text}')
response_json = json.loads(query_result.text)
print(json.dumps(response_json, indent=4))
Expand Down
Loading