-
-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Cherry pick fix --------- Co-authored-by: Nuno Góis <[email protected]>
- Loading branch information
1 parent
3e3235e
commit 28e3747
Showing
4 changed files
with
73 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,6 +440,51 @@ describe('Managing Project access', () => { | |
), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test('Admin group members should be allowed to add any project role', async () => { | ||
const viewerUser = await stores.userStore.insert({ | ||
name: 'Some project admin', | ||
email: '[email protected]', | ||
}); | ||
await accessService.setUserRootRole(viewerUser.id, RoleName.VIEWER); | ||
|
||
const adminRole = await stores.roleStore.getRoleByName(RoleName.ADMIN); | ||
const adminGroup = await stores.groupStore.create({ | ||
name: 'admin_group', | ||
rootRole: adminRole.id, | ||
}); | ||
await stores.groupStore.addUsersToGroup( | ||
adminGroup.id, | ||
[{ user: { id: viewerUser.id } }], | ||
opsUser.username!, | ||
); | ||
|
||
const project = { | ||
id: 'some-project', | ||
name: 'sp', | ||
description: '', | ||
mode: 'open' as const, | ||
defaultStickiness: 'clientId', | ||
}; | ||
await projectService.createProject(project, user, auditUser); | ||
const customRole = await stores.roleStore.create({ | ||
name: 'my_custom_project_role_admin_user', | ||
roleType: 'custom', | ||
description: | ||
'Used to prove that you can assign a role when you are admin', | ||
}); | ||
|
||
await expect( | ||
projectService.addAccess( | ||
project.id, | ||
[customRole.id], // roles | ||
[], // groups | ||
[opsUser.id], // users | ||
extractAuditInfoFromUser(viewerUser), | ||
), | ||
).resolves.not.toThrow(); | ||
}); | ||
|
||
test('Users with project owner should be allowed to add any project role', async () => { | ||
const project = { | ||
id: 'project-owner', | ||
|
@@ -451,11 +496,11 @@ describe('Managing Project access', () => { | |
await projectService.createProject(project, user, auditUser); | ||
const projectAdmin = await stores.userStore.insert({ | ||
name: 'Some project admin', | ||
email: 'admin@example.com', | ||
email: 'some_other_project_admin@example.com', | ||
}); | ||
const projectCustomer = await stores.userStore.insert({ | ||
name: 'Some project customer', | ||
email: 'customer@example.com', | ||
email: 'some_project_customer@example.com', | ||
}); | ||
const ownerRole = await stores.roleStore.getRoleByName(RoleName.OWNER); | ||
await accessService.addUserToRole( | ||
|
@@ -464,7 +509,7 @@ describe('Managing Project access', () => { | |
project.id, | ||
); | ||
const customRole = await stores.roleStore.create({ | ||
name: 'my_custom_role', | ||
name: 'my_custom_project_role', | ||
roleType: 'custom', | ||
description: | ||
'Used to prove that you can assign a role the project owner does not have', | ||
|
@@ -477,7 +522,7 @@ describe('Managing Project access', () => { | |
[projectCustomer.id], | ||
auditUser, | ||
), | ||
).resolves; | ||
).resolves.not.toThrow(); | ||
}); | ||
test('Users with project role should only be allowed to grant same role to others', async () => { | ||
const project = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters