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 all 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.DevAuthClient;
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 prodAuthClient() {
return new AuthClient(createRestClient());
}

@Bean
@Profile({"default", "dev"})
public AuthClient devAuthclient() {
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 DevAuthClient(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 DevAuthClient extends AuthClient {

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

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