Search in sources :

Example 6 with PrivateUrlUser

use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetPrivateUrlRedirectDataConstructor.

@Test
public void testGetPrivateUrlRedirectDataConstructor() throws Exception {
    Exception exception1 = null;
    try {
        PrivateUrlRedirectData privateUrlRedirectData = new PrivateUrlRedirectData(null, null);
    } catch (Exception ex) {
        exception1 = ex;
    }
    assertNotNull(exception1);
    Exception exception2 = null;
    try {
        PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
        PrivateUrlRedirectData privateUrlRedirectData = new PrivateUrlRedirectData(privateUrlUser, null);
    } catch (Exception ex) {
        exception2 = ex;
    }
    assertNotNull(exception2);
}
Also used : PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) CommandException(edu.harvard.iq.dataverse.engine.command.exception.CommandException) Test(org.junit.Test)

Example 7 with PrivateUrlUser

use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetDraftDatasetVersionFromRoleAssignmentNullDataset.

@Test
public void testGetDraftDatasetVersionFromRoleAssignmentNullDataset() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUser;
    DvObject dataset = null;
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    DatasetVersion datasetVersion = PrivateUrlUtil.getDraftDatasetVersionFromRoleAssignment(ra);
    assertNull(datasetVersion);
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DatasetVersion(edu.harvard.iq.dataverse.DatasetVersion) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 8 with PrivateUrlUser

use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetPrivateUrlFromRoleAssignmentSuccess.

@Test
public void testGetPrivateUrlFromRoleAssignmentSuccess() {
    String dataverseSiteUrl = "https://dataverse.example.edu";
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUser;
    DvObject dataset = new Dataset();
    dataset.setId(42l);
    String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    PrivateUrl privateUrl = PrivateUrlUtil.getPrivateUrlFromRoleAssignment(ra, dataverseSiteUrl);
    assertNotNull(privateUrl);
    assertEquals(new Long(42), privateUrl.getDataset().getId());
    assertEquals("https://dataverse.example.edu/privateurl.xhtml?token=cd71e9d7-73a7-4ec8-b890-3d00499e8693", privateUrl.getLink());
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 9 with PrivateUrlUser

use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetUserFromRoleAssignmentNonDataset.

@Test
public void testGetUserFromRoleAssignmentNonDataset() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUserIn;
    DvObject nonDataset = new Dataverse();
    nonDataset.setId(123l);
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
    PrivateUrlUser privateUrlUserOut = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(ra);
    assertNull(privateUrlUserOut);
}
Also used : DvObject(edu.harvard.iq.dataverse.DvObject) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) Dataverse(edu.harvard.iq.dataverse.Dataverse) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Example 10 with PrivateUrlUser

use of edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetPrivateUrlRedirectDataFail.

@Test
public void testGetPrivateUrlRedirectDataFail() {
    DataverseRole aRole = null;
    long datasetId = 42;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
    RoleAssignee anAssignee = privateUrlUser;
    Dataset dataset = new Dataset();
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    ra.setDefinitionPoint(null);
    PrivateUrlRedirectData privateUrlRedirectData = null;
    privateUrlRedirectData = PrivateUrlUtil.getPrivateUrlRedirectData(ra);
    assertNull(privateUrlRedirectData);
}
Also used : Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) RoleAssignee(edu.harvard.iq.dataverse.authorization.RoleAssignee) Test(org.junit.Test)

Aggregations

PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)33 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)22 Test (org.junit.Test)21 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)18 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)18 Dataset (edu.harvard.iq.dataverse.Dataset)14 DvObject (edu.harvard.iq.dataverse.DvObject)11 PrivateUrl (edu.harvard.iq.dataverse.privateurl.PrivateUrl)6 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)5 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)4 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)4 ArrayList (java.util.ArrayList)3 JsonObject (javax.json.JsonObject)3 Dataverse (edu.harvard.iq.dataverse.Dataverse)2 DataverseRoleServiceBean (edu.harvard.iq.dataverse.DataverseRoleServiceBean)2 FileMetadata (edu.harvard.iq.dataverse.FileMetadata)2 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)2 GuestUser (edu.harvard.iq.dataverse.authorization.users.GuestUser)2 User (edu.harvard.iq.dataverse.authorization.users.User)2 TestCommandContext (edu.harvard.iq.dataverse.engine.TestCommandContext)2