use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class CreateRoleCommandTest method testGuestUsersCantAddRoles.
@Test(expected = IllegalCommandException.class)
public void testGuestUsersCantAddRoles() throws CommandException {
DataverseRole dvr = new DataverseRole();
dvr.setAlias("roleTest");
dvr.setName("Tester Role");
dvr.addPermission(Permission.AddDataset);
Dataverse dv = MocksFactory.makeDataverse();
dvr.setOwner(dv);
CreateRoleCommand sut = new CreateRoleCommand(dvr, new DataverseRequest(GuestUser.get(), IpAddress.valueOf("89.17.33.33")), dv);
engine.submit(sut);
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class ExplicitGroupTest method recursiveLogicalContainment.
@Test
public void recursiveLogicalContainment() throws GroupException {
Dataverse dvParent = makeDataverse();
ExplicitGroup parentGroup = roleAssigneeSvc.add(makeExplicitGroup("parent", prv));
ExplicitGroup childGroup = roleAssigneeSvc.add(makeExplicitGroup("child", prv));
ExplicitGroup grandChildGroup = roleAssigneeSvc.add(makeExplicitGroup("grandChild", prv));
parentGroup.setOwner(dvParent);
childGroup.setOwner(dvParent);
grandChildGroup.setOwner(dvParent);
childGroup.add(grandChildGroup);
parentGroup.add(childGroup);
AuthenticatedUser au = roleAssigneeSvc.add(makeAuthenticatedUser("Jane", "Doe"));
grandChildGroup.add(au);
childGroup.add(GuestUser.get());
DataverseRequest auReq = makeRequest(au);
DataverseRequest guestReq = makeRequest();
assertTrue(grandChildGroup.contains(auReq));
assertTrue(childGroup.contains(auReq));
assertTrue(parentGroup.contains(auReq));
assertTrue(childGroup.contains(guestReq));
assertTrue(parentGroup.contains(guestReq));
grandChildGroup.remove(au);
assertFalse(grandChildGroup.contains(auReq));
assertFalse(childGroup.contains(auReq));
assertFalse(parentGroup.contains(auReq));
childGroup.add(AuthenticatedUsers.get());
assertFalse(grandChildGroup.contains(auReq));
assertTrue(childGroup.contains(auReq));
assertTrue(parentGroup.contains(auReq));
final IpGroup ipGroup = roleAssigneeSvc.add(new IpGroup(new IpGroupProvider(null)));
grandChildGroup.add(ipGroup);
ipGroup.add(IpAddressRange.make(IpAddress.valueOf("0.0.1.1"), IpAddress.valueOf("0.0.255.255")));
final IpAddress ip = IpAddress.valueOf("0.0.128.128");
final DataverseRequest request = new DataverseRequest(GuestUser.get(), ip);
assertTrue(ipGroup.contains(request));
assertTrue(grandChildGroup.contains(request));
assertTrue(parentGroup.contains(request));
childGroup.add(GuestUser.get());
assertTrue(childGroup.contains(guestReq));
assertTrue(parentGroup.contains(guestReq));
assertFalse(grandChildGroup.contains(guestReq));
}
Aggregations