use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class SetPointEventHandlerServiceTest method testCannotInsertUnauthorizedScriptRole.
@Test
@ExpectValidationException("scriptRoles")
public void testCannotInsertUnauthorizedScriptRole() {
addRoleToCreatePermission(editRole);
SetPointEventHandlerVO vo = newVO(editUser);
vo.setReadPermission(MangoPermission.requireAnyRole(editRole));
vo.setEditPermission(MangoPermission.requireAnyRole(editRole));
ScriptPermissions permissions = new ScriptPermissions(Sets.newHashSet(readRole, editRole));
vo.setScriptRoles(permissions);
runAs.runAs(editUser, () -> {
service.insert(vo);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class SetPointEventHandlerServiceTest method testCannotUpdateUnauthorizedScriptRole.
@Test
@ExpectValidationException("scriptRoles")
public void testCannotUpdateUnauthorizedScriptRole() {
addRoleToCreatePermission(editRole);
SetPointEventHandlerVO 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, () -> {
SetPointEventHandlerVO fromDb = (SetPointEventHandlerVO) service.insert(vo);
ScriptPermissions newPermissions = new ScriptPermissions(Sets.newHashSet(readRole, editRole));
fromDb.setScriptRoles(newPermissions);
service.update(fromDb.getId(), fromDb);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class MailingListServiceTest method testRecursiveMailingListsAreInvalid.
@Test
@ExpectValidationException("recipients[0]")
public void testRecursiveMailingListsAreInvalid() {
MailingList recursiveMailingList = service.insert(newVO(readUser));
List<MailingListRecipient> entries = new ArrayList<>();
recursiveMailingList.setEntries(entries);
MailingListEntry ml = new MailingListEntry();
ml.setMailingListId(recursiveMailingList.getId());
entries.add(ml);
service.update(recursiveMailingList.getId(), recursiveMailingList);
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class RoleServiceTest method cannotModifyUserRole.
@Test
@ExpectValidationException("xid")
public void cannotModifyUserRole() {
RoleVO vo = service.get(PermissionHolder.USER_ROLE_XID);
RoleVO updated = new RoleVO(Common.NEW_ID, vo.getXid(), vo.getName());
service.update(vo.getXid(), updated);
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class RoleServiceTest method cannotInsertSuperadminRole.
@Test
@ExpectValidationException("xid")
public void cannotInsertSuperadminRole() {
RoleVO vo = new RoleVO(Common.NEW_ID, PermissionHolder.SUPERADMIN_ROLE_XID, "Superadmin default");
service.insert(vo);
}
Aggregations