Search in sources :

Example 1 with Group

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

the class GroupServiceIT method testCreateUser.

@Test
public void testCreateUser() {
    Group group = new Group(GROUP1);
    Entity entity = Entity.json(group);
    Response response = client.target(getPath(organization.getCode())).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    Group returnedGroup = response.readEntity(Group.class);
    assertThat(returnedGroup).isNotNull();
    Group storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNotNull();
    assertThat(storedGroup.getId()).isEqualTo(returnedGroup.getId());
    assertThat(storedGroup.getName()).isEqualTo(GROUP1);
}
Also used : Response(javax.ws.rs.core.Response) Group(io.lumeer.api.model.Group) Entity(javax.ws.rs.client.Entity) Test(org.junit.Test)

Example 2 with Group

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

the class GroupServiceIT method testDeleteUser.

@Test
public void testDeleteUser() {
    groupDao.createGroup(new Group(GROUP1));
    Group storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNotNull();
    Response response = client.target(getPath(organization.getCode())).path(storedGroup.getId()).request(MediaType.APPLICATION_JSON).buildDelete().invoke();
    assertThat(response).isNotNull();
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    storedGroup = getGroup(GROUP1);
    assertThat(storedGroup).isNull();
}
Also used : Response(javax.ws.rs.core.Response) Group(io.lumeer.api.model.Group) Test(org.junit.Test)

Example 3 with Group

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

the class LinkTypeFacadeIT method configureLinkTypes.

@Before
public void configureLinkTypes() {
    user = userDao.createUser(new User(USER));
    Organization organization = new Organization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new Permissions());
    this.organization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(this.organization);
    groupDao.setOrganization(this.organization);
    group = groupDao.createGroup(new Group(GROUP, Collections.singletonList(user.getId())));
    user.setOrganizations(Collections.singleton(this.organization.getId()));
    user = userDao.updateUser(user.getId(), user);
    Permissions organizationPermissions = new Permissions();
    Permission userPermission = Permission.buildWithRoles(user.getId(), Collections.singleton(new Role(RoleType.Read)));
    organizationPermissions.updateUserPermissions(userPermission);
    this.organization.setPermissions(organizationPermissions);
    this.organization = organizationDao.updateOrganization(this.organization.getId(), this.organization);
    Project project = new Project();
    project.setPermissions(new Permissions());
    project.setCode(PROJECT_CODE);
    this.project = projectDao.createProject(project);
    Permissions projectPermissions = new Permissions();
    Permission userProjectPermission = Permission.buildWithRoles(user.getId(), Set.of(new Role(RoleType.Read), new Role(RoleType.LinkContribute)));
    projectPermissions.updateUserPermissions(userProjectPermission);
    this.project.setPermissions(projectPermissions);
    this.project = projectDao.updateProject(this.project.getId(), this.project);
    workspaceKeeper.setWorkspaceIds(this.organization.getId(), this.project.getId());
    collectionDao.setProject(this.project);
    collectionIds.clear();
    for (String name : COLLECTION_NAMES) {
        Permissions collectionPermissions = new Permissions();
        collectionPermissions.updateUserPermissions(new Permission(user.getId(), Collections.singleton(new Role(RoleType.Read))));
        Collection collection = new Collection(name, name, COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
        collectionIds.add(collectionDao.createCollection(collection).getId());
    }
    Collection collection = new Collection("noPerm", "noPerm", COLLECTION_ICON, COLLECTION_COLOR, new Permissions());
    collectionIdNoPerm = collectionDao.createCollection(collection).getId();
    PermissionCheckerUtil.allowGroups();
    permissionsChecker.getPermissionAdapter().invalidateUserCache();
}
Also used : Role(io.lumeer.api.model.Role) Group(io.lumeer.api.model.Group) Project(io.lumeer.api.model.Project) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Organization(io.lumeer.api.model.Organization) Permissions(io.lumeer.api.model.Permissions) Permission(io.lumeer.api.model.Permission) Collection(io.lumeer.api.model.Collection) Before(org.junit.Before)

Example 4 with Group

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

the class ProjectFacadeIT method configureProject.

@Before
public void configureProject() {
    this.user = userDao.createUser(new User(USER));
    this.stranger = userDao.createUser(new User(STRANGER_USER));
    userPermissions = Permission.buildWithRoles(this.user.getId(), Project.ROLES);
    userReadonlyPermissions = Permission.buildWithRoles(this.user.getId(), Collections.singleton(new Role(RoleType.Read)));
    userStrangerPermissions = Permission.buildWithRoles(this.stranger.getId(), Collections.singleton(new Role(RoleType.Read)));
    Organization organization = new Organization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new Permissions());
    organization.getPermissions().updateUserPermissions(Permission.buildWithRoles(this.user.getId(), Collections.singleton(new Role(RoleType.Read))));
    this.organization = organizationDao.createOrganization(organization);
    groupDao.setOrganization(this.organization);
    group = groupDao.createGroup(new Group(GROUP, Collections.singletonList(user.getId())));
    user.setOrganizations(Collections.singleton(this.organization.getId()));
    user = userDao.updateUser(user.getId(), user);
    groupPermissions = Permission.buildWithRoles(group.getId(), Collections.singleton(new Role(RoleType.Read)));
    projectDao.setOrganization(this.organization);
    workspaceKeeper.setOrganizationId(this.organization.getId());
    PermissionCheckerUtil.allowGroups();
    permissionsChecker.getPermissionAdapter().invalidateUserCache();
}
Also used : Role(io.lumeer.api.model.Role) Group(io.lumeer.api.model.Group) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Organization(io.lumeer.api.model.Organization) LumeerAssertions.assertPermissions(io.lumeer.test.util.LumeerAssertions.assertPermissions) Permissions(io.lumeer.api.model.Permissions) Before(org.junit.Before)

Example 5 with Group

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

the class FileAttachmentFacadeIT method configureProject.

@Before
public void configureProject() {
    User user = new User(USER);
    this.user = userDao.createUser(user);
    Organization organization = new Organization();
    organization.setCode(ORGANIZATION_CODE);
    Permissions organizationPermissions = new Permissions();
    userPermission = Permission.buildWithRoles(this.user.getId(), Organization.ROLES);
    organizationPermissions.updateUserPermissions(userPermission);
    organization.setPermissions(organizationPermissions);
    this.organization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(this.organization);
    groupDao.setOrganization(this.organization);
    Group group = new Group(GROUP);
    this.group = groupDao.createGroup(group);
    userPermission = Permission.buildWithRoles(this.user.getId(), Collection.ROLES);
    groupPermission = Permission.buildWithRoles(this.group.getId(), Collections.singleton(new Role(RoleType.Read)));
    Project project = new Project();
    project.setCode(PROJECT_CODE);
    Permissions projectPermissions = new Permissions();
    projectPermissions.updateUserPermissions(Permission.buildWithRoles(this.user.getId(), Project.ROLES));
    project.setPermissions(projectPermissions);
    this.project = projectDao.createProject(project);
    workspaceKeeper.setWorkspaceIds(this.organization.getId(), this.project.getId());
    collectionDao.setProject(project);
    collection = new Collection("C1", "My collection", "fa-eye", "ffaabb", null);
    collection.getPermissions().updateUserPermissions(userPermission);
    collection.getPermissions().updateGroupPermissions(groupPermission);
    collection = collectionDao.createCollection(collection);
    fileAttachment1 = new FileAttachment(organization.getId(), project.getId(), collection.getId(), "5cf6f208857aba009210af9b", "a3", "můk super/$~@#ę€%=název.pdf", "", FileAttachment.AttachmentType.DOCUMENT);
    fileAttachment2 = new FileAttachment(organization.getId(), "5cf6f208857aba009210af9c", collection.getId(), "5cf6f208857aba009210af9b", "a3", "normal file name .doc", "", FileAttachment.AttachmentType.DOCUMENT);
}
Also used : Role(io.lumeer.api.model.Role) Group(io.lumeer.api.model.Group) Project(io.lumeer.api.model.Project) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Organization(io.lumeer.api.model.Organization) FileAttachment(io.lumeer.api.model.FileAttachment) Permissions(io.lumeer.api.model.Permissions) Collection(io.lumeer.api.model.Collection) Before(org.junit.Before)

Aggregations

Group (io.lumeer.api.model.Group)44 Test (org.junit.Test)22 Organization (io.lumeer.api.model.Organization)19 Permissions (io.lumeer.api.model.Permissions)16 Project (io.lumeer.api.model.Project)16 Role (io.lumeer.api.model.Role)16 User (io.lumeer.api.model.User)16 Before (org.junit.Before)15 AuthenticatedUser (io.lumeer.core.auth.AuthenticatedUser)14 Permission (io.lumeer.api.model.Permission)10 Response (javax.ws.rs.core.Response)9 Collection (io.lumeer.api.model.Collection)7 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)6 List (java.util.List)4 LinkType (io.lumeer.api.model.LinkType)2 Query (io.lumeer.api.model.Query)2 QueryStem (io.lumeer.api.model.QueryStem)2 ResourceType (io.lumeer.api.model.ResourceType)2 RoleType (io.lumeer.api.model.RoleType)2 Resource (io.lumeer.api.model.common.Resource)2