use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class IpGroupTest method testContains.
/**
* Test of contains method, of class IpGroup.
*/
@Test
public void testContains() {
IpGroup sut = new IpGroup();
sut.setId(MocksFactory.nextId());
sut.setDescription("A's description");
sut.setDisplayName("A");
sut.setPersistedGroupAlias("&ip/a");
final IpAddressRange allIPv4 = IpAddressRange.make(IpAddress.valueOf("0.0.0.0"), IpAddress.valueOf("255.255.255.255"));
final IpAddressRange allIPv6 = IpAddressRange.make(IpAddress.valueOf("0:0:0:0:0:0:0:0"), IpAddress.valueOf("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
sut.add(allIPv4);
sut.add(allIPv6);
assertTrue(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("1.2.3.4"))));
assertTrue(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("11::fff"))));
sut.remove(allIPv4);
assertFalse(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("1.2.3.4"))));
sut.remove(allIPv6);
assertFalse(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("11::fff"))));
sut.add(IpAddressRange.make(IpAddress.valueOf("0.0.0.0"), IpAddress.valueOf("168.0.0.0")));
assertFalse(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("169.0.0.0"))));
assertTrue(sut.contains(new DataverseRequest(GuestUser.get(), IpAddress.valueOf("167.0.0.0"))));
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testValidMove.
/**
* Moving ChildB to ChildA
* @throws Exception - should not throw an exception
*/
@Test
public void testValidMove() throws Exception {
DataverseRequest aRequest = new DataverseRequest(auth, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, childA, null));
assertEquals(childA, moved.getOwner());
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testNotSuperUser.
/**
* Moving DS Without Being Super User
* Fails due to Permission Exception
* @throws java.lang.Exception
*/
@Test(expected = PermissionException.class)
public void testNotSuperUser() throws Exception {
DataverseRequest aRequest = new DataverseRequest(nobody, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, root, null));
fail();
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class MoveDatasetCommandTest method testInvalidMove.
/**
* Moving DS to its owning DV
* @throws IllegalCommandException
*/
@Test(expected = IllegalCommandException.class)
public void testInvalidMove() throws Exception {
DataverseRequest aRequest = new DataverseRequest(auth, httpRequest);
testEngine.submit(new MoveDatasetCommand(aRequest, moved, root, false));
fail();
}
use of edu.harvard.iq.dataverse.engine.command.DataverseRequest in project dataverse by IQSS.
the class RequestRsyncScriptCommandTest method testHappyPath.
@Test
public void testHappyPath() throws Exception {
dataset = new Dataset();
dataset.setIdentifier("42");
HttpServletRequest aHttpServletRequest = null;
DataverseRequest dataverseRequest = new DataverseRequest(MocksFactory.makeAuthenticatedUser("First", "Last"), aHttpServletRequest);
ScriptRequestResponse scriptRequestResponse = testEngine.submit(new RequestRsyncScriptCommand(dataverseRequest, dataset));
assertEquals("theScript", scriptRequestResponse.getScript());
}
Aggregations