@@ -6,15 +6,16 @@ import com.back.koreaTravelGuide.domain.user.enums.UserRole
66import com.back.koreaTravelGuide.domain.user.repository.UserRepository
77import com.fasterxml.jackson.databind.ObjectMapper
88import jakarta.servlet.http.Cookie
9- import org.junit.jupiter.api.Assertions.assertTrue
109import org.junit.jupiter.api.BeforeEach
1110import org.junit.jupiter.api.DisplayName
1211import org.junit.jupiter.api.Test
12+ import org.mockito.Mockito
1313import org.springframework.beans.factory.annotation.Autowired
1414import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
1515import org.springframework.boot.test.context.SpringBootTest
1616import org.springframework.context.annotation.Import
1717import org.springframework.data.redis.core.RedisTemplate
18+ import org.springframework.data.redis.core.ValueOperations
1819import org.springframework.http.MediaType
1920import org.springframework.test.context.ActiveProfiles
2021import org.springframework.test.web.servlet.MockMvc
@@ -47,6 +48,8 @@ class AuthControllerTest {
4748 @Autowired
4849 private lateinit var objectMapper: ObjectMapper
4950
51+ private lateinit var valueOperations: ValueOperations <String , String >
52+
5053 private lateinit var pendingUser: User
5154 private lateinit var generalUser: User
5255
@@ -73,6 +76,8 @@ class AuthControllerTest {
7376 oauthId = " test5678" ,
7477 ),
7578 )
79+
80+ valueOperations = redisTemplate.opsForValue()
7681 }
7782
7883 @Test
@@ -100,6 +105,7 @@ class AuthControllerTest {
100105 fun t2 () {
101106 // given
102107 val accessToken = jwtTokenProvider.createAccessToken(generalUser.id!! , generalUser.role)
108+ val remainingTime = jwtTokenProvider.getRemainingTime(accessToken)
103109
104110 // when & then
105111 mockMvc.perform(
@@ -111,8 +117,9 @@ class AuthControllerTest {
111117 .andExpect(jsonPath(" $.msg" ).value(" 로그아웃 되었습니다." ))
112118
113119 // verify
114- val isBlacklisted = redisTemplate.opsForValue().get(accessToken) != null
115- assertTrue(isBlacklisted)
120+ Mockito .verify(
121+ valueOperations,
122+ ).set(Mockito .eq(accessToken), Mockito .eq(" logout" ), Mockito .anyLong(), Mockito .eq(TimeUnit .MILLISECONDS ))
116123 }
117124
118125 @Test
@@ -121,7 +128,7 @@ class AuthControllerTest {
121128 // given
122129 val refreshToken = jwtTokenProvider.createRefreshToken(generalUser.id!! )
123130 val redisKey = " refreshToken:${generalUser.id} "
124- redisTemplate.opsForValue().set (redisKey, refreshToken, 7 , TimeUnit . DAYS )
131+ Mockito .` when `(valueOperations.get (redisKey)).thenReturn(refreshToken )
125132
126133 // when & then
127134 mockMvc.perform(
0 commit comments