Search in sources :

Example 31 with User

use of io.lumeer.api.model.User in project engine by Lumeer.

the class UserServiceIT method prepareUser.

private User prepareUser(String organizationId, String user) {
    User u = new User(user);
    u.setName(user);
    u.setGroups(Collections.singletonMap(organizationId, GROUPS));
    return u;
}
Also used : User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser)

Example 32 with User

use of io.lumeer.api.model.User in project engine by Lumeer.

the class UserServiceIT method testUpdateUser.

@Test
public void testUpdateUser() {
    createUser(organizationId1, USER1);
    User storedUser = getUser(organizationId1, USER1);
    assertThat(storedUser).isNotNull();
    User updateUser = prepareUser(organizationId1, USER2);
    Entity entity = Entity.json(updateUser);
    Response response = client.target(getPath(organizationId1)).path(storedUser.getId()).request(MediaType.APPLICATION_JSON).buildPut(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    storedUser = getUser(organizationId1, USER1);
    assertThat(storedUser).isNull();
    storedUser = getUser(organizationId1, USER2);
    assertThat(storedUser).isNotNull();
}
Also used : Response(javax.ws.rs.core.Response) Entity(javax.ws.rs.client.Entity) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) Test(org.junit.Test)

Example 33 with User

use of io.lumeer.api.model.User in project engine by Lumeer.

the class UserServiceIT method testDeleteUser.

@Test
public void testDeleteUser() {
    createUser(organizationId1, USER1);
    User storedUser = getUser(organizationId1, USER1);
    assertThat(storedUser).isNotNull();
    Response response = client.target(getPath(organizationId1)).path(storedUser.getId()).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    storedUser = getUser(organizationId1, USER1);
    assertThat(storedUser).isNull();
}
Also used : Response(javax.ws.rs.core.Response) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) Test(org.junit.Test)

Example 34 with User

use of io.lumeer.api.model.User in project engine by Lumeer.

the class ViewServiceIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
    MorphiaProject project = new MorphiaProject();
    project.setCode(PROJECT_CODE);
    project.setPermissions(new MorphiaPermissions());
    Project storedProject = projectDao.createProject(project);
    viewDao.setProject(storedProject);
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 35 with User

use of io.lumeer.api.model.User in project engine by Lumeer.

the class ProjectServicePermissionsIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(organizationCode);
    organization.setName(organizationName);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(userEmail, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    workspaceKeeper.setOrganization(organizationCode);
    User user = new User(userEmail);
    userDao.createUser(user);
}
Also used : Organization(io.lumeer.api.model.Organization) JsonOrganization(io.lumeer.api.dto.JsonOrganization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Aggregations

User (io.lumeer.api.model.User)50 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)29 Test (org.junit.Test)21 Before (org.junit.Before)18 Organization (io.lumeer.api.model.Organization)17 JsonOrganization (io.lumeer.api.dto.JsonOrganization)13 Project (io.lumeer.api.model.Project)13 JsonPermission (io.lumeer.api.dto.JsonPermission)12 JsonPermissions (io.lumeer.api.dto.JsonPermissions)12 JsonProject (io.lumeer.api.dto.JsonProject)12 JsonCollection (io.lumeer.api.dto.JsonCollection)8 HashSet (java.util.HashSet)7 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)5 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)5 Set (java.util.Set)5 Response (javax.ws.rs.core.Response)4 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)3 HashMap (java.util.HashMap)3 LinkType (io.lumeer.api.model.LinkType)2 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)2