Search in sources :

Example 16 with VreAuthorization

use of nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization in project timbuctoo by HuygensING.

the class VreAuthorizationTest method hasAdminAccessReturnsFalseIfTheRolesContainUnverifiedUserAndAdmin.

@Test
public void hasAdminAccessReturnsFalseIfTheRolesContainUnverifiedUserAndAdmin() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "", UNVERIFIED_USER_ROLE, USER_ROLE);
    boolean allowedToWrite = instance.hasAdminAccess();
    assertThat(allowedToWrite, is(false));
}
Also used : VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Example 17 with VreAuthorization

use of nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization in project timbuctoo by HuygensING.

the class VreAuthorizationTest method isAllowedToWriteReturnsTrueIfTheRolesContainAdmin.

@Test
public void isAllowedToWriteReturnsTrueIfTheRolesContainAdmin() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "", ADMIN_ROLE);
    boolean allowedToWrite = instance.isAllowedToWrite();
    assertThat(allowedToWrite, is(true));
}
Also used : VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Example 18 with VreAuthorization

use of nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization in project timbuctoo by HuygensING.

the class VreAuthorizationTest method isAllowedToWriteReturnsFalseIfTheRolesAreEmpty.

@Test
public void isAllowedToWriteReturnsFalseIfTheRolesAreEmpty() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "");
    boolean allowedToWrite = instance.isAllowedToWrite();
    assertThat(allowedToWrite, is(false));
}
Also used : VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Example 19 with VreAuthorization

use of nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization in project timbuctoo by HuygensING.

the class VreAuthorizationTest method hasAdminAccessReturnsTrueIfTheRolesContainAdmin.

// admin access
@Test
public void hasAdminAccessReturnsTrueIfTheRolesContainAdmin() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "", ADMIN_ROLE);
    boolean allowedToWrite = instance.hasAdminAccess();
    assertThat(allowedToWrite, is(true));
}
Also used : VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Example 20 with VreAuthorization

use of nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization in project timbuctoo by HuygensING.

the class LocalFileVreAuthorizationAccessTest method addAuthorizationReturnsTheAddedAuthorization.

@Test
public void addAuthorizationReturnsTheAddedAuthorization() throws Exception {
    String unknownUser = "unknownUser";
    VreAuthorization vreAuthorization = instance.getOrCreateAuthorization(VRE, unknownUser, UNVERIFIED_USER_ROLE);
    Optional<VreAuthorization> authorization = instance.getAuthorization(VRE, unknownUser);
    assertThat(vreAuthorization, is(authorization.get()));
}
Also used : VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Aggregations

VreAuthorization (nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization)26 Test (org.junit.Test)22 File (java.io.File)5 Permission (nl.knaw.huygens.timbuctoo.v5.security.dto.Permission)5 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)2 IOException (java.io.IOException)2 BasicDataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.BasicDataSetMetaData)2 DataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData)2 AuthorizationUnavailableException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.AuthorizationUnavailableException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Before (org.junit.Before)1