Search in sources :

Example 11 with VreAuthorization

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

the class LocalFileVreAuthorizationAccessTest method getAuthorizationReturnsEmptyIfPermissionNotPresentInEitherFile.

@Test
public void getAuthorizationReturnsEmptyIfPermissionNotPresentInEitherFile() throws Exception {
    File file = new File(authorizationsFolder.toFile(), "authorizations.json");
    file.createNewFile();
    String testAuthInfo = "[{\"vreId\":\"test_vre\",\"userId\":\"33707283d426f900d4d33707283d4268testing2\"," + "\"roles\":[\"ADMIN\"]}]\n";
    Files.write(file.toPath(), testAuthInfo.getBytes());
    String userId = "33707283d426f900d4d33707283d426f9testing";
    Optional<VreAuthorization> authorization = instance.getAuthorization(VRE, userId);
    assertThat(authorization, is(not(present())));
}
Also used : File(java.io.File) VreAuthorization(nl.knaw.huygens.timbuctoo.security.dto.VreAuthorization) Test(org.junit.Test)

Example 12 with VreAuthorization

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

the class VreAuthorizationTest method isAllowedToWriteReturnsTrueIfTheRolesContainUnverifiedUserAndUser.

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

Example 13 with VreAuthorization

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

the class VreAuthorizationTest method hasAdminAccessReturnsFalseIfTheRolesOnlyContainUnverifiedUser.

@Test
public void hasAdminAccessReturnsFalseIfTheRolesOnlyContainUnverifiedUser() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "", UNVERIFIED_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 14 with VreAuthorization

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

the class VreAuthorizationTest method hasAdminAccessReturnsFalseIfTheRolesAreEmpty.

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

Example 15 with VreAuthorization

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

the class VreAuthorizationTest method isAllowedToWriteReturnsTrueIfTheRolesContainUnverifiedUserAndAdmin.

@Test
public void isAllowedToWriteReturnsTrueIfTheRolesContainUnverifiedUserAndAdmin() throws Exception {
    VreAuthorization instance = VreAuthorization.create("", "", UNVERIFIED_USER_ROLE, ADMIN_ROLE);
    boolean allowedToWrite = instance.isAllowedToWrite();
    assertThat(allowedToWrite, is(true));
}
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