forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7cf20f2
commit bfc0a9b
Showing
1 changed file
with
76 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5456,7 +5456,7 @@ public void findAccessStatusForItemTest() throws Exception { | |
} | ||
|
||
@Test | ||
public void findSubmitterTest() throws Exception { | ||
public void findSubmitterByAdminTest() throws Exception { | ||
context.turnOffAuthorisationSystem(); | ||
|
||
//** GIVEN ** | ||
|
@@ -5500,4 +5500,79 @@ public void findSubmitterTest() throws Exception { | |
.andExpect(jsonPath("$.email", is(submitter.getEmail()))); | ||
} | ||
|
||
@Test | ||
public void findSubmitterWithoutReadAccessTest() throws Exception { | ||
context.turnOffAuthorisationSystem(); | ||
|
||
parentCommunity = CommunityBuilder.createCommunity(context) | ||
.withName("Parent Community") | ||
.build(); | ||
|
||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build(); | ||
|
||
EPerson submitter = EPersonBuilder.createEPerson(context) | ||
.withEmail("[email protected]") | ||
.withPassword(password) | ||
.withCanLogin(true) | ||
.build(); | ||
|
||
context.setCurrentUser(submitter); | ||
|
||
Item publicItem = ItemBuilder.createItem(context, col1) | ||
.withTitle("Public item 1") | ||
.withIssueDate("2017-10-17") | ||
.withAuthor("Smith, Donald") | ||
.withSubject("ExtraEntry") | ||
.build(); | ||
|
||
context.restoreAuthSystemState(); | ||
|
||
String token = getAuthToken(eperson.getEmail(), password); | ||
|
||
getClient(token).perform(get("/api/core/items/" + publicItem.getID()) | ||
.param("projection", "full")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", ItemMatcher.matchFullEmbeds())); | ||
|
||
// find submitter by user has no read access | ||
getClient(token).perform(get("/api/core/items/" + publicItem.getID() + "/submitter")) | ||
.andExpect(status().isNoContent()); | ||
} | ||
|
||
@Test | ||
public void findSubmitterByAnonymousTest() throws Exception { | ||
context.turnOffAuthorisationSystem(); | ||
|
||
parentCommunity = CommunityBuilder.createCommunity(context) | ||
.withName("Parent Community") | ||
.build(); | ||
|
||
Collection col1 = CollectionBuilder.createCollection(context, parentCommunity).withName("Collection 1").build(); | ||
|
||
EPerson submitter = EPersonBuilder.createEPerson(context) | ||
.withEmail("[email protected]") | ||
.withPassword(password) | ||
.withCanLogin(true) | ||
.build(); | ||
|
||
context.setCurrentUser(submitter); | ||
|
||
Item publicItem = ItemBuilder.createItem(context, col1) | ||
.withTitle("Public item 1") | ||
.withIssueDate("2017-10-17") | ||
.withAuthor("Smith, Donald") | ||
.withSubject("ExtraEntry") | ||
.build(); | ||
|
||
context.restoreAuthSystemState(); | ||
|
||
getClient().perform(get("/api/core/items/" + publicItem.getID()) | ||
.param("projection", "full")) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", ItemMatcher.matchFullEmbeds())); | ||
|
||
getClient().perform(get("/api/core/items/" + publicItem.getID() + "/submitter")) | ||
.andExpect(status().isNoContent()); | ||
} | ||
|
||
} |