Skip to content

Commit

Permalink
chore: list users and groups under each role in projectaccessadded ev…
Browse files Browse the repository at this point in the history
…ent (#5581)

## About the changes

Changes the project access added event to list all users and groups
added to each role instead of in root event.
  • Loading branch information
daveleek authored Dec 19, 2023
1 parent 7800d9d commit 5603e86
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/lib/routes/admin-api/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ test('should anonymise any PII fields, no matter the depth', async () => {
createdBy: '[email protected]',
createdByUserId: TEST_USER_ID,
data: {
groups: [
roles: [
{
name: 'test',
project: 'default',
users: [{ username: testUsername }],
roleId: 1,
groupIds: [1, 2],
// Doesn't reflect the real data structure for event here, normally a number array.
// Testing PII anonymisation
users: [{ id: 1, username: testUsername }],
},
],
},
Expand All @@ -138,7 +140,7 @@ test('should anonymise any PII fields, no matter the depth', async () => {
.expect(200);

expect(body.events.length).toBe(1);
expect(body.events[0].data.groups[0].users[0].username).not.toBe(
expect(body.events[0].data.roles[0].users[0].username).not.toBe(
testUsername,
);
});
18 changes: 12 additions & 6 deletions src/lib/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,11 @@ export default class ProjectService {
createdBy,
createdByUserId,
data: {
roleId,
groups: usersAndGroups.groups.map(({ id }) => id),
users: usersAndGroups.users.map(({ id }) => id),
roles: {
roleId,
groupIds: usersAndGroups.groups.map(({ id }) => id),
userIds: usersAndGroups.users.map(({ id }) => id),
},
},
}),
);
Expand Down Expand Up @@ -711,9 +713,13 @@ export default class ProjectService {
createdBy,
createdByUserId,
data: {
roles,
groups,
users,
roles: roles.map((roleId) => {
return {
roleId,
groupIds: groups,
userIds: users,
};
}),
},
}),
);
Expand Down

0 comments on commit 5603e86

Please sign in to comment.