Search in sources :

Example 11 with User

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

the class BasicPermissionFetcherTest method initializeOwnerAuthorizationThrowsExceptionWhenVreAuthorizationCrudFails.

@Test(expected = AuthorizationCreationException.class)
public void initializeOwnerAuthorizationThrowsExceptionWhenVreAuthorizationCrudFails() throws Exception {
    User user = userWithId("testuserid");
    doThrow(AuthorizationCreationException.class).when(vreAuthorizationCrud).createAuthorization("testownerid__testdatasetid", user, "ADMIN");
    permissionFetcher.initializeOwnerAuthorization(user, "testownerid", "testdatasetid");
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Test(org.junit.Test)

Example 12 with User

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

the class BasicPermissionFetcherTest method initializeOwnerAuthorizationCreatesAdminAuthorization.

@Test
public void initializeOwnerAuthorizationCreatesAdminAuthorization() throws Exception {
    User user = userWithId("testuserid");
    permissionFetcher.initializeOwnerAuthorization(user, "testownerid", "testdatasetid");
    verify(vreAuthorizationCrud).createAuthorization("testownerid__testdatasetid", user, "ADMIN");
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Test(org.junit.Test)

Example 13 with User

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

the class JsonBasedUserStoreTest method createUserLetsTheUserBeCreatedOnlyOnce.

@Test
public void createUserLetsTheUserBeCreatedOnlyOnce() throws Exception {
    User user1 = instance.createUser("pid", "email", "givenName", "surname", "organization");
    User user2 = instance.createUser("pid", "email", "givenName", "surname", "organization");
    assertThat(user1.getId(), is(user2.getId()));
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Test(org.junit.Test)

Example 14 with User

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

the class JsonBasedUserStoreTest method setUp.

@Before
public void setUp() throws Exception {
    usersFile = FileHelpers.makeTempFilePath(false);
    User user = User.create("", "pidOfKnownUser");
    User userWithoutPid = User.create(null, null);
    User[] users = { user, userWithoutPid };
    OBJECT_MAPPER.writeValue(usersFile.toFile(), users);
    instance = forFile(usersFile);
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Before(org.junit.Before)

Example 15 with User

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

the class JsonBasedUserStoreTest method createUserAddsAUserToTheUsersFile.

@Test
public void createUserAddsAUserToTheUsersFile() throws Exception {
    User createdUser = instance.createUser("pidOfOtherUser", "email", "givenName", "surname", "organization");
    Optional<User> user = instance.userForId(createdUser.getId());
    assertThat(user, is(present()));
    assertThat(user.get().getPersistentId(), is("pidOfOtherUser"));
}
Also used : User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Test(org.junit.Test)

Aggregations

User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)42 Test (org.junit.Test)22 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)19 IOException (java.io.IOException)11 DataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData)9 UserValidationException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.UserValidationException)7 PermissionFetchingException (nl.knaw.huygens.timbuctoo.v5.security.exceptions.PermissionFetchingException)6 Path (javax.ws.rs.Path)5 Urlset (nl.knaw.huygens.timbuctoo.remote.rs.xml.Urlset)5 ImportStatus (nl.knaw.huygens.timbuctoo.v5.dataset.ImportStatus)5 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 GET (javax.ws.rs.GET)4 Response (javax.ws.rs.core.Response)4 BasicDataSetMetaData (nl.knaw.huygens.timbuctoo.v5.dataset.dto.BasicDataSetMetaData)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 GraphQLSchema (graphql.schema.GraphQLSchema)3 Optional (java.util.Optional)3 DataStoreCreationException (nl.knaw.huygens.timbuctoo.v5.dataset.exceptions.DataStoreCreationException)3 QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)3