Skip to content

Commit

Permalink
test: 테스트에서만 강제로 Security 우회하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kkanggu committed Nov 27, 2023
1 parent a702065 commit c3ceed1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JwtVerifier(
private val tokenAlgorithm: Algorithm,
@Value("\${spring.profiles.active}") private val profile: String
) {
private val alwaysAllowProfiles = listOf("dev", "local", "test")
private val alwaysAllowProfiles = listOf("test")

val tokenVerifier: JWTVerifier = JWT
.require(tokenAlgorithm)
Expand All @@ -27,6 +27,10 @@ class JwtVerifier(
.build()

fun verify(request: HttpServletRequest): TokenDto? {
if (profile in alwaysAllowProfiles) {
return TokenDto(userId = 2, userRole = "STUDENT")
}

val bearerToken = request.getHeader("Authorization") ?: return null
if (!bearerToken.startsWith("Bearer ")) {
return null
Expand Down

0 comments on commit c3ceed1

Please sign in to comment.