Add backend test suite covering auth, ownership and the query surface

The API had no tests. These run against the real application through
WebApplicationFactory — same pipeline, same Identity configuration, same JWT
validation — with only the SQLite file, upload folder and signing key
swapped, so a passing test says something about what ships.

The ownership tests pin the rule the old PHP API got wrong: a second user
sees an empty library, gets 404 (not 403, which would confirm the id exists)
when reading, updating or deleting someone else's game, and cannot reassign
ownership by putting ownerId or userId in the request body.

Also covered: the password policy, that login is indistinguishable between a
wrong password and an absent user, that the availability endpoint leaks no
row data, that a token signed with an untrusted key is refused, that the
sort parameter is allow-listed rather than interpolated, and that uploads
must decode as an image regardless of extension or content type.

36 tests, ~1s. Program is now declared public partial so the test host can
reach it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-04 12:16:33 -04:00
co-authored by Claude Opus 5
parent cd5c8fb24e
commit 130921cf89
8 changed files with 794 additions and 0 deletions
+3
View File
@@ -2,4 +2,7 @@
<Folder Name="/src/">
<Project Path="src/LudosData.Api/LudosData.Api.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/LudosData.Api.Tests/LudosData.Api.Tests.csproj" />
</Folder>
</Solution>