🔒️(backend) prevent accessing files if they are not ready

With the addition of the ANALYSING state
files could be accessed in the short time they
were in that state.
We now require files to be in ready.

Also adds missing frontend types (no impact).
This commit is contained in:
Florent Chehab
2026-06-03 15:15:24 +02:00
parent 22b2e6bd1e
commit c79984a883
7 changed files with 16 additions and 11 deletions
@@ -86,7 +86,11 @@ def test_api_files_media_get_own():
assert response.content.decode("utf-8") == "my prose"
def test_api_files_media_auth_file_pending():
@pytest.mark.parametrize(
"rejecting_status",
[models.FileUploadStateChoices.PENDING, models.FileUploadStateChoices.ANALYZING],
)
def test_api_files_media_auth_rejects(rejecting_status):
"""
Users who have a specific access to an file, whatever the role, should not be able to
retrieve related attachments if the file is not ready.
@@ -97,7 +101,7 @@ def test_api_files_media_auth_file_pending():
file = factories.FileFactory(
type=models.FileTypeChoices.BACKGROUND_IMAGE,
upload_state=models.FileUploadStateChoices.PENDING,
upload_state=rejecting_status,
creator=user,
)