Skip to content

Commit

Permalink
Merge pull request #20 from nhnacademy-be5-T3Team/feature/cicd
Browse files Browse the repository at this point in the history
fix/#16 import 수정 및 CICD 수정
  • Loading branch information
joohyun1996 authored Apr 30, 2024
2 parents a6b2ccb + 8589208 commit b632093
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: CI / CD
on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master", "develop" ]

jobs:
ci-cd:
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/t3t/apigateway/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,13 +16,15 @@

@Configuration
@EnableRedisRepositories
@Slf4j
public class RedisConfig {
@Bean
public RedisProperties redisProperties(SecretKeyManagerService secretKeyManagerService,
SecretKeyProperties secretKeyProperties,
Environment environment){

String activeProfile = environment.getActiveProfiles()[0];
String activeProfileSuffix = activeProfile.equals("prod") ? "" : "_" + activeProfile;

return RedisProperties.builder()
.host(secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisIpAddressKeyId()))
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/t3t/apigateway/filter/JwtFilter.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
eureka:
client:
service-url:
defaultZone: ${eurekaServiceUrlDefaultZone}
defaultZone: ${eurekaServiceUrlDefaultZone}

spring:
auth:
host: ${authHost}
3 changes: 2 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ spring:
active: dev

auth:
host: ${authHost}
host: localhost

eureka:
instance:
prefer-ip-address: true
client:
register-with-eureka: true
fetch-registry: true

service-url:
defaultZone: http://127.0.0.1:8761/eureka

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -38,7 +37,7 @@ class SecretKeyManagerTest {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void databaseIpAddressLoadTest() {

// when & then
Expand All @@ -55,7 +54,7 @@ void databaseIpAddressLoadTest() {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void databasePortLoadTest() {

// when & then
Expand All @@ -72,7 +71,7 @@ void databasePortLoadTest() {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void databaseNameLoadTest() {

// when & then
Expand All @@ -89,7 +88,7 @@ void databaseNameLoadTest() {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void databaseUsernameLoadTest() {

// when & then
Expand All @@ -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());
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand All @@ -152,7 +156,7 @@ void redisIpAddressLoadTest() {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void redisPortLoadTest() {
Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPortKeyId()));

Expand All @@ -168,7 +172,7 @@ void redisPortLoadTest() {
* @author woody35545(구건모)
*/
@Test
@Disabled
// @Disabled
void redisPasswordLoadTest() {
Assertions.assertDoesNotThrow(() -> secretKeyManagerService.getSecretValue(secretKeyProperties.getRedisPasswordKeyId()));

Expand Down
62 changes: 62 additions & 0 deletions src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit b632093

Please sign in to comment.