fix(identity): harden user lifecycle and permissions (#136)
Heimdall Gitea / Detect CI scope (push) Successful in 7s
Heimdall Gitea / Build and tests (push) Successful in 14m48s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan server image (push) Successful in 4m27s
Heimdall Gitea / Build and scan agent image (push) Successful in 15m42s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 1m27s
Heimdall Gitea / CI policy (push) Successful in 2s

Co-authored-by: Arnaud Dartois <admin@tordais.cc>
This commit was merged in pull request #136.
This commit is contained in:
arnaud.dartois authored and Arnaud Dartois committed 2026-11-04 13:33:30 +01:00
1 parent ea5f0b7589
commit 89c4c43922
153 files changed
+5218 -1681

No files matched your search

@@ -69,4 +69,30 @@ public class UsersControllerTests : PostgresTestBase
var resetContent = await resetResponse.Content.ReadFromJsonAsync<JsonElement>();
resetContent.GetProperty("temporaryPassword").GetString().ShouldNotBeNullOrEmpty();
}
[Fact]
public async Task Last_unlocked_admin_cannot_be_locked_when_another_admin_is_already_locked()
{
var admin = await Factory.CreateAdminClientAsync();
var list = await admin.GetFromJsonAsync<JsonElement>("api/users?page=1&pageSize=20");
var firstAdminId = list.GetProperty("items").EnumerateArray()
.Single(user => user.GetProperty("roles").EnumerateArray().Any(role => role.GetString() == "Admin"))
.GetProperty("id").GetGuid();
var created = await admin.PostAsJsonAsync("api/users", new
{
email = $"extra-admin-{Guid.NewGuid():N}@heimdall.test",
password = "ExtraAdmin123!",
displayName = "Extra Admin",
roles = new[] { "Admin" }
});
created.EnsureSuccessStatusCode();
var secondAdminId = (await created.Content.ReadFromJsonAsync<JsonElement>())
.GetProperty("id").GetGuid();
(await admin.PostAsync($"api/users/{secondAdminId}/lock", null)).StatusCode
.ShouldBe(System.Net.HttpStatusCode.OK);
var lockLast = await admin.PostAsync($"api/users/{firstAdminId}/lock", null);
lockLast.StatusCode.ShouldBe(System.Net.HttpStatusCode.BadRequest);
}
}