use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method mustRetainAccess.
@Test
@ExpectValidationException({ "readPermission", "editPermission" })
public void mustRetainAccess() {
Role otherRole = createRole(randomXid(), "Some other role").getRole();
User otherUser = insertUser();
User user = insertUser(editRole, readRole);
runAs.runAs(user, () -> {
otherUser.setReadPermission(MangoPermission.requireAnyRole(otherRole));
otherUser.setEditPermission(MangoPermission.requireAnyRole(otherRole));
service.update(otherUser.getId(), otherUser);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantCreateUserYouCantRead.
@Test
@ExpectValidationException("readPermission")
public void cantCreateUserYouCantRead() {
Role createRole = createUsersRole();
User createUser = insertUser(editRole, createRole);
// noinspection Convert2MethodRef
runAs.runAs(createUser, () -> insertUser());
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantChangeCreatedTimeOfSelf.
@Test
@ExpectValidationException("created")
public void cantChangeCreatedTimeOfSelf() {
User user = insertUser();
runAs.runAs(user, () -> {
User self = service.get(user.getId());
Date differentDate = new Date(self.getCreated().getTime() + 1);
self.setCreated(differentDate);
service.update(self.getId(), self);
});
}
use of com.infiniteautomation.mango.rules.ExpectValidationException in project ma-core-public by infiniteautomation.
the class UsersServiceTest method cantAddRolesToSelfWithExplicitEditPermission.
@Test
@ExpectValidationException("roles")
public void cantAddRolesToSelfWithExplicitEditPermission() {
setEditSelfPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
User vo = insertUser(editRole);
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setRoles(Stream.concat(self.getRoles().stream(), Stream.of(readRole)).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 cantDisableSelf.
@Test
@ExpectValidationException("disabled")
public void cantDisableSelf() {
setEditSelfPermission(MangoPermission.requireAnyRole(PermissionHolder.USER_ROLE));
User vo = insertUser();
runAs.runAs(vo, () -> {
User self = service.get(vo.getId());
self.setDisabled(true);
service.update(self.getId(), self);
});
}
Aggregations