Skip to content
Snippets Groups Projects
Commit 6196ef30 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Allow access to the DataFile S3 URL to IIIF processes

parent 9c542aba
No related branches found
No related tags found
1 merge request!2067Allow access to the DataFile S3 URL to IIIF processes
......@@ -41,11 +41,11 @@ class DataFileSerializer(serializers.ModelSerializer):
def get_s3_url(self, obj):
if 'request' not in self.context:
return
# Only allow the S3 URL for ponos tasks of Files processes or admins
# Only allow the S3 URL for ponos tasks of Files or IIIF processes or admins
request = self.context['request']
if is_admin_or_ponos_task(request):
request_process = get_process_from_task_auth(request)
if not request_process or request_process.mode == ProcessMode.Files:
if not request_process or request_process.mode in (ProcessMode.Files, ProcessMode.IIIF):
return obj.s3_url
......
......@@ -157,7 +157,7 @@ class TestDataFileApi(FixtureAPITestCase):
def test_retrieve_datafile_s3_url_task_process_mode(self, gen_url_mock):
"""
Ponos task authentication allows access to the S3 URL, only if the task's
parent process is of Files ProcessMode.
parent process has a Files or IIIF mode.
"""
user = User.objects.create(email='user2@test.test', display_name='User 2', verified_email=True)
gen_url_mock.return_value = 'http://somewhere'
......@@ -170,7 +170,7 @@ class TestDataFileApi(FixtureAPITestCase):
with self.settings(IMPORTS_WORKER_VERSION=str(self.import_worker_version.id)):
process.start()
cases = [
(process_mode, 'http://somewhere' if process_mode == ProcessMode.Files else None)
(process_mode, 'http://somewhere' if process_mode in (ProcessMode.Files, ProcessMode.IIIF) else None)
for process_mode in ProcessMode
]
for process_mode, s3_url in cases:
......
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