generated from pricelees/issue-pr-template
[#22] 프론트엔드 React 전환 및 인증 API 수정 #23
@ -39,6 +39,6 @@ class AuthController(
|
|||||||
override fun logout(@MemberId memberId: Long): ResponseEntity<CommonApiResponse<Unit>> {
|
override fun logout(@MemberId memberId: Long): ResponseEntity<CommonApiResponse<Unit>> {
|
||||||
authService.logout(memberId)
|
authService.logout(memberId)
|
||||||
|
|
||||||
return ResponseEntity.ok(CommonApiResponse())
|
return ResponseEntity.noContent().build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -125,17 +125,20 @@ class AuthControllerTest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Given("로그아웃 요청을 보낼 때") {
|
Given("로그아웃 요청을 보낼 때") {
|
||||||
val endpoint = "/logout"
|
val endpoint = "/logout"
|
||||||
|
|
||||||
When("토큰의 유효성 & 회원 존재 여부와 무관하게") {
|
When("토큰으로 memberId 조회가 가능하면") {
|
||||||
|
every {
|
||||||
|
jwtHandler.getMemberIdFromToken(any())
|
||||||
|
} returns 1L
|
||||||
|
|
||||||
Then("정상 응답한다.") {
|
Then("정상 응답한다.") {
|
||||||
runPostTest(
|
runPostTest(
|
||||||
mockMvc = mockMvc,
|
mockMvc = mockMvc,
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
) {
|
) {
|
||||||
status { isOk() }
|
status { isNoContent() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ abstract class RoomescapeApiTest : BehaviorSpec() {
|
|||||||
log: Boolean = false,
|
log: Boolean = false,
|
||||||
assert: MockMvcResultMatchersDsl.() -> Unit
|
assert: MockMvcResultMatchersDsl.() -> Unit
|
||||||
): ResultActionsDsl = mockMvc.get(endpoint) {
|
): ResultActionsDsl = mockMvc.get(endpoint) {
|
||||||
header(HttpHeaders.COOKIE, "accessToken=token")
|
header(HttpHeaders.AUTHORIZATION, "Bearer token")
|
||||||
}.apply {
|
}.apply {
|
||||||
log.takeIf { it }?.let { this.andDo { print() } }
|
log.takeIf { it }?.let { this.andDo { print() } }
|
||||||
}.andExpect(assert)
|
}.andExpect(assert)
|
||||||
@ -59,7 +59,7 @@ abstract class RoomescapeApiTest : BehaviorSpec() {
|
|||||||
log: Boolean = false,
|
log: Boolean = false,
|
||||||
assert: MockMvcResultMatchersDsl.() -> Unit
|
assert: MockMvcResultMatchersDsl.() -> Unit
|
||||||
): ResultActionsDsl = mockMvc.post(endpoint) {
|
): ResultActionsDsl = mockMvc.post(endpoint) {
|
||||||
this.header(HttpHeaders.COOKIE, "accessToken=token")
|
this.header(HttpHeaders.AUTHORIZATION, "Bearer token")
|
||||||
body?.let {
|
body?.let {
|
||||||
this.contentType = MediaType.APPLICATION_JSON
|
this.contentType = MediaType.APPLICATION_JSON
|
||||||
this.content = objectMapper.writeValueAsString(it)
|
this.content = objectMapper.writeValueAsString(it)
|
||||||
@ -74,7 +74,7 @@ abstract class RoomescapeApiTest : BehaviorSpec() {
|
|||||||
log: Boolean = false,
|
log: Boolean = false,
|
||||||
assert: MockMvcResultMatchersDsl.() -> Unit
|
assert: MockMvcResultMatchersDsl.() -> Unit
|
||||||
): ResultActionsDsl = mockMvc.delete(endpoint) {
|
): ResultActionsDsl = mockMvc.delete(endpoint) {
|
||||||
header(HttpHeaders.COOKIE, "accessToken=token")
|
header(HttpHeaders.AUTHORIZATION, "Bearer token")
|
||||||
}.apply {
|
}.apply {
|
||||||
log.takeIf { it }?.let { this.andDo { print() } }
|
log.takeIf { it }?.let { this.andDo { print() } }
|
||||||
}.andExpect(assert)
|
}.andExpect(assert)
|
||||||
@ -109,14 +109,18 @@ abstract class RoomescapeApiTest : BehaviorSpec() {
|
|||||||
fun <T> MvcResult.readValue(valueType: Class<T>): T = this.response.contentAsString
|
fun <T> MvcResult.readValue(valueType: Class<T>): T = this.response.contentAsString
|
||||||
.takeIf { it.isNotBlank() }
|
.takeIf { it.isNotBlank() }
|
||||||
?.let { readValue(it, valueType) }
|
?.let { readValue(it, valueType) }
|
||||||
?: throw RuntimeException("""
|
?: throw RuntimeException(
|
||||||
|
"""
|
||||||
[Test] Exception occurred while reading response json: ${this.response.contentAsString} with value type: $valueType
|
[Test] Exception occurred while reading response json: ${this.response.contentAsString} with value type: $valueType
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
|
||||||
fun <T> readValue(responseJson: String, valueType: Class<T>): T = objectMapper
|
fun <T> readValue(responseJson: String, valueType: Class<T>): T = objectMapper
|
||||||
.readTree(responseJson)["data"]
|
.readTree(responseJson)["data"]
|
||||||
?.let { objectMapper.convertValue(it, valueType) }
|
?.let { objectMapper.convertValue(it, valueType) }
|
||||||
?: throw RuntimeException("""
|
?: throw RuntimeException(
|
||||||
|
"""
|
||||||
[Test] Exception occurred while reading response json: $responseJson with value type: $valueType
|
[Test] Exception occurred while reading response json: $responseJson with value type: $valueType
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user