파트너 계정을 생성하려면 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 사용하기
- 처리 완.
'Java > Spring' 카테고리의 다른 글
Redis로 ttl 설정해보기 (0) | 2024.03.18 |
---|---|
[에러] SLF4J: Class path contains multiple SLF4J bindings (0) | 2024.03.18 |
Test 이모저모 - Jackson 활용 (ObjectMapper.writeValueAsString) (0) | 2024.03.06 |
Test 이모저모 - when 의 필요성 (0) | 2024.03.05 |
[Spring Security] JwtAuthenticationFilter 구현 (0) | 2024.02.29 |