Skip to content

Commit cf1a352

Browse files
nadove-ucschannes-ucsc
authored andcommitted
IT allows 401 responses for file downloads from outside of Terra (#7660)
1 parent dcbbf2b commit cf1a352

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

test/integration_test.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,24 +1145,31 @@ def _test_repository_files(self, catalog: CatalogName):
11451145
self.assertIsNone(file_url, inner_file)
11461146
self.assertEqual('lungmap', config.catalogs[catalog].atlas, inner_file)
11471147

1148-
def _test_file_download(self, source: SourceSpec, file: JSON) -> mutable_furl:
1148+
def _test_file_download(self, source: SourceSpec, file: JSON) -> mutable_furl | None:
11491149
file_url = furl(file['azul_url'])
11501150
# FIXME: Use _check_endpoint() instead
11511151
# https://github.com/DataBiosphere/azul/issues/7373
11521152
self.assertEqual(file_url.path.segments[0], 'repository')
11531153
file_url.path.segments.insert(0, 'fetch')
11541154
response = self._get_url_unchecked(GET, file_url)
1155-
self.assertEqual(200, response.status)
1156-
response = json.loads(response.data)
1157-
while response['Status'] != 302:
1158-
self.assertEqual(301, response['Status'])
1155+
if response.status == 401:
1156+
msg = json.loads(response.data)['Message']
1157+
prefix = 'Unexpected response from '
1158+
self.assertEqual(prefix, msg[:len(prefix)])
1159+
self.assertNotIn(str(config.tdr_service_url), msg)
1160+
return None
1161+
else:
1162+
self.assertEqual(200, response.status)
1163+
response = json.loads(response.data)
1164+
while response['Status'] != 302:
1165+
self.assertEqual(301, response['Status'])
1166+
self.assertNotIn('Retry-After', response)
1167+
response = self._get_url_json(GET, furl(response['Location']))
11591168
self.assertNotIn('Retry-After', response)
1160-
response = self._get_url_json(GET, furl(response['Location']))
1161-
self.assertNotIn('Retry-After', response)
1162-
final_file_url = furl(response['Location'])
1163-
response = self._get_url(GET, final_file_url, stream=True)
1164-
self._validate_file_response(response, source, file)
1165-
return final_file_url
1169+
final_file_url = furl(response['Location'])
1170+
response = self._get_url(GET, final_file_url, stream=True)
1171+
self._validate_file_response(response, source, file)
1172+
return final_file_url
11661173

11671174
def _file_ext(self, file: JSON) -> str:
11681175
# We believe that the file extension is a more reliable indicator than
@@ -1795,6 +1802,7 @@ def _delete():
17951802
aws.mirror_bucket, '_it', 'file', f'{digest.value}.{digest.type}',
17961803
])
17971804
actual_url = self._test_file_download(source.spec, file_response)
1805+
self.assertIsNotNone(actual_url)
17981806
actual_url.set(args=None)
17991807
self.assertEqual(expected_url, actual_url)
18001808
_delete()

0 commit comments

Comments
 (0)