From 2dfd595d87cd6296c9614d0b48c0218ba35885f7 Mon Sep 17 00:00:00 2001 From: kyeong-hyeok Date: Wed, 6 Dec 2023 00:04:45 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=ED=86=A0=ED=81=B0=20=EC=9E=AC=EB=B0=9C?= =?UTF-8?q?=EA=B8=89=20Controller=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80=20(#62)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthControllerTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/com/project/mapdagu/domain/auth/controller/AuthControllerTest.java b/src/test/java/com/project/mapdagu/domain/auth/controller/AuthControllerTest.java index 7f6b42e..d616860 100644 --- a/src/test/java/com/project/mapdagu/domain/auth/controller/AuthControllerTest.java +++ b/src/test/java/com/project/mapdagu/domain/auth/controller/AuthControllerTest.java @@ -1,7 +1,9 @@ package com.project.mapdagu.domain.auth.controller; import com.fasterxml.jackson.databind.ObjectMapper; +import com.project.mapdagu.domain.auth.dto.request.RefreshTokenRequest; import com.project.mapdagu.domain.auth.service.AuthService; +import com.project.mapdagu.jwt.service.JwtService; import com.project.mapdagu.utils.TestUserArgumentResolver; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,6 +31,8 @@ class AuthControllerTest { private AuthController authController; @Mock private AuthService authService; + @Mock + private JwtService jwtService; private ObjectMapper objectMapper = new ObjectMapper(); private MockMvc mockMvc; @@ -51,4 +55,19 @@ void setUp() { result.andExpect(status().isNoContent()); verify(authService, times(1)).logout(any(), anyString()); } + + @Test + void 토큰_재발급() throws Exception { + //given + RefreshTokenRequest request = new RefreshTokenRequest("refreshToken"); + //when + ResultActions result = mockMvc.perform( + post("/auth/reIssue") + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(request)) + ); + //then + result.andExpect(status().isNoContent()); + verify(jwtService, times(1)).reIssueToken(any(), anyString()); + } } \ No newline at end of file