use of org.motechproject.security.model.UserDto in project motech by motech.
the class MotechUserServiceBundleIT method shouldFindUserByUsername.
@Test
public void shouldFindUserByUsername() {
motechUserService.register("userName", "password", "1234", "", asList("IT_ADMIN", "DB_ADMIN"), Locale.ENGLISH);
UserDto motechUser = motechUserService.getUser("userName");
assertNotNull(motechUser);
assertTrue(motechUser.getRoles().contains("IT_ADMIN"));
assertTrue(motechUser.getRoles().contains("DB_ADMIN"));
}
use of org.motechproject.security.model.UserDto in project motech by motech.
the class MotechUserServiceBundleIT method shouldFindUserByUsernameCaseInsensitive.
@Test
public void shouldFindUserByUsernameCaseInsensitive() {
motechUserService.register("userName", "password", "1234", "", asList("IT_ADMIN", "DB_ADMIN"), Locale.ENGLISH);
UserDto motechUser = motechUserService.getUser("USERNAME");
assertNotNull(motechUser);
assertTrue(motechUser.getRoles().contains("IT_ADMIN"));
assertTrue(motechUser.getRoles().contains("DB_ADMIN"));
}
use of org.motechproject.security.model.UserDto in project motech by motech.
the class MotechUserServiceBundleIT method shouldNotActivateUserWhenPasswordsAreTheSame.
@Test
public void shouldNotActivateUserWhenPasswordsAreTheSame() {
motechUserService.register("expired", "password", "1234", "", asList("IT_ADMIN"), Locale.ENGLISH, UserStatus.MUST_CHANGE_PASSWORD, "");
MotechUserProfile profile = motechUserService.changeExpiredPassword("expired", "password", "password");
assertNull(profile);
UserDto userDto = motechUserService.getUser("expired");
assertEquals(UserStatus.MUST_CHANGE_PASSWORD, userDto.getUserStatus());
}
use of org.motechproject.security.model.UserDto in project motech by motech.
the class MotechUserServiceBundleIT method shouldChangeExpiredPassword.
@Test
public void shouldChangeExpiredPassword() {
motechUserService.register("expired", "password", "1234", "", asList("IT_ADMIN"), Locale.ENGLISH, UserStatus.MUST_CHANGE_PASSWORD, "");
MotechUserProfile profile = motechUserService.changeExpiredPassword("expired", "password", "newPassword");
assertNotNull(profile);
assertEquals(UserStatus.ACTIVE, profile.getUserStatus());
UserDto userDto = motechUserService.getUser("expired");
assertEquals(UserStatus.ACTIVE, userDto.getUserStatus());
}
use of org.motechproject.security.model.UserDto in project motech by motech.
the class UserControllerTest method shouldPrintErrorsFromValidators.
@Test
public void shouldPrintErrorsFromValidators() throws Exception {
when(localeService.getUserLocale(any(HttpServletRequest.class))).thenReturn(Locale.GERMAN);
when(settingService.getPasswordValidator()).thenReturn(validator);
when(validator.getValidationError(Locale.GERMAN)).thenReturn("Error from validator");
doThrow(new PasswordValidatorException("error")).when(userService).register(eq("john"), eq("invalid"), eq("john@gmail.com"), eq(""), anyListOf(String.class), any(Locale.class));
UserDto userDto = new UserDto();
userDto.setUserName("john");
userDto.setEmail("john@gmail.com");
userDto.setPassword("invalid");
mockMvc.perform(post("/users/create").body(new ObjectMapper().writeValueAsBytes(userDto)).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest()).andExpect(content().string("literal:Error from validator"));
}
Aggregations