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())));
}
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));
}
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));
}
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));
}
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));
}
Aggregations