use of com.serotonin.m2m2.vo.role.Role in project ma-core-public by infiniteautomation.
the class MailingListServiceTest method testRemoveOverprivledgedEditRole.
@Test(expected = PermissionException.class)
public void testRemoveOverprivledgedEditRole() {
MailingList vo = newVO(readUser);
Set<Role> editRoles = Collections.singleton(editRole);
vo.setEditPermission(MangoPermission.requireAnyRole(editRoles));
service.insert(vo);
MailingList fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
runAs.runAs(readUser, () -> {
vo.setEditPermission(MangoPermission.superadminOnly());
service.update(vo.getXid(), vo);
});
}
use of com.serotonin.m2m2.vo.role.Role in project ma-core-public by infiniteautomation.
the class UsersServiceTest method testAddEditRoleUserDoesNotHave.
@Test
@Override
@ExpectValidationException("roles")
public void testAddEditRoleUserDoesNotHave() {
User vo = newVO(readUser);
vo.setRoles(Collections.singleton(readRole));
service.insert(vo);
// Ensure the ability to edit self
setEditSelfPermission(MangoPermission.requireAnyRole(readRole));
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
Set<Role> newRoles = new HashSet<>(self.getRoles());
newRoles.add(editRole);
self.setRoles(newRoles);
service.update(self.getId(), self);
});
}
use of com.serotonin.m2m2.vo.role.Role in project ma-core-public by infiniteautomation.
the class UsersServiceTest method canAddOwnRolesWhenCreating.
@Test
public void canAddOwnRolesWhenCreating() {
Role createRole = createUsersRole();
User createUser = insertUser(createRole, editRole, readRole);
runAs.runAs(createUser, () -> {
insertUser(readRole);
});
}
use of com.serotonin.m2m2.vo.role.Role in project ma-core-public by infiniteautomation.
the class RoleServiceTest method canGetRoleUserHas.
@Test
public void canGetRoleUserHas() {
RoleVO roleUserHas = insertNewVO(readUser);
User testUser = createUser("test-user@example.com", "test-user@example.com", "test-user@example.com", "test-user@example.com", roleUserHas.getRole());
runAs.runAs(testUser, () -> {
RoleVO role = service.get(roleUserHas.getXid());
assertEquals(role.getXid(), roleUserHas.getXid());
assertEquals(role.getName(), roleUserHas.getName());
assertEquals(role.getId(), roleUserHas.getId());
});
}
use of com.serotonin.m2m2.vo.role.Role in project ma-core-public by infiniteautomation.
the class UsersServiceTest method createUsersRole.
public Role createUsersRole() {
Role createRole = createRole(randomXid(), "Create users role").getRole();
PermissionDefinition createPermission = Common.getBean(UserCreatePermission.class);
systemPermissionService.update(MangoPermission.requireAnyRole(createRole), createPermission);
return createRole;
}
Aggregations