Test

    26. 프로필 수정 테스트

    인증된 사용자가 접근할 수 있는 기능 테스트하기 실제 DB에 저장되어 있는 정보에 대응하는 인증된 Authentication이 필요하다. @WithMockUser로는 처리할 수 없다. 인증된 사용자를 제공할 커스텀 애노테이션 만들기 @WithAccount https://docs.spring.io/spring-security/reference/servlet/test/method.html#test-method-setup @BeforeEach void beforeEach() { SignUpForm signUpForm = new SignUpForm(); signUpForm.setNickname("jungi"); signUpForm.setEmail("devjun63@gmail.com"); signUpForm.se..

    20. 로그인 / 로그아웃 테스트

    테스트 요점 정리 폼 서브밋 요청 (post)은 반드시 .with(csrf())를 추가할 것. .andExpect(authenticated()) 또는 .andExpect(unauthenticated())로 인증 여부를 확인할 수 있다. 리다이렉트 응답은 .andExpect(status().is3xxRedirection()) 로 확인한다. 리다이렉트 URL은 .andExpect(redirectedUrl()) 로 확인할 수 있다. JUnit 5의 @BeforeEach와 @AfterEach. 임의로 로그인 된 사용자가 필요한 경우에는 @WithMockUser. spring security -> form 그냥 보내면 안됨 why? csrf라는 protection활성화 token param값을 다르게 주고 싶다면..