Skip to content

Commit

Permalink
chore : dev 환경도 테스트가 동작하도록 변수 분리
Browse files Browse the repository at this point in the history
- 다시초기화 dev 환경에서도 돌아가게하려면 카카오 앱을 하나 더 만들어야함..
  • Loading branch information
JiwonKKang committed Jul 25, 2024
1 parent 1dc3bde commit c7c930e
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 24 deletions.
2 changes: 0 additions & 2 deletions application/app-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ dependencies {

//aop
implementation 'org.springframework.boot:spring-boot-starter-aop'

//spring-json
implementation 'org.springframework.boot:spring-boot-configuration-processor'

//JWT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package core.startup.mealtoktok.api.auth;

import core.startup.mealtoktok.api.auth.request.SignupRequest;
import core.startup.mealtoktok.api.auth.response.OAuthLogin;
import core.startup.mealtoktok.api.dto.SignupRequest;
import core.startup.mealtoktok.api.dto.OAuthLoginResponse;
import core.startup.mealtoktok.common.dto.Response;
import core.startup.mealtoktok.domain.auth.AuthService;
import core.startup.mealtoktok.domain.auth.JwtTokens;
import core.startup.mealtoktok.domain.auth.OAuthTokens;
import core.startup.mealtoktok.api.global.security.JwtTokenizer;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/auth")
@Slf4j
public class AuthApi implements AuthApiDocs {

private final AuthService authService;
Expand All @@ -38,13 +40,13 @@ public Response<Void> signUp(@RequestBody SignupRequest signupRequest, HttpServl
}

@GetMapping("/oauth/login/link")
public Response<OAuthLogin> oauthLoginLink() {
OAuthLogin oAuthLogin = OAuthLogin.from(authService.getKakaoLoginLink());
return Response.success(oAuthLogin);
public Response<OAuthLoginResponse> oauthLoginLink() {
OAuthLoginResponse oAuthLoginResponse = OAuthLoginResponse.from(authService.getKakaoLoginLink());
return Response.success(oAuthLoginResponse);
}

@GetMapping("/login/oauth2/code/kakao")
public Response<Void> credentialTest(@RequestParam String code) {
public Response<Void> credentialTest(@RequestParam("code") String code) {
authService.getCredentialTest(code);
return Response.success("테스트 성공");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package core.startup.mealtoktok.api.auth;

import core.startup.mealtoktok.api.auth.request.SignupRequest;
import core.startup.mealtoktok.api.auth.response.OAuthLogin;
import core.startup.mealtoktok.api.dto.SignupRequest;
import core.startup.mealtoktok.api.dto.OAuthLoginResponse;
import core.startup.mealtoktok.common.dto.Response;
import core.startup.mealtoktok.domain.auth.OAuthTokens;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -22,7 +22,7 @@ public interface AuthApiDocs {
Response<Void> login(OAuthTokens oAuthTokens, HttpServletResponse response);

@Operation(summary = "OAuth 링크발급(백엔드 개발 테스트용입니다)")
Response<OAuthLogin> oauthLoginLink();
Response<OAuthLoginResponse> oauthLoginLink();

@Operation(summary = "OAuth code를 통한 테스트(백엔드 개발 테스트용입니다)")
Response<Void> credentialTest(@RequestParam String code);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package core.startup.mealtoktok.api.dto;

public record OAuthLoginResponse(
String link
) {
public static OAuthLoginResponse from(String link) {
return new OAuthLoginResponse(link);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core.startup.mealtoktok.api.auth.request;
package core.startup.mealtoktok.api.dto;

import core.startup.mealtoktok.domain.auth.OAuthTokens;
import core.startup.mealtoktok.domain.user.AddressWithCoordinate;
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/application-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ oauth:
app-id: ${KAKAO_APP_ID}
admin-key: ${KAKAO_ADMIN_KEY}
service-key: ${KAKAO_REST_API_KEY}

---
spring:
config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public class UserReader {
private final UserCacheManager userCacheManager;

public User read(TargetUser targetUser) {
return userCacheManager.read(targetUser).orElseGet( () ->
userRepository.findById(targetUser)
);
return userCacheManager.read(targetUser).orElseGet( () ->{
User user = userRepository.findById(targetUser);
userCacheManager.cache(user);
return user;
});
}

public boolean isAlreadyRegistered(OAuthInfo oAuthInfo) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
Expand Down Expand Up @@ -58,6 +59,7 @@ public RedisTemplate<String, RefreshToken> tokenRedisTemplate() {
}

@Bean
@Primary
public RedisTemplate<String, String> banTokenRedisTemplate() {
RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory());
Expand Down

0 comments on commit c7c930e

Please sign in to comment.