mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
added unit test to retrieve a resource policy attached to the Anonymous group with/without using authentication
This commit is contained in:
@@ -129,6 +129,36 @@ public class ResourcePolicyRestRepositoryIT extends AbstractControllerIntegratio
|
||||
.containsString("/api/authz/resourcepolicies/" + resourcePolicy.getID())));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findOneResourcePolicyOfAnonymousGroupTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Group groupAnonymous = EPersonServiceFactory.getInstance().getGroupService().findByName(context,
|
||||
Group.ANONYMOUS);
|
||||
|
||||
EPerson eperson1 = EPersonBuilder.createEPerson(context)
|
||||
.withEmail("eperson1@mail.com")
|
||||
.withPassword("qwerty01")
|
||||
.build();
|
||||
|
||||
Community community = CommunityBuilder.createCommunity(context).withName("My community").build();
|
||||
|
||||
ResourcePolicy resourcePolicy = ResourcePolicyBuilder.createResourcePolicy(context)
|
||||
.withDspaceObject(community)
|
||||
.withAction(Constants.READ)
|
||||
.withGroup(groupAnonymous)
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
String authToken = getAuthToken(eperson1.getEmail(), "qwerty01");
|
||||
getClient(authToken).perform(get("/api/authz/resourcepolicies/" + resourcePolicy.getID()))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
getClient().perform(get("/api/authz/resourcepolicies/" + resourcePolicy.getID()))
|
||||
.andExpect(status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findOneUnAuthenticatedTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
Reference in New Issue
Block a user