use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserSearchServiceTest method shouldSearchForUsers.
@Test
public void shouldSearchForUsers() throws Exception {
User foo = new User("foo", new ArrayList<>(), "foo@cruise.com", false);
User bar = new User("bar-foo", new ArrayList<>(), "bar@go.com", true);
when(ldapUserSearch.search("foo")).thenReturn(Arrays.asList(foo, bar));
List<UserSearchModel> models = userSearchService.search("foo", new HttpLocalizedOperationResult());
assertThat(models, is(Arrays.asList(new UserSearchModel(foo, UserSourceType.LDAP), new UserSearchModel(bar, UserSourceType.LDAP))));
}
use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceIntegrationTest method shouldReturnErrorWhenTryingToAddAnonymousUser.
@Test
public void shouldReturnErrorWhenTryingToAddAnonymousUser() throws Exception {
UserSearchModel anonymous = new UserSearchModel(new User(CaseInsensitiveString.str(Username.ANONYMOUS.getUsername()), "Mr. Anonymous", "anon@cruise.com"), UserSourceType.LDAP);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
userService.create(Arrays.asList(anonymous), result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.message(localizer), is("Failed to add user. Username 'anonymous' is not permitted."));
}
use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceIntegrationTest method shouldCreateANewUser.
@Test
public void shouldCreateANewUser() throws Exception {
UserSearchModel foo = new UserSearchModel(new User("fooUser", "Mr Foo", "foo@cruise.com"), UserSourceType.LDAP);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
userService.create(Arrays.asList(foo), result);
assertThat(result.isSuccessful(), is(true));
assertThat(result.message(localizer), is("User 'fooUser' successfully added."));
}
use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceIntegrationTest method shouldDeleteAllUsers.
@Test
public void shouldDeleteAllUsers() throws Exception {
UserSearchModel foo = new UserSearchModel(new User("fooUser", "Mr Foo", "foo@cruise.com"));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
userService.create(Arrays.asList(foo), result);
assertThat(userService.allUsersForDisplay(UserService.SortableColumn.EMAIL, UserService.SortDirection.ASC).size(), is(1));
userService.deleteAll();
assertThat(userService.allUsersForDisplay(UserService.SortableColumn.EMAIL, UserService.SortDirection.ASC).size(), is(0));
}
use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceTest method shouldAllowCreateNewUsersFromPasswordFileWithoutEmailAddress.
@Test
public void shouldAllowCreateNewUsersFromPasswordFileWithoutEmailAddress() throws Exception {
UserSearchModel passwordUser = new UserSearchModel(new User("passwordUser"), UserSourceType.PASSWORD_FILE);
doNothing().when(userDao).saveOrUpdate(passwordUser.getUser());
when(userDao.findUser("passwordUser")).thenReturn(new NullUser());
when(userDao.enabledUserCount()).thenReturn(10);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
userService.create(Arrays.asList(passwordUser), result);
assertThat(result.isSuccessful(), is(true));
}
Aggregations