From c2e23083d1d6d0ae33102475544c581d62cd4064 Mon Sep 17 00:00:00 2001 From: joohyun Date: Tue, 30 Apr 2024 13:39:21 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix/#16=20import=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=B0=8F=20CICD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++ .../t3t/apigateway/config/RedisConfig.java | 3 + .../com/t3t/apigateway/filter/JwtFilter.java | 3 +- src/main/resources/application-prod.yml | 6 +- src/main/resources/application.yml | 3 +- .../keymanager/SecretKeyManagerTest.java | 24 ++++--- src/test/resources/application.yml | 62 +++++++++++++++++++ 7 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 src/test/resources/application.yml diff --git a/pom.xml b/pom.xml index f7dcc4a..59975fd 100644 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,10 @@ org.springframework.boot spring-boot-starter-data-redis + + com.h2database + h2 + io.jsonwebtoken jjwt-api diff --git a/src/main/java/com/t3t/apigateway/config/RedisConfig.java b/src/main/java/com/t3t/apigateway/config/RedisConfig.java index 23fbb50..e8c0644 100644 --- a/src/main/java/com/t3t/apigateway/config/RedisConfig.java +++ b/src/main/java/com/t3t/apigateway/config/RedisConfig.java @@ -3,6 +3,7 @@ import com.t3t.apigateway.keymanager.properties.SecretKeyProperties; import com.t3t.apigateway.keymanager.service.SecretKeyManagerService; import com.t3t.apigateway.property.RedisProperties; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; @@ -15,6 +16,7 @@ @Configuration @EnableRedisRepositories +@Slf4j public class RedisConfig { @Bean public RedisProperties redisProperties(SecretKeyManagerService secretKeyManagerService, @@ -22,6 +24,7 @@ public RedisProperties redisProperties(SecretKeyManagerService secretKeyManagerS Environment environment){ String activeProfile = environment.getActiveProfiles()[0]; + String activeProfileSuffix = activeProfile.equals("prod") ? "" : "_" + activeProfile; return RedisProperties.builder() .host(secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisIpAddressKeyId())) diff --git a/src/main/java/com/t3t/apigateway/filter/JwtFilter.java b/src/main/java/com/t3t/apigateway/filter/JwtFilter.java index 5774ee9..9561af8 100644 --- a/src/main/java/com/t3t/apigateway/filter/JwtFilter.java +++ b/src/main/java/com/t3t/apigateway/filter/JwtFilter.java @@ -1,9 +1,8 @@ package com.t3t.apigateway.filter; -import com.t3t.apigateway.common.JwtUtils;; +import com.t3t.apigateway.common.JwtUtils; import com.t3t.apigateway.exception.TokenNotAuthenticatedExceptions; import com.t3t.apigateway.exception.TokenNotExistExceptions; -import com.t3t.apigateway.service.TokenService; import lombok.RequiredArgsConstructor; import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.GatewayFilterChain; diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 887fa0b..69e2d59 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,4 +1,8 @@ eureka: client: service-url: - defaultZone: ${eurekaServiceUrlDefaultZone} \ No newline at end of file + defaultZone: ${eurekaServiceUrlDefaultZone} + +spring: + auth: + host: ${authHost} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fa28295..6cdfdb8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -9,7 +9,7 @@ spring: active: dev auth: - host: ${authHost} + host: localhost eureka: instance: @@ -17,6 +17,7 @@ eureka: client: register-with-eureka: true fetch-registry: true + service-url: defaultZone: http://127.0.0.1:8761/eureka diff --git a/src/test/java/com/t3t/apigateway/keymanager/SecretKeyManagerTest.java b/src/test/java/com/t3t/apigateway/keymanager/SecretKeyManagerTest.java index fb38569..6879487 100644 --- a/src/test/java/com/t3t/apigateway/keymanager/SecretKeyManagerTest.java +++ b/src/test/java/com/t3t/apigateway/keymanager/SecretKeyManagerTest.java @@ -5,7 +5,6 @@ import com.t3t.apigateway.keymanager.service.SecretKeyManagerService; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -38,7 +37,7 @@ class SecretKeyManagerTest { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void databaseIpAddressLoadTest() { // when & then @@ -55,7 +54,7 @@ void databaseIpAddressLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void databasePortLoadTest() { // when & then @@ -72,7 +71,7 @@ void databasePortLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void databaseNameLoadTest() { // when & then @@ -89,7 +88,7 @@ void databaseNameLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void databaseUsernameLoadTest() { // when & then @@ -107,7 +106,7 @@ void databaseUsernameLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void databasePasswordLoadTest() { Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getDatabasePasswordKeyId())); String value = secretKeyManagerService.getSecretValue(secretKeyProperties.getDatabasePasswordKeyId()); @@ -122,10 +121,12 @@ void databasePasswordLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void jwtSecretKeyLoadTest() { Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getJwtSecretKeyId())); String value = secretKeyManagerService.getSecretValue(secretKeyProperties.getJwtSecretKeyId()); + log.info(value); + log.info(value.toString()); Assertions.assertNotNull(value); } @@ -136,13 +137,16 @@ void jwtSecretKeyLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void redisIpAddressLoadTest() { Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisIpAddressKeyId())); String value = secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisIpAddressKeyId()); Assertions.assertNotNull(value); + + log.info(value); + log.info("redisIpAddress => {}", value); } @@ -152,7 +156,7 @@ void redisIpAddressLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void redisPortLoadTest() { Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPortKeyId())); @@ -168,7 +172,7 @@ void redisPortLoadTest() { * @author woody35545(구건모) */ @Test - @Disabled +// @Disabled void redisPasswordLoadTest() { Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPasswordKeyId())); diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 0000000..0885b83 --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,62 @@ +spring: + datasource: + driver-class-name: org.h2.Driver + url: jdbc:h2:mem:testdb + username: sa + password: + jpa: + hibernate: + ddl-auto: create-drop + properties: + hibernate: + dialect: org.hibernate.dialect.H2Dialect + format_sql: true + show_sql: true + redis: + host: ${redisHost} + password: ${redisPassword} + port: ${redisPort} + database: ${redisDatabase} + application: + name: eureka-client + profiles: + active: test + +eureka: + instance: + prefer-ip-address: true + client: + register-with-eureka: true + fetch-registry: true + service-url: + defaultZone : http://127.0.0.1:8761/eureka + + +t3t: + secretKeyManager: + certKeyPath: ${secretKeyManagerCertKeyPath} + certKeyType: ${secretKeyManagerCertKeyType} + appKey: ${secretKeyManagerAppKey} + password: ${secretKeyManagerPassword} + + secrets: + databaseName: + keyId: "e3203972cbf04433b90c752f695d5736" + databaseServerIpAddress: + keyId: "62911d2c30064812b2b2c97a8dd90782" + databaseServerPort: + keyId: "48e191996aa748938a1edb62652336f4" + databaseServerUsername: + keyId: "f008c1d3f87f4f88ae57bd03871eb10d" + databaseServerPassword: + keyId: "8a65684780224384a681c3e9035ca7d6" + jwtSecretKey: + keyId: "e4f4d4a87ccd49e594f03dffee9fa58d" + redisServerIpAddress: + keyId: "10ee8b6140cc49ffa9e7a7c8a2924a3e" + redisServerPort: + keyId: "0582f8b117604b7d86e9f3ff26931cde" + redisServerPassword: + keyId: "ec1eb8e0706e402cbec8487cbcb86564" + token: + key: ${jwtSecretKey} From d8fd973d599ebdc581f3e6de362bf1e7ad45fac0 Mon Sep 17 00:00:00 2001 From: joohyun Date: Tue, 30 Apr 2024 13:40:46 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:#16=20pull=20request=EC=8B=9C=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 616039b..80de7b2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -3,8 +3,6 @@ name: CI / CD on: push: branches: [ "master", "develop" ] - pull_request: - branches: [ "master", "develop" ] jobs: ci-cd: From 36074854488de89f6cc2f87ba2e98a070f1d5da8 Mon Sep 17 00:00:00 2001 From: joohyun Date: Tue, 30 Apr 2024 13:41:32 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:#16=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EB=AA=85=EB=A0=B9=EC=96=B4=20=EC=98=A4?= =?UTF-8?q?=ED=83=88=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 80de7b2..96b4ecf 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Prepare secure key manager certKey file - run: + run: | echo ${{ secrets.SECURE_KEY_MANAGER_CERT_KEY }} > t3team-skm-cert.txt mkdir src/main/resources/key base64 -d t3team-skm-cert.txt > src/main/resources/key/t3team-skm-cert.p12