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