From 95e952c215ce561b305a8ca18f01179652068820 Mon Sep 17 00:00:00 2001 From: pricelees Date: Wed, 23 Jul 2025 15:09:36 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20JwtHandler=EC=97=90=EC=84=9C?= =?UTF-8?q?=EC=9D=98=20=EB=B9=88=20=ED=86=A0=ED=81=B0=EA=B0=92=20=EC=98=88?= =?UTF-8?q?=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt | 2 ++ .../kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt b/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt index 4437021b..29e7b38b 100644 --- a/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt +++ b/src/main/kotlin/roomescape/auth/infrastructure/jwt/JwtHandler.kt @@ -37,6 +37,8 @@ class JwtHandler( .body .get(MEMBER_ID_CLAIM_KEY, Number::class.java) .toLong() + } catch (_: IllegalArgumentException) { + throw AuthException(AuthErrorCode.TOKEN_NOT_FOUND) } catch (_: ExpiredJwtException) { throw AuthException(AuthErrorCode.EXPIRED_TOKEN) } catch (_: Exception) { diff --git a/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt b/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt index 91b9f376..a7ee570d 100644 --- a/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt +++ b/src/test/kotlin/roomescape/auth/infrastructure/jwt/JwtHandlerTest.kt @@ -41,7 +41,7 @@ class JwtHandlerTest : FunSpec({ test("토큰이 빈 값이면 예외를 던진다.") { shouldThrow { jwtHandler.getMemberIdFromToken("") - }.errorCode shouldBe AuthErrorCode.INVALID_TOKEN + }.errorCode shouldBe AuthErrorCode.TOKEN_NOT_FOUND } test("시크릿 키가 잘못된 경우 예외를 던진다.") {