-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT/#17] 가입 계정 플랫폼 조회 기능 구현 #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
06100ff
[FEAT] 가입 소셜 계정 조회 UseCase 정의
yummygyudon 3b9839c
[FEAT] 가입 소셜 계정 조회 UseCase 기능 구현
yummygyudon 6bab443
[FEAT] 조회 성공 케이스에 대한 Success Code 구현
yummygyudon cb5c7e8
[FEAT] 가입 소셜 계정 조회 API Response DTO 구현
yummygyudon 81834ef
[FEAT] 가입 소셜 계정 조회 API 정의 및 구현
yummygyudon dabedba
[FEAT] 인증 검사 대상 API 중 가입 플랫폼 조회 API 제외
yummygyudon 78d3dbb
[CHORE] jpa yaml 속성 추가
yummygyudon 67ad88e
[STYLE] 구현체 내용 및 패키지 이동 (user -> auth)
yummygyudon a4c38b0
[TEST] GetSocialAccountUsecase 구현체 테스트
yummygyudon cf47444
[CHORE] 불필요한 Success Code Enum 삭제 (`UserSuccess`)
yummygyudon 8e38d88
[CHORE] import 명시화 (`SocialAuthApiController`)
yummygyudon 080e6e7
[REFACTOR] Response Util 반영
yummygyudon 4f4d7d2
[STYLE] HttpStatus 종류 별 주석으로 영역 분리 (`AuthSuccess`)
yummygyudon f7b4b4a
[REFACTOR] Test 클래스 리팩토링
yummygyudon 1e73869
[REFACTOR] 인증 제외 대상 URI 리스트 상수화
yummygyudon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
10 changes: 10 additions & 0 deletions
10
src/main/java/sopt/makers/authentication/usecase/auth/port/in/GetSocialAccountUsecase.java
This file contains hidden or 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,10 @@ | ||
package sopt.makers.authentication.usecase.auth.port.in; | ||
|
||
public interface GetSocialAccountUsecase { | ||
|
||
SocialAccountPlatformInfo getSocialAccountPlatform(GetSocialAccountPlatformCommand command); | ||
|
||
record GetSocialAccountPlatformCommand(String name, String phone) {} | ||
|
||
record SocialAccountPlatformInfo(String platformName) {} | ||
} |
24 changes: 24 additions & 0 deletions
24
...java/sopt/makers/authentication/usecase/auth/service/GetSocialAccountPlatformService.java
This file contains hidden or 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,24 @@ | ||
package sopt.makers.authentication.usecase.auth.service; | ||
|
||
import sopt.makers.authentication.domain.auth.AuthPlatform; | ||
import sopt.makers.authentication.domain.user.User; | ||
import sopt.makers.authentication.usecase.auth.port.in.GetSocialAccountUsecase; | ||
import sopt.makers.authentication.usecase.auth.port.out.UserRepository; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class GetSocialAccountPlatformService implements GetSocialAccountUsecase { | ||
private final UserRepository userRepository; | ||
|
||
@Override | ||
public SocialAccountPlatformInfo getSocialAccountPlatform( | ||
GetSocialAccountPlatformCommand command) { | ||
User user = userRepository.findByPhone(command.phone()); | ||
AuthPlatform authPlatform = user.getSocialAccount().authPlatformType(); | ||
return new SocialAccountPlatformInfo(authPlatform.name()); | ||
} | ||
} |
This file contains hidden or 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
85 changes: 85 additions & 0 deletions
85
.../sopt/makers/authentication/usecase/auth/service/GetSocialAccountPlatformServiceTest.java
This file contains hidden or 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,85 @@ | ||
package sopt.makers.authentication.usecase.auth.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import sopt.makers.authentication.domain.auth.AuthPlatform; | ||
import sopt.makers.authentication.domain.auth.SocialAccount; | ||
import sopt.makers.authentication.domain.user.User; | ||
import sopt.makers.authentication.usecase.auth.port.in.GetSocialAccountUsecase; | ||
import sopt.makers.authentication.usecase.auth.port.out.UserRepository; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestPropertySource; | ||
|
||
@SpringBootTest | ||
@ActiveProfiles("local") | ||
@TestPropertySource(locations = {"classpath:env/local.env"}) | ||
class GetSocialAccountPlatformServiceTest { | ||
private static final String PLATFORM_NAME_GOOGLE = "GOOGLE"; | ||
private static final String PLATFORM_NAME_APPLE = "APPLE"; | ||
private static final String TEST_AUTH_ID = "test"; | ||
private static final String TEST_USER_PHONE_FOR_GOOGLE = "01012345678"; | ||
private static final String TEST_USER_PHONE_FOR_APPLE = "01087654321"; | ||
|
||
@MockBean UserRepository userRepository; | ||
|
||
@Autowired GetSocialAccountPlatformService getSocialAccountPlatformService; | ||
|
||
@BeforeEach | ||
void setMockUser() { | ||
User mockedUserForGoogle = mock(User.class); | ||
User mockedUserForApple = mock(User.class); | ||
SocialAccount mockedSocialAccountForGoogle = mock(SocialAccount.class); | ||
SocialAccount mockedSocialAccountForApple = mock(SocialAccount.class); | ||
|
||
given(mockedSocialAccountForGoogle.authPlatformId()).willReturn(TEST_AUTH_ID); | ||
given(mockedSocialAccountForApple.authPlatformId()).willReturn(TEST_AUTH_ID); | ||
given(mockedSocialAccountForGoogle.authPlatformType()).willReturn(AuthPlatform.GOOGLE); | ||
given(mockedSocialAccountForApple.authPlatformType()).willReturn(AuthPlatform.APPLE); | ||
|
||
given(mockedUserForGoogle.getSocialAccount()).willReturn(mockedSocialAccountForGoogle); | ||
given(mockedUserForApple.getSocialAccount()).willReturn(mockedSocialAccountForApple); | ||
|
||
when(userRepository.findByPhone(TEST_USER_PHONE_FOR_GOOGLE)).thenReturn(mockedUserForGoogle); | ||
when(userRepository.findByPhone(TEST_USER_PHONE_FOR_APPLE)).thenReturn(mockedUserForApple); | ||
} | ||
|
||
@ParameterizedTest(name = "({index}) command : {0} -> result : {1}") | ||
@DisplayName("주어진 Command에 대해 의도한 결과값을 반환한다") | ||
@MethodSource("argsForGetPlatformInfoTest") | ||
void 주어진_Command에_대해_의도한_결과값을_반환한다( | ||
// given | ||
GetSocialAccountUsecase.GetSocialAccountPlatformCommand givenCommand, String expectedResult) { | ||
// when | ||
GetSocialAccountUsecase.SocialAccountPlatformInfo result = | ||
getSocialAccountPlatformService.getSocialAccountPlatform(givenCommand); | ||
|
||
// then | ||
assertThat(result.platformName()).isEqualTo(expectedResult); | ||
} | ||
|
||
static Stream<Arguments> argsForGetPlatformInfoTest() { | ||
return Stream.of( | ||
Arguments.of( | ||
new GetSocialAccountUsecase.GetSocialAccountPlatformCommand( | ||
null, TEST_USER_PHONE_FOR_GOOGLE), | ||
PLATFORM_NAME_GOOGLE), | ||
Arguments.of( | ||
new GetSocialAccountUsecase.GetSocialAccountPlatformCommand( | ||
null, TEST_USER_PHONE_FOR_APPLE), | ||
PLATFORM_NAME_APPLE)); | ||
} | ||
yummygyudon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.