use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class MailingListServiceTest method testAddMissingEditRole.
@Test
@ExpectValidationException("editPermission")
public void testAddMissingEditRole() {
MailingList vo = newVO(readUser);
Role role = new Role(10000, "new-role");
Set<Role> editRoles = Collections.singleton(role);
vo.setEditPermission(MangoPermission.requireAnyRole(editRoles));
service.insert(vo);
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class RoleServiceTest method cannotInsertNewUserRole.
@Test
@ExpectValidationException("xid")
public void cannotInsertNewUserRole() {
RoleVO vo = new RoleVO(Common.NEW_ID, PermissionHolder.USER_ROLE_XID, "user default");
service.insert(vo);
}
use of com.infiniteautomation.mango.rules.ExpectValidationException 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.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class RoleServiceTest method cannotModifySuperadminRole.
@Test
@ExpectValidationException("xid")
public void cannotModifySuperadminRole() {
RoleVO vo = service.get(PermissionHolder.SUPERADMIN_ROLE_XID);
RoleVO updated = new RoleVO(Common.NEW_ID, vo.getXid(), "Superadmin default changed");
service.update(vo.getXid(), updated);
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantRemoveRolesFromSelf.
@Test
@ExpectValidationException("roles")
public void cantRemoveRolesFromSelf() {
setEditSelfPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
User vo = newVO(null);
vo.setRoles(new HashSet<>(Arrays.asList(editRole, readRole)));
vo.setEditPermission(MangoPermission.superadminOnly());
service.insert(vo);
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setRoles(self.getRoles().stream().filter(r -> !r.equals(readRole)).collect(Collectors.toSet()));
service.update(self.getId(), self);
});
}
Aggregations