public String postLogin(@AuthenticationPrincipal CustomUserDetails userDetails) {
authService.auth(userDetails.getId());
redirect "redirect: /main";
} и метод тестирования: @Test
void postLogin_success() выдает исключение {
UserDTO userDTO = createUserDTO(1, "Пользователь", "user@mail.ru", "пароль");
Код: Выделить всё
when(authService.auth(anyInt())).thenReturn(userDTO);
mockMvc.perform(post("/login")
.with(csrf())
.principal(authenticationToken)
.characterEncoding("UTF-8")
.param("email", "user@mail.ru")
.param("password", "password"))
.andDo(print())
.andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl("/main"));
} but it shows an error: java.lang.AssertionError: Redirected URL expected: but was:
Фактическое:/login?error
Подробнее здесь: https://stackoverflow.com/questions/792 ... nprincipal
Мобильная версия