Skip to content

Instantly share code, notes, and snippets.

@GHGHGHKO
Created February 23, 2023 13:06
Show Gist options
  • Select an option

  • Save GHGHGHKO/15f6bd4868e360d04b36458b59175624 to your computer and use it in GitHub Desktop.

Select an option

Save GHGHGHKO/15f6bd4868e360d04b36458b59175624 to your computer and use it in GitHub Desktop.
UserControllerTest accessDenied test code
@Test
fun `권한 문제로 유저 정보를 가져오지 못한다`() {
val signInRequestDto = SignInRequestDto(
email = ID + 0 + EMAIL,
password = PASSWORD
)
token = signService.signIn(signInRequestDto).token
mockMvc.get("/users/v1") {
contentType = MediaType.APPLICATION_JSON
header(X_AUTH_TOKEN, token)
}
.andDo { print() }
.andExpect { status { is4xxClientError() } }
.andExpect { jsonPath("$.success") { value(false) } }
.andExpect { jsonPath("$.code") { value(-1003) } }
.andExpect { jsonPath("$.message") { exists() } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment