forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in dspace-cris-2023_02_x-DSC-1604-cris-security-check-subgroup…
…s (pull request DSpace#1982) Dspace cris 2023 02 x DSC-1604 cris security check subgroups Approved-by: Stefano Maffei
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 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 |
---|---|---|
|
@@ -310,6 +310,33 @@ public void testHasAccessWithSubmitterGroupConfig() throws SQLException, Authori | |
assertThat(crisSecurityService.hasAccess(context, item, anotherSubmitter, accessMode), is(true)); | ||
} | ||
|
||
@Test | ||
public void testHasAccessWithGroupChildOfResearchersConfig() throws SQLException { | ||
context.turnOffAuthorisationSystem(); | ||
Group researchersMainGroup = GroupBuilder.createGroup(context) | ||
.withName("Researchers") | ||
.build(); | ||
Group researcherSubGroup = GroupBuilder.createGroup(context) | ||
.withName("Researcher") | ||
.withParent(researchersMainGroup) | ||
.build(); | ||
EPerson firstUser = EPersonBuilder.createEPerson(context) | ||
.withEmail("[email protected]") | ||
.withGroupMembership(researcherSubGroup) | ||
.build(); | ||
Item item = ItemBuilder.createItem(context, collection) | ||
.withTitle("Test item") | ||
.withDspaceObjectOwner("Owner", owner.getID().toString()) | ||
//.withCrisOwner("Owner", owner.getID().toString()) | ||
.build(); | ||
context.restoreAuthSystemState(); | ||
AccessItemMode accessMode = buildAccessItemMode(CrisSecurity.GROUP); | ||
when(accessMode.getGroups()).thenReturn(List.of("Researcher")); | ||
assertThat(crisSecurityService.hasAccess(context, item, firstUser, accessMode), is(true)); | ||
assertThat(crisSecurityService.hasAccess(context, item, eperson, accessMode), is(false)); | ||
assertThat(crisSecurityService.hasAccess(context, item, owner, accessMode), is(false)); | ||
} | ||
|
||
@Test | ||
public void testHasAccessWithGroupConfig() throws SQLException, AuthorizeException { | ||
|
||
|