use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class UserServiceIntegrationTest method modifyRoles_shouldNotModifyRolesForAUserThatDoesNotExistInDb.
@Test
public void modifyRoles_shouldNotModifyRolesForAUserThatDoesNotExistInDb() {
assertThat(userDao.findUser("user-1"), is(instanceOf(NullUser.class)));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
userService.modifyRolesAndUserAdminPrivileges(Arrays.asList("user-1"), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.nochange), Arrays.asList(new TriStateSelection("dev", TriStateSelection.Action.add)), result);
assertThat(userDao.findUser("user-1"), is(instanceOf(NullUser.class)));
assertThat(result.isSuccessful(), is(false));
assertThat(result.message(), containsString("User 'user-1' does not exist in the database."));
}
use of com.thoughtworks.go.presentation.TriStateSelection in project gocd by gocd.
the class UserServiceIntegrationTest method modifyRoles_shouldRemoveUserFromRole.
@Test
public void modifyRoles_shouldRemoveUserFromRole() {
addUser(new User("user-1"));
// add it first
userService.modifyRolesAndUserAdminPrivileges(Arrays.asList("user-1"), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.nochange), Arrays.asList(new TriStateSelection("dev", TriStateSelection.Action.add)), new HttpLocalizedOperationResult());
// now remove it
userService.modifyRolesAndUserAdminPrivileges(Arrays.asList("user-1"), new TriStateSelection(Admin.GO_SYSTEM_ADMIN, TriStateSelection.Action.nochange), Arrays.asList(new TriStateSelection("dev", TriStateSelection.Action.remove)), new HttpLocalizedOperationResult());
CruiseConfig cruiseConfig = goConfigDao.load();
assertThat(cruiseConfig.server().security().getRoles().findByName(new CaseInsensitiveString("dev")).hasMember(new CaseInsensitiveString("user-1")), is(false));
}
Aggregations