-
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.
✅ #140 Github/KakaoAuthCodeRequestUrlProvider 테스트 코드 작성
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...dev/backlog/auth/infrastructure/github/authCode/GithubAuthCodeRequestUrlProviderTest.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,42 @@ | ||
package dev.backlog.auth.infrastructure.github.authCode; | ||
|
||
import dev.backlog.auth.domain.oauth.OAuthProvider; | ||
import dev.backlog.auth.infrastructure.github.config.GithubProperties; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class GithubAuthCodeRequestUrlProviderTest { | ||
|
||
@Mock | ||
private GithubProperties githubProperties; | ||
|
||
@InjectMocks | ||
private GithubAuthCodeRequestUrlProvider provider; | ||
|
||
@Test | ||
void oAuthProvider() { | ||
OAuthProvider oAuthProvider = provider.oAuthProvider(); | ||
|
||
assertThat(oAuthProvider).isEqualTo(OAuthProvider.GITHUB); | ||
} | ||
|
||
@Test | ||
void provide() { | ||
String resultUrl = "https://github.com/login/oauth/authorize?client_id=testClientId&redirect_uri=https://testClientId/redirect"; | ||
|
||
when(githubProperties.getClientId()).thenReturn("testClientId"); | ||
when(githubProperties.getRedirectUrl()).thenReturn("https://testClientId/redirect"); | ||
|
||
String expectedUrl = provider.provide(); | ||
|
||
assertThat(resultUrl).isEqualTo(expectedUrl); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...a/dev/backlog/auth/infrastructure/kakao/authcode/KakaoAuthCodeRequestUrlProviderTest.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,42 @@ | ||
package dev.backlog.auth.infrastructure.kakao.authcode; | ||
|
||
import dev.backlog.auth.domain.oauth.OAuthProvider; | ||
import dev.backlog.auth.infrastructure.kakao.config.KakaoProperties; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class KakaoAuthCodeRequestUrlProviderTest { | ||
|
||
@Mock | ||
private KakaoProperties kakaoProperties; | ||
|
||
@InjectMocks | ||
private KakaoAuthCodeRequestUrlProvider provider; | ||
|
||
@Test | ||
void oAuthProvider() { | ||
OAuthProvider oAuthProvider = provider.oAuthProvider(); | ||
|
||
assertThat(oAuthProvider).isEqualTo(OAuthProvider.KAKAO); | ||
} | ||
|
||
@Test | ||
void provide() { | ||
String resultUrl = "https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=testClientId&redirect_uri=https://testClientId/redirect"; | ||
|
||
when(kakaoProperties.getClientId()).thenReturn("testClientId"); | ||
when(kakaoProperties.getRedirectUrl()).thenReturn("https://testClientId/redirect"); | ||
|
||
String expectedUrl = provider.provide(); | ||
|
||
assertThat(resultUrl).isEqualTo(expectedUrl); | ||
} | ||
|
||
} |