Skip to content

Commit 9e81db5

Browse files
committed
test: 비어있는 리프레시 토큰 테스트 케이스 추가
1 parent 5c672ae commit 9e81db5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/test/java/com/example/solidconnection/auth/controller/RefreshTokenCookieManagerTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.junit.jupiter.api.DisplayName;
1313
import org.junit.jupiter.api.Nested;
1414
import org.junit.jupiter.api.Test;
15+
import org.junit.jupiter.params.ParameterizedTest;
16+
import org.junit.jupiter.params.provider.ValueSource;
1517
import org.springframework.mock.web.MockHttpServletRequest;
1618
import org.springframework.mock.web.MockHttpServletResponse;
1719

@@ -99,7 +101,7 @@ class 쿠키에서_리프레시_토큰을_추출한다 {
99101
}
100102

101103
@Test
102-
void 리프레시_토큰에_해당하는_쿠키가_없으면_예외가_발생한다() {
104+
void 리프레시_토큰_쿠키가_없으면_예외가_발생한다() {
103105
// given
104106
MockHttpServletRequest request = new MockHttpServletRequest();
105107
request.setCookies(new Cookie("otherCookie", "some-value"));
@@ -109,5 +111,18 @@ class 쿠키에서_리프레시_토큰을_추출한다 {
109111
.isInstanceOf(CustomException.class)
110112
.hasMessageContaining(ErrorCode.REFRESH_TOKEN_NOT_EXISTS.getMessage());
111113
}
114+
115+
@ParameterizedTest
116+
@ValueSource(strings = {"", " "})
117+
void 리프레시_토큰_쿠키가_비어있으면_예외가_발생한다(String token) {
118+
// given
119+
MockHttpServletRequest request = new MockHttpServletRequest();
120+
request.setCookies(new Cookie(REFRESH_TOKEN_COOKIE_NAME, token));
121+
122+
// when & then
123+
assertThatCode(() -> cookieManager.getRefreshToken(request))
124+
.isInstanceOf(CustomException.class)
125+
.hasMessageContaining(ErrorCode.REFRESH_TOKEN_NOT_EXISTS.getMessage());
126+
}
112127
}
113128
}

0 commit comments

Comments
 (0)