Skip to content

Commit

Permalink
[DSC-1487] add more ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
eskander authored and NikitaKr1vonosov committed Oct 2, 2024
1 parent 7cf20f2 commit bfc0a9b
Showing 1 changed file with 76 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5456,7 +5456,7 @@ public void findAccessStatusForItemTest() throws Exception {
}

@Test
public void findSubmitterTest() throws Exception {
public void findSubmitterByAdminTest() throws Exception {
context.turnOffAuthorisationSystem();

//** GIVEN **
Expand Down Expand Up @@ -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());
}

}

0 comments on commit bfc0a9b

Please sign in to comment.