diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml
index f5a3c2b..3defdfa 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:
@@ -13,6 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Prepare secure key manager certKey file
+
run: |
echo ${{ secrets.SECURE_KEY_MANAGER_CERT_KEY }} > t3team-skm-cert.txt
mkdir src/main/resources/key
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}