Skip to content

Commit

Permalink
feat : restdoc swagger jwt bearer 세팅 (#78)
Browse files Browse the repository at this point in the history
* docs : 주석작성

* core : gradle 이상한거 삭제
  • Loading branch information
ImNM authored Sep 3, 2023
1 parent af805ec commit 537cb68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import com.higoods.api.auth.usecase.WithDrawUseCase
import com.higoods.api.common.BOOLEAN
import com.higoods.api.common.BaseControllerTest
import com.higoods.api.common.DocumentObjects
import com.higoods.api.common.DocumentObjects.authorizationHeaderDocs
import com.higoods.api.common.NUMBER
import com.higoods.api.common.OpenApiTag
import com.higoods.api.common.STRING
Expand Down Expand Up @@ -197,8 +196,7 @@ class AuthControllerTest : BaseControllerTest() {
}
.isStatus(200)
.makeDocument(
DocumentInfo(identifier = "로그아웃", tag = OpenApiTag.AUTH, description = "로그아웃"),
authorizationHeaderDocs
DocumentInfo(identifier = "로그아웃", tag = OpenApiTag.AUTH, description = "로그아웃")
)
}

Expand All @@ -210,8 +208,7 @@ class AuthControllerTest : BaseControllerTest() {
}
.isStatus(200)
.makeDocument(
DocumentInfo(identifier = "회원탈퇴", tag = OpenApiTag.AUTH, description = "회원탈퇴"),
authorizationHeaderDocs
DocumentInfo(identifier = "회원탈퇴", tag = OpenApiTag.AUTH, description = "회원탈퇴")
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ abstract class BaseControllerTest : FunSpec() {
"user",
authDetails.authorities
)
this.header(HttpHeaders.AUTHORIZATION, "bearerAuthJWT")
// 실제 토큰을 집어넣는이유.
// https://github.com/ePages-de/restdocs-api-spec/pull/86
// https://github.com/ePages-de/restdocs-api-spec/blob/4c735ca2796d0620ecef30e20471a173cec0809b/restdocs-api-spec/src/main/kotlin/com/epages/restdocs/apispec/JwtSecurityHandler.kt#L14
// 복호화해서 scope 들어있는 oauth 헤더가 아니면 자동으로 좌물쇠 채워주는 소스가 있습니다.
this.header(HttpHeaders.AUTHORIZATION, "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
}

protected fun ResultActions.isStatus(code: Int): ResultActions =
Expand All @@ -170,7 +174,6 @@ abstract class BaseControllerTest : FunSpec() {
.description(documentInfo.description)
.deprecated(documentInfo.deprecated)
.tag(documentInfo.tag.value),

snippets = snippets
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ object DocumentObjects : BaseControllerTest() {
"user.fcmInfo.appAlarm" type BOOLEAN means "FcmNotificationVo"
).toTypedArray()

val authorizationHeaderDocs = requestHeaders("Authorization" type STRING means "bearerAuthJWT")

override val controller: Any
get() = OBJECT
}

0 comments on commit 537cb68

Please sign in to comment.