-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MATE-127 : [REFACTOR] CATCH Mi 로그아웃 및 JWT 로직 리팩토링 (#116)
* MATE-127 : [FEAT] 로그아웃 관련 예외 처리 추가 * MATE-127 : [REFACTOR] 토큰 생성 리팩토링 * MATE-127 : [REFACTOR] 로그아웃 시 블랙리스트 추가 기능 리팩토링 및 인증 정보 삭제 추가 * MATE-127 : [REFACTOR] 로그아웃 컨트롤러 리팩토링 및 Swagger 추가 * MATE-127 : [TEST] 리팩토링 코드에 맞게 로그인, 로그아웃 관련 테스트 수정 * MATE-127 : [FEAT] 액세스 토큰의 유효 시간을 30분으로 수정
- Loading branch information
Showing
9 changed files
with
128 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.example.mate.domain.member.integration; | ||
|
||
import com.example.mate.common.jwt.JwtToken; | ||
import com.example.mate.common.security.util.JwtUtil; | ||
import com.example.mate.config.WithAuthMember; | ||
import com.example.mate.domain.constant.Gender; | ||
|
@@ -47,12 +48,14 @@ | |
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static com.example.mate.domain.match.entity.MatchStatus.SCHEDULED; | ||
import static com.example.mate.domain.mate.entity.Status.CLOSED; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.ArgumentMatchers.*; | ||
import static org.mockito.Mockito.doNothing; | ||
import static org.mockito.Mockito.when; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
|
@@ -277,7 +280,7 @@ private MemberInfoUpdateRequest createMemberInfoUpdateRequest() { | |
.memberId(member.getId()) | ||
.build(); | ||
} | ||
|
||
@Nested | ||
@DisplayName("자체 회원 가입") | ||
class Join { | ||
|
@@ -462,6 +465,16 @@ void login_member_success() throws Exception { | |
.email("[email protected]") | ||
.build(); | ||
|
||
// mockJwtToken 객체 생성 | ||
JwtToken mockJwtToken = JwtToken.builder() | ||
.grantType("Bearer") | ||
.accessToken("mockAccessToken") | ||
.refreshToken("mockRefreshToken") | ||
.build(); | ||
|
||
// JwtUtil의 createTokens 메서드 mock 처리 | ||
when(jwtUtil.createTokens(any(Member.class))).thenReturn(mockJwtToken); | ||
|
||
// when & then | ||
mockMvc.perform(post("/api/members/login") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
|
@@ -506,6 +519,11 @@ void logout_member_success_with_my_info_denied() throws Exception { | |
// given | ||
String token = "Bearer accessToken"; | ||
|
||
// mockJwtToken 객체 생성 | ||
Map<String, Object> mockClaims = Map.of("iat", new Date().getTime()); // 'iat' 필드를 mock 처리 | ||
when(jwtUtil.validateToken(anyString())).thenReturn(mockClaims); | ||
|
||
|
||
// when & then | ||
when(redisTemplate.opsForValue()).thenReturn(valueOperations); | ||
doNothing().when(valueOperations).set( | ||
|
Oops, something went wrong.