Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions db/seed/Member.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ wicar@dfds.com;Willi hehe;wicar@dfds.com;"{""signedUpForDemos"":true}";User
emwee@dfds.com;Emil Weee;emwee@dfds.com;"{""signedUpForDemos"":false}";User
ewica@dfds.com;Emil Carlsen;ewica@dfds.com;"{""signedUpForDemos"":true}";User
emcla@dfds.com;Emil Clausen;emcla@dfds.com;"{""signedUpForDemos"":true}";User
owner@bar.com;Owner Bar;owner@bar.com;"{""signedUpForDemos"":false}";User
contributor@bar.com;Contributor Bar;contributor@bar.com;"{""signedUpForDemos"":false}";User
reader@bar.com;Reader Bar;reader@bar.com;"{""signedUpForDemos"":false}";User
9 changes: 6 additions & 3 deletions db/seed/RbacGroup.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Id;CreatedAt;UpdatedAt;Name;Description
BA0AA734-206D-454E-AC95-14855B6901E4;2026-07-23T09:15:35.803168;2026-07-23T09:15:35.803174;CloudEngineers;Group: CloudEngineers
899F8F9E-3F7E-4EF3-A2CD-2E1DDA78E40A;2026-07-23T09:15:35.803179;2026-07-23T09:15:35.803180;BatchCapabilityCreators;Group: BatchCapabilityCreators
7D3D7498-9075-4D1B-B6C1-AF6E95788C3B;2026-07-23T09:15:35.803184;2026-07-23T09:15:35.803185;ServiceCatalogueReaders;Group: ServiceCatalogueReaders
BA0AA734-206D-454E-AC95-14855B6901E4;2026-07-28T08:00:09.521076+00:00;2026-07-28T08:00:09.521078+00:00;CloudEngineers;Group: CloudEngineers
890CC44E-2D09-5ACE-A1C3-F62560AE45F8;2026-07-28T08:00:09.521081+00:00;2026-07-28T08:00:09.521082+00:00;CapabilityOwnersBar;Group: CapabilityOwnersBar
12F13079-AD3A-5F64-9AD6-1A94D5F8C7C5;2026-07-28T08:00:09.521085+00:00;2026-07-28T08:00:09.521097+00:00;CapabilityContributorsBar;Group: CapabilityContributorsBar
7C72E0F1-6FBA-5165-94EA-7EE4A75C35A2;2026-07-28T08:00:09.521100+00:00;2026-07-28T08:00:09.521101+00:00;CapabilityReadersBar;Group: CapabilityReadersBar
899F8F9E-3F7E-4EF3-A2CD-2E1DDA78E40A;2026-07-28T08:00:09.521103+00:00;2026-07-28T08:00:09.521104+00:00;BatchCapabilityCreators;Group: BatchCapabilityCreators
7D3D7498-9075-4D1B-B6C1-AF6E95788C3B;2026-07-28T08:00:09.521106+00:00;2026-07-28T08:00:09.521107+00:00;ServiceCatalogueReaders;Group: ServiceCatalogueReaders
7 changes: 5 additions & 2 deletions db/seed/RbacGroupMember.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Id;GroupId;UserId;CreatedAt
7BADF960-B926-4BDC-A4BF-8B0CB444E292;BA0AA734-206D-454E-AC95-14855B6901E4;andfris@dfds.com;2026-07-23T09:15:35.803265
DEF609DD-40B7-4DEC-A430-0208C49555DB;BA0AA734-206D-454E-AC95-14855B6901E4;emcla@dfds.com;2026-07-23T09:15:35.803272
C4048DBD-0C0F-4E1D-9EDD-FBDECB5782D8;BA0AA734-206D-454E-AC95-14855B6901E4;andfris@dfds.com;2026-07-28T08:00:09.521137+00:00
18DEDFB3-BAE7-4E3F-8B4C-0A6A54978E98;BA0AA734-206D-454E-AC95-14855B6901E4;emcla@dfds.com;2026-07-28T08:00:09.521143+00:00
80594E92-85BC-42EC-9DC9-92D57896DCF3;890CC44E-2D09-5ACE-A1C3-F62560AE45F8;owner@bar.com;2026-07-28T08:00:09.521148+00:00
BDC31F2E-CAE0-4C29-B0F8-CC6FF32A92B4;12F13079-AD3A-5F64-9AD6-1A94D5F8C7C5;contributor@bar.com;2026-07-28T08:00:09.521152+00:00
B267C1CE-201C-47E5-AC1E-39EFB7977E79;7C72E0F1-6FBA-5165-94EA-7EE4A75C35A2;reader@bar.com;2026-07-28T08:00:09.521156+00:00
288 changes: 146 additions & 142 deletions db/seed/RbacPermissionGrants.csv

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions db/seed/RbacRole.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Id;OwnerId;CreatedAt;UpdatedAt;Name;Description;Type
36202DFB-D106-440D-8B99-F11BC8D77C9C;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801873;2026-07-23T09:15:35.801901;Owner;Role: Owner;Global
2C561A6D-90F4-4649-80B3-76A854A64EA2;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801908;2026-07-23T09:15:35.801909;Contributor;Role: Contributor;Global
22DAB91B-C2D8-4840-A173-1416EF1B882D;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801913;2026-07-23T09:15:35.801914;Reader;Role: Reader;Global
F67CACC9-8DD4-4481-AC15-00B5DD83B046;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801917;2026-07-23T09:15:35.801918;Guest;Role: Guest;Global
5E32EE6A-1A73-4ACF-9C61-90E4D0D59261;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801921;2026-07-23T09:15:35.801922;CloudEngineer;Role: CloudEngineer;Global
6A2EE52C-6A9B-4A2A-B9C8-5851DD2D9A6F;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801925;2026-07-23T09:15:35.801926;BatchCapabilityCreator;Role: BatchCapabilityCreator;Global
A983CF2E-772E-437D-B9D8-5DDF769339D3;0000DFD5-0000-0000-0000-00000000000A;2026-07-23T09:15:35.801929;2026-07-23T09:15:35.801930;ServiceCatalogueReader;Role: ServiceCatalogueReader;Global
36202DFB-D106-440D-8B99-F11BC8D77C9C;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520313+00:00;2026-07-28T08:00:09.520339+00:00;Owner;Role: Owner;Global
2C561A6D-90F4-4649-80B3-76A854A64EA2;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520344+00:00;2026-07-28T08:00:09.520345+00:00;Contributor;Role: Contributor;Global
22DAB91B-C2D8-4840-A173-1416EF1B882D;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520349+00:00;2026-07-28T08:00:09.520350+00:00;Reader;Role: Reader;Global
F67CACC9-8DD4-4481-AC15-00B5DD83B046;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520353+00:00;2026-07-28T08:00:09.520354+00:00;Guest;Role: Guest;Global
5E32EE6A-1A73-4ACF-9C61-90E4D0D59261;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520356+00:00;2026-07-28T08:00:09.520357+00:00;CloudEngineer;Role: CloudEngineer;Global
6A2EE52C-6A9B-4A2A-B9C8-5851DD2D9A6F;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520360+00:00;2026-07-28T08:00:09.520361+00:00;BatchCapabilityCreator;Role: BatchCapabilityCreator;Global
A983CF2E-772E-437D-B9D8-5DDF769339D3;0000DFD5-0000-0000-0000-00000000000A;2026-07-28T08:00:09.520364+00:00;2026-07-28T08:00:09.520364+00:00;ServiceCatalogueReader;Role: ServiceCatalogueReader;Global
12 changes: 6 additions & 6 deletions db/seed/RbacRoleGrants.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Id;RoleId;CreatedAt;AssignedEntityType;AssignedEntityId;Type;Resource
E02D91E6-DE3C-4C55-BC0A-EDABD1492197;5E32EE6A-1A73-4ACF-9C61-90E4D0D59261;2026-07-23T09:15:35.803819;Group;BA0AA734-206D-454E-AC95-14855B6901E4;Global;
4CE54588-72CB-4B27-93D3-7F842B9C91AF;6A2EE52C-6A9B-4A2A-B9C8-5851DD2D9A6F;2026-07-23T09:15:35.803831;Group;899F8F9E-3F7E-4EF3-A2CD-2E1DDA78E40A;Global;
059F294D-4FD4-4836-9B11-9A7E8FA125C7;A983CF2E-772E-437D-B9D8-5DDF769339D3;2026-07-23T09:15:35.803837;Group;7D3D7498-9075-4D1B-B6C1-AF6E95788C3B;Global;
F1F3A53C-3D8E-4D54-BF66-7FB67209B701;36202DFB-D106-440D-8B99-F11BC8D77C9C;2026-07-23T09:15:35.803840;User;owner@bar.com;Capability;bar
706A6EB8-4378-4F66-9D37-BC84601D57F0;2C561A6D-90F4-4649-80B3-76A854A64EA2;2026-07-23T09:15:35.803843;User;contributor@bar.com;Capability;bar
8D0D4C50-2336-4C1C-91D8-7654577F52B3;22DAB91B-C2D8-4840-A173-1416EF1B882D;2026-07-23T09:15:35.803846;User;reader@bar.com;Capability;bar
FAB12495-6C01-47ED-ACD5-89F26598E6AE;5E32EE6A-1A73-4ACF-9C61-90E4D0D59261;2026-07-28T08:00:09.521191+00:00;Group;BA0AA734-206D-454E-AC95-14855B6901E4;Global;
656007CA-4B1C-4371-B476-389B232471B7;36202DFB-D106-440D-8B99-F11BC8D77C9C;2026-07-28T08:00:09.521196+00:00;Group;890CC44E-2D09-5ACE-A1C3-F62560AE45F8;Capability;bar
8E22A84B-202B-4D55-99AB-4D5338085488;2C561A6D-90F4-4649-80B3-76A854A64EA2;2026-07-28T08:00:09.521201+00:00;Group;12F13079-AD3A-5F64-9AD6-1A94D5F8C7C5;Capability;bar
27433F2F-A40D-4D9D-AB5A-FE662CF35E24;22DAB91B-C2D8-4840-A173-1416EF1B882D;2026-07-28T08:00:09.521205+00:00;Group;7C72E0F1-6FBA-5165-94EA-7EE4A75C35A2;Capability;bar
C8430FA1-5AFA-4926-A6C8-DB4080535CF4;6A2EE52C-6A9B-4A2A-B9C8-5851DD2D9A6F;2026-07-28T08:00:09.521209+00:00;Group;899F8F9E-3F7E-4EF3-A2CD-2E1DDA78E40A;Global;
32F8845E-72C8-4BFB-BAD6-2313AB2D7E02;A983CF2E-772E-437D-B9D8-5DDF769339D3;2026-07-28T08:00:09.521213+00:00;Group;7D3D7498-9075-4D1B-B6C1-AF6E95788C3B;Global;
14 changes: 7 additions & 7 deletions src/SelfService.Tests/Application/TestRbacApplicationService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using SelfService.Application;
using SelfService.Domain.Models;
Expand Down Expand Up @@ -402,7 +402,7 @@ await rbacSvc.IsUserPermitted(
(
await rbacSvc.IsUserPermitted(
"test01@dfds.cloud",
[new Permission { Namespace = RbacNamespace.CapabilityManagement, Name = "request-deletion" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "request-deletion" }],
"test01"
)
).Permitted()
Expand Down Expand Up @@ -590,7 +590,7 @@ await rbacSvc.IsUserPermitted(
(
await rbacSvc.IsUserPermitted(
"owner@bar.com",
[new Permission { Namespace = RbacNamespace.CapabilityMembershipManagement, Name = "create" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "invite-member" }],
"bar"
)
).Permitted()
Expand All @@ -600,7 +600,7 @@ await rbacSvc.IsUserPermitted(
(
await rbacSvc.IsUserPermitted(
"owner@bar.com",
[new Permission { Namespace = RbacNamespace.CapabilityMembershipManagement, Name = "delete" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "remove-member" }],
"bar"
)
).Permitted()
Expand All @@ -625,7 +625,7 @@ public async void CapabilityContributorAccessUsingDbStore()
(
await rbacSvc.IsUserPermitted(
"contributor@bar.com",
[new Permission { Namespace = RbacNamespace.CapabilityManagement, Name = "delete" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "remove-member" }],
"bar"
)
).Permitted()
Expand Down Expand Up @@ -665,7 +665,7 @@ await rbacSvc.IsUserPermitted(
(
await rbacSvc.IsUserPermitted(
"contributor@bar.com",
[new Permission { Namespace = RbacNamespace.CapabilityMembershipManagement, Name = "create" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "invite-member" }],
"bar"
)
).Permitted()
Expand Down Expand Up @@ -710,7 +710,7 @@ await rbacSvc.IsUserPermitted(
(
await rbacSvc.IsUserPermitted(
"reader@bar.com",
[new Permission { Namespace = RbacNamespace.CapabilityManagement, Name = "delete" }],
[new Permission { Namespace = RbacNamespace.Capability, Name = "remove-member" }],
"bar"
)
).Permitted()
Expand Down
45 changes: 39 additions & 6 deletions src/SelfService.Tests/Application/TestRbacBulkAndMembers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ public async Task GrantPermissions_bulk_creates_all_on_success()
populateDatabase: true,
rbacRoleGrantsSeed: new List<RbacRoleGrant>(),
rbacGroupSeed: new List<RbacGroup>(),
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>()
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>
{
RbacPermissionGrant.New(
AssignedEntityType.User,
"ce@dfds.com",
RbacNamespace.Rbac,
"create",
RbacAccessType.Global,
""
),
}
);
var svc = fixture.ApiApplication.Services.GetService<IRbacApplicationService>()!;

Expand Down Expand Up @@ -45,9 +55,12 @@ public async Task GrantPermissions_bulk_creates_all_on_success()
await fixture.DbContext.SaveChangesAsync();

var allGrants = await fixture.DbContext.RbacPermissionGrants.ToListAsync();
Assert.Equal(2, allGrants.Count);
Assert.Contains(allGrants, g => g.AssignedEntityId == "alice@dfds.com");
Assert.Contains(allGrants, g => g.AssignedEntityId == "bob@dfds.com");
var createdByBulk = allGrants
.Where(g => g.AssignedEntityId == "alice@dfds.com" || g.AssignedEntityId == "bob@dfds.com")
.ToList();
Assert.Equal(2, createdByBulk.Count);
Assert.Contains(createdByBulk, g => g.AssignedEntityId == "alice@dfds.com");
Assert.Contains(createdByBulk, g => g.AssignedEntityId == "bob@dfds.com");
}

[Fact]
Expand All @@ -57,7 +70,17 @@ public async Task GrantPermissions_bulk_rolls_back_atomically_on_failure()
populateDatabase: true,
rbacRoleGrantsSeed: new List<RbacRoleGrant>(),
rbacGroupSeed: new List<RbacGroup>(),
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>()
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>
{
RbacPermissionGrant.New(
AssignedEntityType.User,
"ce@dfds.com",
RbacNamespace.Rbac,
"create",
RbacAccessType.Global,
""
),
}
);
var svc = fixture.ApiApplication.Services.GetService<IRbacApplicationService>()!;

Expand Down Expand Up @@ -94,7 +117,17 @@ public async Task GrantGroupGrant_accepts_service_principal_member()

var fixture = await RbacTestData.NewInMemoryFixture(
populateDatabase: true,
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>(),
rbacPermissionGrantsSeed: new List<RbacPermissionGrant>
{
RbacPermissionGrant.New(
AssignedEntityType.User,
"ce@dfds.com",
RbacNamespace.Rbac,
"create",
RbacAccessType.Global,
""
),
},
rbacRoleGrantsSeed: new List<RbacRoleGrant>(),
rbacGroupSeed: new List<RbacGroup> { seedGroup }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static async Task<Scenario> NewScenario()
RbacPermissionGrant.New(
AssignedEntityType.Role,
ownerRole.Id.ToString(),
RbacNamespace.CapabilityManagement,
RbacNamespace.Capability,
"manage-permissions",
RbacAccessType.Capability,
""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public async Task InitializeAsync()
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.Topics,
"delete",
"delete-public",
RbacAccessType.Capability,
"foo"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.TopicsPublic,
"delete",
RbacNamespace.Topics,
"delete-public",
RbacAccessType.Capability,
"foo"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public async Task InitializeAsync()
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.Topics,
"delete",
"delete-public",
RbacAccessType.Global,
"*"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.TopicsPublic,
"delete",
RbacNamespace.Topics,
"delete-public",
RbacAccessType.Global,
"*"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public async Task InitializeAsync()
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"read-requests",
RbacAccessType.Capability,
"foo"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"manage-requests",
RbacAccessType.Capability,
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public async Task InitializeAsync()
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"read-requests",
RbacAccessType.Capability,
"foo"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"manage-requests",
RbacAccessType.Capability,
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task InitializeAsync()
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"read-requests",
RbacAccessType.Capability,
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public async Task InitializeAsync()
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"read-requests",
RbacAccessType.Capability,
"foo"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"manage-requests",
RbacAccessType.Capability,
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public async Task InitializeAsync()
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"read-requests",
RbacAccessType.Capability,
"foo"
),
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityMembershipManagement,
RbacNamespace.Capability,
"manage-requests",
RbacAccessType.Capability,
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async Task get_capability_by_id_returns_expected_allow_on_aws_account_lin
RbacPermissionGrant.New(
AssignedEntityType.User,
"foo@bar.com",
RbacNamespace.CapabilityManagement,
RbacNamespace.Capability,
"read",
RbacAccessType.Capability,
stubCapability.Id.ToString()
Expand Down
Loading
Loading