Skip to content

Commit

Permalink
#140 Github/KakaoAuthCodeRequestUrlProvider 테스트 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
1o18z committed Sep 23, 2023
1 parent 381ee45 commit 2797cda
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
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);
}

}
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);
}

}

0 comments on commit 2797cda

Please sign in to comment.