use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantAddAdditionalRolesWhenUpdating.
@Test
@ExpectValidationException("roles")
public void cantAddAdditionalRolesWhenUpdating() {
Role roleToAdd = createRole(randomXid(), "Some other role").getRole();
Role createRole = createUsersRole();
User createUser = insertUser(createRole, editRole, readRole);
User otherUser = insertUser();
runAs.runAs(createUser, () -> {
otherUser.setRoles(Collections.singleton(roleToAdd));
service.update(otherUser.getId(), otherUser);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class DataPointServiceTest method testSetRolesCannotBeNull.
@Test
@ExpectValidationException("setPermission")
public void testSetRolesCannotBeNull() {
DataPointVO vo = newVO(editUser);
setReadPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
setEditPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
vo.setSetPermission(null);
service.insert(vo);
runAs.runAs(readUser, () -> {
DataPointVO fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
fromDb.setName("read user edited me");
fromDb.setSetPermission(new MangoPermission());
service.update(fromDb.getXid(), fromDb);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class EmailEventHandlerServiceTest method testCannotUpdateUnauthorizedScriptRole.
@Test
@ExpectValidationException("scriptRoles")
public void testCannotUpdateUnauthorizedScriptRole() {
addRoleToCreatePermission(editRole);
EmailEventHandlerVO vo = newVO(editUser);
vo.setReadPermission(MangoPermission.requireAnyRole(editRole));
vo.setEditPermission(MangoPermission.requireAnyRole(editRole));
ScriptPermissions permissions = new ScriptPermissions(Sets.newHashSet(editRole));
vo.setScriptRoles(permissions);
runAs.runAs(editUser, () -> {
EmailEventHandlerVO fromDb = (EmailEventHandlerVO) service.insert(vo);
ScriptPermissions newPermissions = new ScriptPermissions(Sets.newHashSet(readRole, editRole));
fromDb.setScriptRoles(newPermissions);
service.update(fromDb.getId(), fromDb);
});
}
Aggregations