From 6196ef3014a0f39f2920a6b26db6f0d644290d7d Mon Sep 17 00:00:00 2001 From: Erwan Rouchet <rouchet@teklia.com> Date: Mon, 24 Jul 2023 12:21:48 +0200 Subject: [PATCH] Allow access to the DataFile S3 URL to IIIF processes --- arkindex/process/serializers/files.py | 4 ++-- arkindex/process/tests/test_datafile_api.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arkindex/process/serializers/files.py b/arkindex/process/serializers/files.py index a4edb516bc..43a5900bc2 100644 --- a/arkindex/process/serializers/files.py +++ b/arkindex/process/serializers/files.py @@ -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 diff --git a/arkindex/process/tests/test_datafile_api.py b/arkindex/process/tests/test_datafile_api.py index 2e849abf2d..d001863eac 100644 --- a/arkindex/process/tests/test_datafile_api.py +++ b/arkindex/process/tests/test_datafile_api.py @@ -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: -- GitLab