-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* test: JwtDecoderTest Fixture 추가 및 테스트 케이스 리펙토링 * test: JwtEncoderTest Fixture 추가 및 테스트 케이스 리펙토링 * test: 사용하지 않는 필드 제거와 final 제거 * test: KakaoOauth2TypeTest Fixture 추가 및 테스트 케이스 리펙토링 * test: KakaoUserInformationProviderTest Fixture 추가 및 테스트 케이스 리펙토링 * test: JpaBlackListTokenRepositoryTest Fixture 추가 및 테스트 케이스 리펙토링 * test: AuthenticationServiceFixture Fixture 추가 및 테스트 케이스 리펙토링 * test: AuthenticationUserServiceTest Fixture 추가 및 테스트 케이스 리펙토링 * test: Fixture가 가지고 있던 테스트 관련 어노테이션을 기존 테스트 클래스로 변경 * test: BlackListTokenServiceTest Fixture 추가 및 테스트 케이스 리펙토링 * refactor: 로그인 메서드 네이밍 변경 * test: AuthenticationControllerTest Fixture 추가 및 테스트 케이스 리펙토링 * test: 누락된 테스트 케이스 추가 * test: AuthenticationServiceTest Fixture 및 테스트 케이스 수정 * test: AuthenticationControllerTest Fixture 및 테스트 케이스 수정 * test: KakaoUserInformationProviderTest Fixture 및 테스트 케이스 수정 * test: JpaBlackListTokenRepositoryFixture Fixture 내용 변경 * test: AuthenticationServiceTest 관련 사용하지 않는 Fixture 삭제 및 필드 변경 * test: KakaoUserInformationProviderTest 관련 테스트 대상을 Fixture에서 테스트 클래스로 변경
- Loading branch information
Showing
19 changed files
with
659 additions
and
554 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
292 changes: 81 additions & 211 deletions
292
...g/src/test/java/com/ddang/ddang/authentication/application/AuthenticationServiceTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
39 changes: 6 additions & 33 deletions
39
...c/test/java/com/ddang/ddang/authentication/application/AuthenticationUserServiceTest.java
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
134 changes: 134 additions & 0 deletions
134
...java/com/ddang/ddang/authentication/application/fixture/AuthenticationServiceFixture.java
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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package com.ddang.ddang.authentication.application.fixture; | ||
|
||
import com.ddang.ddang.authentication.domain.TokenEncoder; | ||
import com.ddang.ddang.authentication.domain.TokenType; | ||
import com.ddang.ddang.authentication.domain.dto.UserInformationDto; | ||
import com.ddang.ddang.authentication.infrastructure.oauth2.Oauth2Type; | ||
import com.ddang.ddang.device.domain.DeviceToken; | ||
import com.ddang.ddang.device.infrastructure.persistence.JpaDeviceTokenRepository; | ||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.image.infrastructure.persistence.JpaProfileImageRepository; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import java.time.Instant; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class AuthenticationServiceFixture { | ||
|
||
protected Oauth2Type 지원하는_소셜_로그인_타입 = Oauth2Type.KAKAO; | ||
protected Oauth2Type 지원하지_않는_소셜_로그인_타입 = Oauth2Type.KAKAO; | ||
|
||
protected String 유효한_소셜_로그인_토큰 = "Bearer accessToken"; | ||
protected String 만료된_소셜_로그인_토큰; | ||
|
||
protected String 디바이스_토큰 = "deviceToken"; | ||
|
||
protected User 사용자; | ||
protected User 탈퇴한_사용자; | ||
protected User 이미지가_없는_사용자; | ||
|
||
protected UserInformationDto 사용자_회원_정보 = new UserInformationDto(12345L); | ||
protected UserInformationDto 탈퇴한_사용자_회원_정보 = new UserInformationDto(54321L); | ||
protected UserInformationDto 가입하지_않은_사용자_회원_정보 = new UserInformationDto(-99999L); | ||
|
||
protected String 유효한_액세스_토큰; | ||
protected String 유효하지_않은_액세스_토큰 = "Bearer invalidAccessToken"; | ||
protected String 탈퇴한_사용자_액세스_토큰; | ||
protected String 이미지가_없는_사용자_액세스_토큰; | ||
protected String 존재하지_않는_사용자_액세스_토큰; | ||
protected String 유효한_리프레시_토큰; | ||
protected String 만료된_리프레시_토큰; | ||
protected String 유효하지_않은_타입의_리프레시_토큰 = "invalidRefreshToken"; | ||
|
||
@Autowired | ||
private JpaUserRepository userRepository; | ||
|
||
@Autowired | ||
private JpaProfileImageRepository profileImageRepository; | ||
|
||
@Autowired | ||
private TokenEncoder tokenEncoder; | ||
|
||
@Autowired | ||
private JpaDeviceTokenRepository deviceTokenRepository; | ||
|
||
@BeforeEach | ||
void fixtureSetUp() { | ||
profileImageRepository.save(new ProfileImage("default_profile_image.png", "default_profile_image.png")); | ||
|
||
사용자 = User.builder() | ||
.name("kakao12345") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(0.0d) | ||
.oauthId("12345") | ||
.build(); | ||
|
||
탈퇴한_사용자 = User.builder() | ||
.name("kakao12346") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(0.0d) | ||
.oauthId("12346") | ||
.build(); | ||
|
||
이미지가_없는_사용자 = User.builder() | ||
.name("kakao12347") | ||
.profileImage(null) | ||
.reliability(0.0d) | ||
.oauthId("12347") | ||
.build(); | ||
|
||
userRepository.save(사용자); | ||
탈퇴한_사용자.withdrawal(); | ||
userRepository.save(탈퇴한_사용자); | ||
|
||
final DeviceToken deviceToken = new DeviceToken(사용자, 디바이스_토큰); | ||
deviceTokenRepository.save(deviceToken); | ||
|
||
유효한_리프레시_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.REFRESH, | ||
Map.of("userId", 1L) | ||
); | ||
|
||
만료된_리프레시_토큰 = tokenEncoder.encode( | ||
LocalDateTime.ofInstant(Instant.parse("2023-01-01T22:21:20Z"), ZoneId.of("UTC")), | ||
TokenType.REFRESH, | ||
Map.of("userId", 1L) | ||
); | ||
|
||
만료된_소셜_로그인_토큰 = tokenEncoder.encode( | ||
Instant.parse("2000-08-10T15:30:00Z").atZone(ZoneId.of("UTC")).toLocalDateTime(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 1L) | ||
); | ||
|
||
유효한_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 1L) | ||
); | ||
|
||
탈퇴한_사용자_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 탈퇴한_사용자.getId()) | ||
); | ||
|
||
이미지가_없는_사용자_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 가입하지_않은_사용자_회원_정보.id()) | ||
); | ||
|
||
존재하지_않는_사용자_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", -99999L) | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../com/ddang/ddang/authentication/application/fixture/AuthenticationUserServiceFixture.java
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.ddang.ddang.authentication.application.fixture; | ||
|
||
import com.ddang.ddang.image.domain.ProfileImage; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class AuthenticationUserServiceFixture { | ||
|
||
@Autowired | ||
private JpaUserRepository userRepository; | ||
|
||
protected User 사용자; | ||
protected User 탈퇴한_사용자; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
사용자 = User.builder() | ||
.name("kakao12345") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(0.0d) | ||
.oauthId("12345") | ||
.build(); | ||
|
||
탈퇴한_사용자 = User.builder() | ||
.name("kakao12346") | ||
.profileImage(new ProfileImage("upload.png", "store.png")) | ||
.reliability(0.0d) | ||
.oauthId("12346") | ||
.build(); | ||
|
||
userRepository.save(사용자); | ||
userRepository.save(탈퇴한_사용자); | ||
|
||
탈퇴한_사용자.withdrawal(); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...java/com/ddang/ddang/authentication/application/fixture/BlackListTokenServiceFixture.java
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.ddang.ddang.authentication.application.fixture; | ||
|
||
import com.ddang.ddang.authentication.domain.BlackListToken; | ||
import com.ddang.ddang.authentication.domain.TokenEncoder; | ||
import com.ddang.ddang.authentication.domain.TokenType; | ||
import com.ddang.ddang.authentication.infrastructure.persistence.JpaBlackListTokenRepository; | ||
import java.time.LocalDateTime; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
public class BlackListTokenServiceFixture { | ||
|
||
@Autowired | ||
private JpaBlackListTokenRepository blackListTokenRepository; | ||
|
||
@Autowired | ||
private TokenEncoder tokenEncoder; | ||
|
||
protected String 유효한_액세스_토큰; | ||
protected String 유효한_리프레시_토큰; | ||
protected String 만료된_액세스_토큰; | ||
protected String 만료된_리프레시_토큰; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
유효한_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 1L) | ||
); | ||
유효한_리프레시_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.REFRESH, | ||
Map.of("userId", 1L) | ||
); | ||
만료된_액세스_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.ACCESS, | ||
Map.of("userId", 2L) | ||
); | ||
만료된_리프레시_토큰 = tokenEncoder.encode( | ||
LocalDateTime.now(), | ||
TokenType.REFRESH, | ||
Map.of("userId", 2L) | ||
); | ||
|
||
blackListTokenRepository.save(new BlackListToken(TokenType.ACCESS, 만료된_액세스_토큰)); | ||
blackListTokenRepository.save(new BlackListToken(TokenType.REFRESH, 만료된_리프레시_토큰)); | ||
} | ||
} |
Oops, something went wrong.