Search in sources :

Example 11 with RoleAssignment

use of edu.harvard.iq.dataverse.RoleAssignment 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 12 with RoleAssignment

use of edu.harvard.iq.dataverse.RoleAssignment 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)

Example 13 with RoleAssignment

use of edu.harvard.iq.dataverse.RoleAssignment in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetDatasetFromRoleAssignmentNonDataset.

@Test
public void testGetDatasetFromRoleAssignmentNonDataset() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUser;
    DvObject nonDataset = new Dataverse();
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, nonDataset, privateUrlToken);
    assertNull(PrivateUrlUtil.getDatasetFromRoleAssignment(ra));
}
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 14 with RoleAssignment

use of edu.harvard.iq.dataverse.RoleAssignment in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetUserFromRoleAssignmentSucess.

@Test
public void testGetUserFromRoleAssignmentSucess() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUserIn = new PrivateUrlUser(42);
    RoleAssignee anAssignee = privateUrlUserIn;
    DvObject dataset = new Dataset();
    dataset.setId(123l);
    String privateUrlToken = null;
    RoleAssignment ra = new RoleAssignment(aRole, anAssignee, dataset, privateUrlToken);
    PrivateUrlUser privateUrlUserOut = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(ra);
    assertNotNull(privateUrlUserOut);
}
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 15 with RoleAssignment

use of edu.harvard.iq.dataverse.RoleAssignment in project dataverse by IQSS.

the class PrivateUrlUtilTest method testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess.

@Test
public void testGetPrivateUrlUserFromRoleAssignmentAndAssigneeSuccess() {
    DataverseRole aRole = null;
    PrivateUrlUser privateUrlUser = new PrivateUrlUser(42);
    RoleAssignee assignee = privateUrlUser;
    DvObject dataset = new Dataset();
    dataset.setId(42l);
    String privateUrlToken = "cd71e9d7-73a7-4ec8-b890-3d00499e8693";
    RoleAssignment assignment = new RoleAssignment(aRole, assignee, dataset, privateUrlToken);
    PrivateUrlUser privateUrl = PrivateUrlUtil.getPrivateUrlUserFromRoleAssignment(assignment, assignee);
    assertNotNull(privateUrl);
}
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)

Aggregations

RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)38 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)23 PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)22 RoleAssignee (edu.harvard.iq.dataverse.authorization.RoleAssignee)19 Test (org.junit.Test)19 Dataset (edu.harvard.iq.dataverse.Dataset)16 DvObject (edu.harvard.iq.dataverse.DvObject)14 Dataverse (edu.harvard.iq.dataverse.Dataverse)8 ArrayList (java.util.ArrayList)8 DatasetVersion (edu.harvard.iq.dataverse.DatasetVersion)7 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)7 IllegalCommandException (edu.harvard.iq.dataverse.engine.command.exception.IllegalCommandException)6 PrivateUrl (edu.harvard.iq.dataverse.privateurl.PrivateUrl)5 DataverseRoleServiceBean (edu.harvard.iq.dataverse.DataverseRoleServiceBean)4 User (edu.harvard.iq.dataverse.authorization.users.User)4 TestCommandContext (edu.harvard.iq.dataverse.engine.TestCommandContext)4 TestDataverseEngine (edu.harvard.iq.dataverse.engine.TestDataverseEngine)4 DataverseRequest (edu.harvard.iq.dataverse.engine.command.DataverseRequest)4 Before (org.junit.Before)4 DataverseFieldTypeInputLevel (edu.harvard.iq.dataverse.DataverseFieldTypeInputLevel)3