파트너 계정을 생성하려면 MANAGER 권한이 필요하다.
@Test
@DisplayName("회원 가입 성공 - PARTNER_IN_OFFICE")
void signupSuccessForPartnerInOffice() throws Exception {
  // given
  SignupDto.Request signupDto = SignupDto.Request.builder()
      .username("username")
      .password("password")
      .name("testName")
      .address("testAddress")
      .mobile("010-1234-5678")
      .mail("test@mail.com")
      .role("PARTNER_IN_OFFICE")
      .build();

  ObjectMapper objectMapper = new ObjectMapper();
  String jsonContent = objectMapper.writeValueAsString(signupDto);

  // when
  mockMvc.perform(post("/signup/partner/office")
          .contentType(MediaType.APPLICATION_JSON)
          .content(jsonContent))
      .andExpect(status().isOk());
}

 

  • 이렇게 그냥 진행 했더니
    • 403(Fobidden) 금지 됐다는 상태번호와 AssertionError 가 발생했다.

  • withMockUser 사용하기

MANAGER 권한을 갖는 Mock User 생성

  • 처리 완.

+ Recent posts