Skip to content

Fix/upload filename and polish - #38

Merged
AsierCL merged 5 commits into
mainfrom
fix/upload-filename-and-polish
Nov 5, 2026
Merged

AsierCL merged 5 commits into
mainfrom
fix/upload-filename-and-polish

Conversation

@AsierCL

@AsierCL AsierCL commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

The test profile shares a single in-memory H2 across test classes, so every
class has to clean up after the previous one. AuthRateLimitIntegrationTest only
deleted users, which broke as soon as GovernanceRulesIntegrationTest ran right
before it in CI (file_proposal FK). GlobalJourneyIntegrationTest had the full
ordered list; AuthRateLimit got a copy. Two lists drift.

Move the order into TestDatabaseCleaner and use it from all three classes.

Verified: 129/129 in default order and with -Dsurefire.runOrder=reversealphabetical;
GovernanceRulesIntegrationTest -> AuthRateLimitIntegrationTest passes.
The original filename comes from the client and is stored in
original_filename varchar(255); it also travels in the Content-Disposition of
the download URL. Two cases broke:

- a name longer than the column made the upload fail with 409
  DATA_INTEGRITY_ERROR (found while verifying #35);
- a name with path components ('../../etc/notas.pdf') was stored as-is.

FileNames.sanitize keeps the last path segment, drops control characters and
truncates to 255 characters preserving the extension. It is applied on upload
and again when building the Content-Disposition, so rows stored before this
change are also safe.

Tests (new OriginalFilenameIntegrationTest) assert the visible effect: the
filename declared in the signed download URL.

Verified RED first: long name -> 409, path kept. GREEN after the change.
The loader checked whether the key was already defined after doing the
quote-stripping work. Checking right after validating the key is equivalent and
skips work that was thrown away.
- 126 -> 129 tests, 17 -> 18 suite classes.
- OriginalFilenameIntegrationTest documented (long name, path components,
  normal name) and what it actually asserts.
- The migration negative case is a manual probe, not an automated test.
- TestDatabaseCleaner is the single place for the FK-safe cleanup order.
Section 18 was inserted before 17, and the previous fix attempt moved it past
the coverage summary. 15..18 now run in order and the summary stays last.
Found by the review of this same PR.
@AsierCL
AsierCL merged commit 140b7e5 into main Nov 5, 2026
2 checks passed
@AsierCL
AsierCL deleted the fix/upload-filename-and-polish branch November 5, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant