From e80d324b4f3e77db1773e9ffdb2db9b393b97a40 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sun, 8 Nov 2026 21:30:36 +0100 Subject: [PATCH] Test: een Eigenaar kan elke rol instellen op een ander account Co-Authored-By: Claude Sonnet 5.5 --- .../Controllers/UsersApiWithRealTokensTests.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/SlpModularCms.Modules.Identity.Tests/Controllers/UsersApiWithRealTokensTests.cs b/src/SlpModularCms.Modules.Identity.Tests/Controllers/UsersApiWithRealTokensTests.cs index 06455a2..dc0bada 100644 --- a/src/SlpModularCms.Modules.Identity.Tests/Controllers/UsersApiWithRealTokensTests.cs +++ b/src/SlpModularCms.Modules.Identity.Tests/Controllers/UsersApiWithRealTokensTests.cs @@ -158,6 +158,22 @@ public class UsersApiWithRealTokensTests : IAsyncLifetime (await SendAsync(token, HttpMethod.Delete, $"/Users/{admin.Id}")).Should().Be(HttpStatusCode.NoContent); } + [Fact] + public async Task AnOwner_CanSetEveryRoleOnAnotherAccount_WhileTheLastOwnerRuleStillHolds() + { + await AddUserAsync("andrea@test.nl", "Owner"); + var second = await AddUserAsync("second@test.nl", "Owner"); + var user = await AddUserAsync("user@test.nl", "User"); + var token = await TokenAsync("andrea@test.nl"); + + (await ChangeRoleAsync(token, user.Id, "Administrator")).Should().Be(HttpStatusCode.OK); // User -> Administrator + (await ChangeRoleAsync(token, user.Id, "Owner")).Should().Be(HttpStatusCode.OK); // Administrator -> Owner + (await ChangeRoleAsync(token, second.Id, "Administrator")).Should().Be(HttpStatusCode.OK); // Owner -> Administrator (two others remain) + (await ChangeRoleAsync(token, user.Id, "User")).Should().Be(HttpStatusCode.OK); // Owner -> User + (await RoleOfAsync(second.Id)).Should().Be("Administrator"); + (await RoleOfAsync(user.Id)).Should().Be("User"); + } + // ---- the Administrator is held to the hierarchy [Fact]