Admin: allow changing your own quota

The self-protection guard refused every change to the admin's own account.
It now only refuses blocking and deleting yourself; a quota change is fine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 15:39:33 +01:00
co-authored by Claude Opus 5.5
parent a4581ab199
commit 77e9c25353
2 changed files with 25 additions and 6 deletions
+14
View File
@@ -168,6 +168,20 @@ async def test_admin_cannot_block_or_delete_themselves(world: World) -> None:
assert (await c.delete(f"/api/admin/users/{admin.id}")).status_code == 409
async def test_admin_can_change_their_own_quota(world: World) -> None:
admin = await world.user(admin=True)
async with await world.client(admin) as c:
resp = await c.patch(f"/api/admin/users/{admin.id}", json={"quota_bytes": 5 * 2**30})
assert resp.status_code == 200
assert resp.json()["quota_bytes"] == 5 * 2**30
# Quota together with a block is still refused: the block is the problem.
assert (
await c.patch(
f"/api/admin/users/{admin.id}", json={"quota_bytes": 2**30, "blocked": True}
)
).status_code == 409
async def test_delete_removes_the_user_and_their_data(world: World, bus: _Bus) -> None:
admin = await world.user(admin=True)
target = await world.user()