refactor: JwtHandler에서의 빈 토큰값 예외 처리 추가

This commit is contained in:
이상진 2025-07-23 15:09:36 +09:00
parent 357f53deb4
commit 95e952c215
2 changed files with 3 additions and 1 deletions

View File

@ -37,6 +37,8 @@ class JwtHandler(
.body .body
.get(MEMBER_ID_CLAIM_KEY, Number::class.java) .get(MEMBER_ID_CLAIM_KEY, Number::class.java)
.toLong() .toLong()
} catch (_: IllegalArgumentException) {
throw AuthException(AuthErrorCode.TOKEN_NOT_FOUND)
} catch (_: ExpiredJwtException) { } catch (_: ExpiredJwtException) {
throw AuthException(AuthErrorCode.EXPIRED_TOKEN) throw AuthException(AuthErrorCode.EXPIRED_TOKEN)
} catch (_: Exception) { } catch (_: Exception) {

View File

@ -41,7 +41,7 @@ class JwtHandlerTest : FunSpec({
test("토큰이 빈 값이면 예외를 던진다.") { test("토큰이 빈 값이면 예외를 던진다.") {
shouldThrow<AuthException> { shouldThrow<AuthException> {
jwtHandler.getMemberIdFromToken("") jwtHandler.getMemberIdFromToken("")
}.errorCode shouldBe AuthErrorCode.INVALID_TOKEN }.errorCode shouldBe AuthErrorCode.TOKEN_NOT_FOUND
} }
test("시크릿 키가 잘못된 경우 예외를 던진다.") { test("시크릿 키가 잘못된 경우 예외를 던진다.") {