use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method superadminCantRemoveSuperadminRoleFromSelf.
@Test
@ExpectValidationException("roles")
public void superadminCantRemoveSuperadminRoleFromSelf() {
setEditSelfPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
User vo = insertUser(editRole, readRole, PermissionHolder.SUPERADMIN_ROLE);
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setRoles(self.getRoles().stream().filter(r -> !r.equals(PermissionHolder.SUPERADMIN_ROLE)).collect(Collectors.toSet()));
service.update(self.getId(), self);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantDisableSelfEvenIfSuperadmin.
@Test
@ExpectValidationException("disabled")
public void cantDisableSelfEvenIfSuperadmin() {
User vo = insertUser(PermissionHolder.SUPERADMIN_ROLE);
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setDisabled(true);
service.update(self.getId(), self);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantChangePermissionsOfSelf.
@Test
@ExpectValidationException({ "readPermission", "editPermission" })
public void cantChangePermissionsOfSelf() {
setEditSelfPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
User vo = insertUser();
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setReadPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
self.setEditPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
service.update(self.getId(), self);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method mustRetainAccessToSelf.
@Test
@ExpectValidationException({ "readPermission", "editPermission" })
public void mustRetainAccessToSelf() {
User vo = insertUser(editRole, readRole);
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setReadPermission(MangoPermission.superadminOnly());
self.setEditPermission(MangoPermission.superadminOnly());
service.update(self.getId(), self);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantCreateUserYouCantEdit.
@Test
@ExpectValidationException("editPermission")
public void cantCreateUserYouCantEdit() {
Role createRole = createUsersRole();
User createUser = insertUser(readRole, createRole);
// noinspection Convert2MethodRef
runAs.runAs(createUser, () -> insertUser());
}
Aggregations