use of org.motechproject.security.exception.PasswordTooShortException in project motech by motech.
the class UserControllerTest method shouldPrintMinPasswordLengthError.
@Test
public void shouldPrintMinPasswordLengthError() 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 PasswordTooShortException(20)).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("key:security.validator.error.min_length\nparams:20"));
}
Aggregations