Skip to content
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

feat: 개발서버 테스트 환경 개선 #683

Open
wants to merge 5 commits into
base: chongdae
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test {
}

openapi3 {
servers = [{ url = 'http://13.124.137.6' },
servers = [{ url = 'https://dev.chongdae.site' },
{ url = 'http://localhost:8080' }]
title '총대마켓 API 명세서'
description '총대마켓 백엔드 API 명세서'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.zzang.chongdae.auth.config;

import com.zzang.chongdae.auth.service.AuthClient;
import com.zzang.chongdae.auth.service.TestAuthClient;
import java.time.Duration;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.ClientHttpRequestFactories;
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.web.client.RestClient;

@Configuration
@Slf4j
public class AuthClientConfig {

@Value("${auth.connect-timeout-length}")
Expand All @@ -20,10 +24,18 @@ public class AuthClientConfig {
private Duration readTimeoutLength;

@Bean
public AuthClient authClient() {
@Profile("prod")
public AuthClient realAuthClient() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public AuthClient realAuthClient() {
public AuthClient prodAuthClient() {

이런 네이밍은 어떨까요?

Copy link
Contributor Author

@fromitive fromitive Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real, External, Prod, Oauth 고민하다가 prod 와 real이 남았서 고민했었는데 메이슨 덕분에 네이밍 고민이 줄어들었네요 ㅎㅎ

prod 프로파일과 동일한 명칭이면 사용할 때 햇갈리지 않을 것 같아요

그럼 testAuthClient도 일관성에 맞게 devAuthClient로 변경할까 고민이네요..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일관성 있게 devAuthClient로 변경하는 것 찬성합니다! testAuthClient라는 명칭을 사용할 경우 dev 환경이 아닌 저희 로컬 테스트 환경으로 오해될 소지가 있는 것 같아요 :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 답변을 못 드렸었네요! 죄송합니다. 저도 devAuthClient 좋은 것 같아요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 그럼 devAuthClient, prodAuthClient 채택하겠습니다 의견 주셔서 고마워요 😄

return new AuthClient(createRestClient());
}

@Bean
@Profile({"default", "dev"})
public AuthClient testAuthClient() {
log.warn("테스트 인증 환경이 설정되었습니다. 프로덕션 환경이라면 서버 중지가 필요합니다.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 로깅해주는 거 좋네요~! 👍

return new TestAuthClient(createRestClient());
}

private RestClient createRestClient() {
return RestClient.builder()
.requestFactory(createRequestFactory())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.zzang.chongdae.auth.service;

import com.zzang.chongdae.global.exception.MarketException;
import org.springframework.web.client.RestClient;

public class TestAuthClient extends AuthClient {

public TestAuthClient(RestClient restClient) {
super(restClient);
}

@Override
public String getKakaoUserInfo(String accessToken) {
try {
return super.getKakaoUserInfo(accessToken);
} catch (MarketException e) {
return accessToken;
}
}
}