Skip to content

Commit

Permalink
test: 토큰 재발급 Controller 테스트 코드 추가 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyeong-hyeok committed Dec 5, 2023
1 parent 4646dbb commit 2dfd595
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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());
}
}

0 comments on commit 2dfd595

Please sign in to comment.