// when
ResultActionsactions = mockMvc.perform(patch("/api/diary/{id}", 1L)
.content(json)
.contentType(APPLICATION_JSON));
// then
actions.andExpect(status().isOk())
.andDo(print());
java.lang.AssertionError: Status expected:<200> but was:<403>
Expected :200
Actual :403
<Click to see difference>
at org.springframework.test.util.AssertionErrors.fail(AssertionErrors.java:59)
at org.springframework.test.util.AssertionErrors.assertEquals(AssertionErrors.java:122)
at org.springframework.test.web.servlet.result.StatusResultMatchers.lambda$matcher$9(StatusResultMatchers.java:627)
at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:214)
at nero.diary.domain.diary.api.DiaryApiControllerTest.update(DiaryApiControllerTest.java:200)
.with(csrf())
코드를 추가// when
ResultActionsactions = mockMvc.perform(patch("/api/diary/{id}", 1L)
// add !!
.with(csrf())
//
.content(json)
.contentType(APPLICATION_JSON));
// then
actions.andExpect(status().isOk())
.andDo(print());
✨ 정확한 원인, 해결법은 아니고 이외 틀린거 있으면 지적과 참고만 해주시길바랍니다