added unit test to retrieve a resource policy attached to the Anonymous group with/without using authentication

This commit is contained in:
Mykhaylo Boychuk
2020-02-06 15:52:58 +01:00
parent 3e0db7a7a1
commit dc06efbb83

View File

@@ -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();