From 3315d1d24f3ec208cab23486d3c071134a8a753f Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Fri, 27 Dec 2024 16:47:56 +0900 Subject: [PATCH 01/14] =?UTF-8?q?[CHORE]=20Test=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=84=A0=EC=96=B8=20builder=20=EC=83=9D=EC=84=B1=EC=9E=90=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/sopt/makers/operation/banner/BannerTest.java | 12 ++++++------ .../makers/operation/banner/PublishPeriodTest.java | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/operation-domain/src/test/java/org/sopt/makers/operation/banner/BannerTest.java b/operation-domain/src/test/java/org/sopt/makers/operation/banner/BannerTest.java index f8cdb1c7..1c111fcf 100644 --- a/operation-domain/src/test/java/org/sopt/makers/operation/banner/BannerTest.java +++ b/operation-domain/src/test/java/org/sopt/makers/operation/banner/BannerTest.java @@ -48,12 +48,12 @@ public class BannerTest { private static final String TEST_BANNER_PC_IMAGE_URL = "image-url-for-pc"; private static final String TEST_BANNER_MOBILE_IMAGE_URL = "image-url-for-mobile"; - private static final PublishPeriod TEST_PUBLISH_PERIOD = new PublishPeriod( - TEST_BANNER_START_DATE, TEST_BANNER_END_DATE - ); - private static final BannerImage TEST_BANNER_IMAGE = new BannerImage( - TEST_BANNER_PC_IMAGE_URL, TEST_BANNER_MOBILE_IMAGE_URL - ); + private static final PublishPeriod TEST_PUBLISH_PERIOD = PublishPeriod.builder() + .startDate(TEST_BANNER_START_DATE) + .endDate(TEST_BANNER_END_DATE).build(); + private static final BannerImage TEST_BANNER_IMAGE = BannerImage.builder() + .pcImageUrl(TEST_BANNER_PC_IMAGE_URL) + .mobileImageUrl(TEST_BANNER_MOBILE_IMAGE_URL).build(); private static final Banner TEST_BANNER = Banner.builder() .location(TEST_BANNER_LOCATION) diff --git a/operation-domain/src/test/java/org/sopt/makers/operation/banner/PublishPeriodTest.java b/operation-domain/src/test/java/org/sopt/makers/operation/banner/PublishPeriodTest.java index f0d6a3da..07c7db80 100644 --- a/operation-domain/src/test/java/org/sopt/makers/operation/banner/PublishPeriodTest.java +++ b/operation-domain/src/test/java/org/sopt/makers/operation/banner/PublishPeriodTest.java @@ -17,7 +17,9 @@ public class PublishPeriodTest { private static final LocalDate TEST_START_DATE = LocalDate.of(2024,1,1); private static final LocalDate TEST_END_DATE = LocalDate.of(2024,12,31); - private final PublishPeriod givenPeriod = new PublishPeriod(TEST_START_DATE, TEST_END_DATE); + private final PublishPeriod givenPeriod = PublishPeriod.builder() + .startDate(TEST_START_DATE) + .endDate(TEST_END_DATE).build(); @ParameterizedTest(name = "({index}) date : {0} -> result : {1}") @MethodSource("argsForCalculateStatus") From f7df9f1b0c3d261f16cc0b5cd77c3462c75f2603 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Fri, 27 Dec 2024 16:50:18 +0900 Subject: [PATCH 02/14] =?UTF-8?q?[FIX]=20api=20=EB=AA=A8=EB=93=88=20build.?= =?UTF-8?q?gradle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - profile 파라미터에 따른 동적 yaml 설정 - `application-*.yml`을 메인 yaml 설정 & build 환경으로 복사 --- operation-api/build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/operation-api/build.gradle b/operation-api/build.gradle index 9a8c28a3..47a515af 100644 --- a/operation-api/build.gradle +++ b/operation-api/build.gradle @@ -19,6 +19,19 @@ tasks.named("bootJar") { }) } +def profile = project.findProperty("profile") ?: "test" +println("Build Profile: $profile") + +tasks.register("processProfileYaml", Copy) { + from("src/main/resources/application-${profile}.yaml") + into("build/resources/main") // 빌드 시 사용할 리소스 경로 + rename { "application.yaml" } // 모든 프로파일 파일을 application.yaml로 변경 +} + +// processResources 작업 후에 실행되도록 의존성 추가 +tasks.named("processResources") { + dependsOn("processProfileYaml") +} dependencies { // module implementation project(path: ':operation-auth') From 2ae8d9b3f9bac3891f661efb8faf97c8d57b8d8a Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Fri, 27 Dec 2024 16:51:56 +0900 Subject: [PATCH 03/14] =?UTF-8?q?[REFACTOR]=20dockerfile=20build=20command?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 동적 Profile `ARG` 적용 (기본 값 = test) - `-x test` 제거 (CI를 통한 안정성 검증 목적) --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b6b4226c..3300b65e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM openjdk:17-jdk-slim as builder +ARG PROFILE=test + # mkdir /app-build && cd /app-build WORKDIR /app-build @@ -7,7 +9,7 @@ WORKDIR /app-build COPY . /app-build # create .jar -RUN ./gradlew build -x test +RUN echo "Build with PROFILE=${PROFILE}" && ./gradlew build -Pprofile=${PROFILE} --no-daemon # Run-Time Image Setting FROM openjdk:17-jdk-slim as production From d1269173ec2b2b1093027774dda5383aa1e78716 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Fri, 27 Dec 2024 16:52:28 +0900 Subject: [PATCH 04/14] =?UTF-8?q?[CHORE]=20Docker=20=EA=B8=B0=EB=B0=98=20C?= =?UTF-8?q?I=20Script=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 321cbbac..b8553f67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,28 +23,6 @@ jobs: run: chmod +x ./gradlew shell: bash - - name: Create application.yml - run: | - pwd - cd ./operation-api/src/main/resources - touch ./application-dev.yml - echo "${{ secrets.APPLICATION_DEV }}" >> ./application-dev.yml - cat ./application-dev.yml - - - name: Create application-test.yml - run: | - cd ./operation-domain/src/test - mkdir -p resources - touch ./resources/application-test.yml - echo "${{ secrets.APPLICATION_DOMAIN_TEST }}" >> ./application-test.yml - cat ./application-test.yml - - - name: 'Get key from Github Secrets' - run: | - pwd - mkdir -p ./operation-api/src/main/resources/static - echo "${{ secrets.APPLE_KEY }}" | base64 --decode > ./operation-api/src/main/resources/static/${{ secrets.APPLE_KEY_NAME }} - - - name: Build with Gradle - run: ./gradlew build + - name: 🧱 Build with Gradle + run: docker build -t app-ci . shell: bash \ No newline at end of file From f082b04f29e385410d08ee4f55dae42b24ed8271 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Fri, 27 Dec 2024 17:48:35 +0900 Subject: [PATCH 05/14] =?UTF-8?q?[REFACTOR]=20SSH=20=EC=A0=91=EC=86=8D=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B0=B0=ED=8F=AC=20=EB=B0=A9=EC=8B=9D=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-dev.yml | 91 +++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 37 deletions(-) diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml index 9b0e9fa9..0fd5988c 100644 --- a/.github/workflows/cd-dev.yml +++ b/.github/workflows/cd-dev.yml @@ -6,14 +6,14 @@ on: branches: [ develop ] jobs: - build-and-push-and-deploy: + build-and-push: runs-on: ubuntu-22.04 steps: - - name: Checkout + - name: ✅ Checkout uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: ⚙️ Set up JDK 17 uses: actions/setup-java@v3 with: java-version: 17 @@ -27,16 +27,6 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} aws-region: ${{ secrets.AWS_REGION }} - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash - - - name: Create Property - run: | - - mkdir -p ./operation-api/src/main/resources/static - echo "${{ secrets.APPLE_KEY }}" | base64 --decode > ./operation-api/src/main/resources/static/${{ secrets.APPLE_KEY_NAME }} - - name: 🧱 Build Image and Push to ECR env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} @@ -47,36 +37,63 @@ jobs: docker tag $AWS_ECR_REPO:latest public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest docker push public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest - - name: 📝 Copy Script File + deploy: + needs: build-and-push + runs-on: ubuntu-latest + + steps: + - name: ✅ Checkout + uses: actions/checkout@v3 + + - name: 🔒 Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: 📝 Copy Files from S3 env: REGION: ${{ secrets.AWS_REGION }} + APPLE_KEY_NAME: ${{ secrets.APPLE_KEY_NAME }} S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} run: | - mkdir ./script aws s3 cp --region $REGION \ - s3://$S3_BUCKET/dev/script/deploy.sh ./script/deploy.sh + s3://$S3_BUCKET/dev/script/deploy.sh ./deploy.sh aws s3 cp --region $REGION \ - s3://$S3_BUCKET/dev/script/switch.sh ./script/switch.sh + s3://$S3_BUCKET/dev/script/switch.sh ./switch.sh aws s3 cp --region $REGION \ - s3://$S3_BUCKET/dev/script/valid.sh ./script/valid.sh - - aws s3 cp --region $REGION \ - s3://$S3_BUCKET/dev/dev.env application.env + s3://$S3_BUCKET/dev/script/valid.sh ./valid.sh - - name: Make zip file - run: zip -r ./$GITHUB_SHA.zip ./script ./appspec.yml ./application.env - shell: bash + aws s3 cp --region $REGION \ + s3://$S3_BUCKET/dev/dev.env ./application.env + aws s3 cp --region $REGION \ + s3://$S3_BUCKET/dev/static/$APPLE_KEY ./$APPLE_KEY_NAME - - name: Upload Property Zip to S3 and Create Code Deploy - env: - REGION: ${{ secrets.AWS_REGION }} - DEPLOY_APPLICATION: ${{ secrets.AWS_DEPLOY_APPLICATION }} - DEPLOY_GROUP: ${{ secrets.AWS_DEPLOY_GROUP_DEV }} - S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} - run: | - aws s3 cp --region $REGION ./$GITHUB_SHA.zip s3://$S3_BUCKET/dev/deploy/$GITHUB_SHA.zip - - aws deploy create-deployment --application-name $DEPLOY_APPLICATION \ - --deployment-config-name CodeDeployDefault.AllAtOnce \ - --deployment-group-name $DEPLOY_GROUP \ - --s3-location bucket=$S3_BUCKET,bundleType=zip,key=dev/deploy/$GITHUB_SHA.zip \ No newline at end of file + - name: 🚀SSH command deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST_DEV }} + username: ubuntu + key: ${{ secrets.PEM_KEY_DEV }} + port: 22 + script: | + mkdir -p /home/ubuntu/script/op + mkdir -p /home/ubuntu/property/op + mkdir -p /home/ubuntu/env/op + + echo $(cat deploy.sh) > /home/ubuntu/script/op/deploy.sh + echo $(cat switch.sh) > /home/ubuntu/script/op/switch.sh + echo $(cat valid.sh) > /home/ubuntu/script/op/valid.sh + echo $(cat application.env) > /home/ubuntu/env/op/application.env + echo $(cat ${{ secrets.APPLE_KEY_NAME }}) > /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} + + sudo chmod +x /home/ubuntu/script/op/deploy.sh + sudo chmod +x /home/ubuntu/script/op/switch.sh + sudo chmod +x /home/ubuntu/script/op/valid.sh + sudo chmod +r /home/ubuntu/env/op/application.env + sudo chmod +r /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY }} + + ./home/ubuntu/script/op/deploy.sh + ./home/ubuntu/script/op/switch.sh + ./home/ubuntu/script/op/valid.sh \ No newline at end of file From ac5bcfd597c485e2719583ea3e2a355b8c11deb6 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Sun, 29 Dec 2024 16:52:10 +0900 Subject: [PATCH 06/14] =?UTF-8?q?[HOTFIX]=20=EC=9B=90=EA=B2=A9=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=EC=97=90=20Runner=20=EC=83=9D=EC=84=B1=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=A0=84=EC=86=A1=20Step=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-dev.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml index 0fd5988c..2aa9e9c4 100644 --- a/.github/workflows/cd-dev.yml +++ b/.github/workflows/cd-dev.yml @@ -70,6 +70,21 @@ jobs: aws s3 cp --region $REGION \ s3://$S3_BUCKET/dev/static/$APPLE_KEY ./$APPLE_KEY_NAME + - name: 🔄 Transfer Files to Server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST_DEV }} + username: ubuntu + key: ${{ secrets.PEM_KEY_DEV }} + port: 22 + source: | + deploy.sh + switch.sh + valid.sh + application.env + ${{ secrets.APPLE_KEY_NAME }} + target: /home/ubuntu/deploy-temp/op + - name: 🚀SSH command deploy uses: appleboy/ssh-action@master with: @@ -82,11 +97,11 @@ jobs: mkdir -p /home/ubuntu/property/op mkdir -p /home/ubuntu/env/op - echo $(cat deploy.sh) > /home/ubuntu/script/op/deploy.sh - echo $(cat switch.sh) > /home/ubuntu/script/op/switch.sh - echo $(cat valid.sh) > /home/ubuntu/script/op/valid.sh - echo $(cat application.env) > /home/ubuntu/env/op/application.env - echo $(cat ${{ secrets.APPLE_KEY_NAME }}) > /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} + mv /home/ubuntu/deploy-temp/op/deploy.sh /home/ubuntu/script/op/deploy.sh + mv /home/ubuntu/deploy-temp/op/switch.sh /home/ubuntu/script/op/switch.sh + mv /home/ubuntu/deploy-temp/op/valid.sh /home/ubuntu/script/op/valid.sh + mv /home/ubuntu/deploy-temp/op/application.env /home/ubuntu/env/op/application.env + mv /home/ubuntu/deploy-temp/op/${{ secrets.APPLE_KEY_NAME }} /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} sudo chmod +x /home/ubuntu/script/op/deploy.sh sudo chmod +x /home/ubuntu/script/op/switch.sh @@ -94,6 +109,6 @@ jobs: sudo chmod +r /home/ubuntu/env/op/application.env sudo chmod +r /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY }} - ./home/ubuntu/script/op/deploy.sh - ./home/ubuntu/script/op/switch.sh - ./home/ubuntu/script/op/valid.sh \ No newline at end of file + /home/ubuntu/script/op/deploy.sh + /home/ubuntu/script/op/switch.sh + /home/ubuntu/script/op/valid.sh \ No newline at end of file From 61a022a4573aedb06b3c8464a084b2203ca35946 Mon Sep 17 00:00:00 2001 From: yummygyudon Date: Sun, 29 Dec 2024 17:00:38 +0900 Subject: [PATCH 07/14] =?UTF-8?q?[HOTFIX]=20scp=20action=20source=20?= =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A3=BC=EC=9E=85=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-dev.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml index 2aa9e9c4..595adf37 100644 --- a/.github/workflows/cd-dev.yml +++ b/.github/workflows/cd-dev.yml @@ -77,12 +77,7 @@ jobs: username: ubuntu key: ${{ secrets.PEM_KEY_DEV }} port: 22 - source: | - deploy.sh - switch.sh - valid.sh - application.env - ${{ secrets.APPLE_KEY_NAME }} + source: "deploy.sh,switch.sh,valid.sh,application.env,${{ secrets.APPLE_KEY_NAME }}" target: /home/ubuntu/deploy-temp/op - name: 🚀SSH command deploy From f4f03206fd495d76f18f983bfc0c0dfb0435dc57 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Fri, 3 Jan 2025 14:54:38 +0900 Subject: [PATCH 08/14] =?UTF-8?q?[TEST]=20Banner=20API=20=EB=B0=B0?= =?UTF-8?q?=EB=84=88=20=EC=83=9D=EC=84=B1=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../banner/api/BannerApiControllerTest.java | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java index c58d10a7..b90987b7 100644 --- a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java +++ b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java @@ -1,5 +1,6 @@ package org.sopt.makers.operation.web.banner.api; +import com.fasterxml.jackson.databind.*; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -8,10 +9,11 @@ import org.sopt.makers.operation.filter.JwtAuthenticationFilter; import org.sopt.makers.operation.filter.JwtExceptionFilter; import org.sopt.makers.operation.jwt.JwtTokenProvider; +import org.sopt.makers.operation.web.banner.dto.request.BannerRequest.*; import org.sopt.makers.operation.web.banner.dto.response.BannerResponse; +import org.sopt.makers.operation.web.banner.dto.response.BannerResponse.*; import org.sopt.makers.operation.web.banner.service.BannerService; -import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.ComponentScan; @@ -29,6 +31,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -45,6 +48,8 @@ class BannerApiControllerTest { private BannerService bannerService; @Autowired private MockMvc mockMvc; + @Autowired + ObjectMapper objectMapper; @BeforeEach void setMockBanner() { @@ -121,4 +126,35 @@ void getExternalBanners() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.success").value("true")); } + + @Test + @DisplayName("(POST) New Banner") + void createNewBanner() throws Exception { + // given + BannerCreate bannerCreate = new BannerCreate("pg_community", "product", "publisher", + LocalDate.of(2024, 1, 1), LocalDate.of(2024, 12, 31), "link", "image-url-pc", "image-url-mobile" + ); + String request = objectMapper.writeValueAsString(bannerCreate); + BannerDetail givenBannerDetail = bannerService.getBannerDetail(MOCK_BANNER_ID); + when(bannerService.createBanner(bannerCreate)) + .thenReturn(givenBannerDetail); + + // when & then + this.mockMvc.perform(post("/api/v1/banners") + .contentType(APPLICATION_JSON) + .content(request)) + .andExpect(status().isCreated()) + .andExpect(jsonPath("$.success").value("true")) + .andExpect(jsonPath("$.message").value(BannerSuccessCode.SUCCESS_CREATE_BANNER.getMessage())) + .andExpect(jsonPath("$.data.id").value(givenBannerDetail.bannerId())) + .andExpect(jsonPath("$.data.status").value(givenBannerDetail.bannerStatus())) + .andExpect(jsonPath("$.data.location").value(givenBannerDetail.bannerLocation())) + .andExpect(jsonPath("$.data.content_type").value(givenBannerDetail.bannerType())) + .andExpect(jsonPath("$.data.publisher").value(givenBannerDetail.publisher())) + .andExpect(jsonPath("$.data.link").value(givenBannerDetail.link())) + .andExpect(jsonPath("$.data.start_date").value(givenBannerDetail.startDate().toString())) + .andExpect(jsonPath("$.data.end_date").value(givenBannerDetail.endDate().toString())) + .andExpect(jsonPath("$.data.image_url_pc").value(givenBannerDetail.pcImageUrl())) + .andExpect(jsonPath("$.data.image_url_mobile").value(givenBannerDetail.mobileImageUrl())); + } } From 2d91cea799924e18a7b1e4291b115a2e6a4ea46c Mon Sep 17 00:00:00 2001 From: sung-silver Date: Fri, 3 Jan 2025 14:58:34 +0900 Subject: [PATCH 09/14] =?UTF-8?q?[TEST]=20test=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=BB=A8=EB=B2=A4=EC=85=98=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/web/banner/api/BannerApiControllerTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java index b90987b7..fdaf97b3 100644 --- a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java +++ b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java @@ -139,10 +139,12 @@ void createNewBanner() throws Exception { when(bannerService.createBanner(bannerCreate)) .thenReturn(givenBannerDetail); - // when & then - this.mockMvc.perform(post("/api/v1/banners") + this.mockMvc.perform( + // when + post("/api/v1/banners") .contentType(APPLICATION_JSON) .content(request)) + // then .andExpect(status().isCreated()) .andExpect(jsonPath("$.success").value("true")) .andExpect(jsonPath("$.message").value(BannerSuccessCode.SUCCESS_CREATE_BANNER.getMessage())) From b604002313eb98e0f71581bdf9668fd7e2fa5ee9 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Fri, 3 Jan 2025 17:35:19 +0900 Subject: [PATCH 10/14] =?UTF-8?q?[CHORE]=20=EC=82=AC=EC=9A=A9=EB=90=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/makers/operation/web/banner/service/BannerService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/web/banner/service/BannerService.java b/operation-api/src/main/java/org/sopt/makers/operation/web/banner/service/BannerService.java index 7c14ae53..a30548ed 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/web/banner/service/BannerService.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/web/banner/service/BannerService.java @@ -4,7 +4,6 @@ import org.sopt.makers.operation.web.banner.dto.request.*; import org.sopt.makers.operation.web.banner.dto.response.BannerResponse; -import org.sopt.makers.operation.web.banner.dto.response.BannerResponse.BannerDetail; import org.sopt.makers.operation.web.banner.dto.response.BannerResponse.BannerImageUrl; public interface BannerService { From e4a6f09cffdd3cefc2a99b53273446b406c8d22e Mon Sep 17 00:00:00 2001 From: sung-silver Date: Mon, 6 Jan 2025 14:50:56 +0900 Subject: [PATCH 11/14] =?UTF-8?q?[TEST]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../banner/api/BannerApiControllerTest.java | 73 ++++++++++--------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java index fdaf97b3..b73d8fd7 100644 --- a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java +++ b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java @@ -1,9 +1,7 @@ package org.sopt.makers.operation.web.banner.api; import com.fasterxml.jackson.databind.*; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.*; import org.sopt.makers.operation.code.success.web.BannerSuccessCode; import org.sopt.makers.operation.filter.JwtAuthenticationFilter; @@ -11,7 +9,6 @@ import org.sopt.makers.operation.jwt.JwtTokenProvider; import org.sopt.makers.operation.web.banner.dto.request.BannerRequest.*; import org.sopt.makers.operation.web.banner.dto.response.BannerResponse; -import org.sopt.makers.operation.web.banner.dto.response.BannerResponse.*; import org.sopt.makers.operation.web.banner.service.BannerService; import org.springframework.test.web.servlet.MockMvc; @@ -25,6 +22,8 @@ import java.security.Principal; import java.time.LocalDate; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -94,6 +93,7 @@ void getBannerDetail() throws Exception { @DisplayName("(DELETE) Banner Delete") void deleteBanner() throws Exception { //given + bannerService.deleteBanner(MOCK_BANNER_ID); BannerResponse.BannerDetail mockBannerDetail = bannerService.getBannerDetail(MOCK_BANNER_ID); this.mockMvc.perform( @@ -105,7 +105,6 @@ void deleteBanner() throws Exception { //then .andExpect(status().isNoContent()) .andExpect(jsonPath("$.success").value("true")); - } @Test @@ -127,36 +126,38 @@ void getExternalBanners() throws Exception { .andExpect(jsonPath("$.success").value("true")); } - @Test - @DisplayName("(POST) New Banner") - void createNewBanner() throws Exception { - // given - BannerCreate bannerCreate = new BannerCreate("pg_community", "product", "publisher", - LocalDate.of(2024, 1, 1), LocalDate.of(2024, 12, 31), "link", "image-url-pc", "image-url-mobile" - ); - String request = objectMapper.writeValueAsString(bannerCreate); - BannerDetail givenBannerDetail = bannerService.getBannerDetail(MOCK_BANNER_ID); - when(bannerService.createBanner(bannerCreate)) - .thenReturn(givenBannerDetail); - - this.mockMvc.perform( - // when - post("/api/v1/banners") - .contentType(APPLICATION_JSON) - .content(request)) - // then - .andExpect(status().isCreated()) - .andExpect(jsonPath("$.success").value("true")) - .andExpect(jsonPath("$.message").value(BannerSuccessCode.SUCCESS_CREATE_BANNER.getMessage())) - .andExpect(jsonPath("$.data.id").value(givenBannerDetail.bannerId())) - .andExpect(jsonPath("$.data.status").value(givenBannerDetail.bannerStatus())) - .andExpect(jsonPath("$.data.location").value(givenBannerDetail.bannerLocation())) - .andExpect(jsonPath("$.data.content_type").value(givenBannerDetail.bannerType())) - .andExpect(jsonPath("$.data.publisher").value(givenBannerDetail.publisher())) - .andExpect(jsonPath("$.data.link").value(givenBannerDetail.link())) - .andExpect(jsonPath("$.data.start_date").value(givenBannerDetail.startDate().toString())) - .andExpect(jsonPath("$.data.end_date").value(givenBannerDetail.endDate().toString())) - .andExpect(jsonPath("$.data.image_url_pc").value(givenBannerDetail.pcImageUrl())) - .andExpect(jsonPath("$.data.image_url_mobile").value(givenBannerDetail.mobileImageUrl())); + @Nested + class CreateBannerTests { + @Test + @DisplayName("(POST) New Banner") + void createNewBanner() throws Exception { + // given + BannerCreate bannerCreate = new BannerCreate("pg_community", "product", "publisher", + LocalDate.of(2024, 1, 1), LocalDate.of(2024, 12, 31), "link", "image-url-pc", "image-url-mobile"); + BannerResponse.BannerDetail mockBannerDetail = new BannerResponse.BannerDetail( + MOCK_BANNER_ID, "in_progress", "pg_community", "product", "publisher", "link", + LocalDate.of(2024, 1, 1), LocalDate.of(2024, 12, 31), "image-url-pc", "image-url-mobile"); + String request = objectMapper.writeValueAsString(bannerCreate); + when(bannerService.createBanner(any(BannerCreate.class))).thenReturn(mockBannerDetail); + + // when + mockMvc.perform(post("/api/v1/banners") + .contentType(APPLICATION_JSON) + .content(request)) + // then + .andExpect(status().isCreated()) + .andExpect(jsonPath("$.success").value(true)) + .andExpect(jsonPath("$.message").value(BannerSuccessCode.SUCCESS_CREATE_BANNER.getMessage())) + .andExpect(jsonPath("$.data.id").value(mockBannerDetail.bannerId())) + .andExpect(jsonPath("$.data.status").value(mockBannerDetail.bannerStatus())) + .andExpect(jsonPath("$.data.location").value(mockBannerDetail.bannerLocation())) + .andExpect(jsonPath("$.data.content_type").value(mockBannerDetail.bannerType())) + .andExpect(jsonPath("$.data.publisher").value(mockBannerDetail.publisher())) + .andExpect(jsonPath("$.data.link").value(mockBannerDetail.link())) + .andExpect(jsonPath("$.data.start_date").value(mockBannerDetail.startDate().toString())) + .andExpect(jsonPath("$.data.end_date").value(mockBannerDetail.endDate().toString())) + .andExpect(jsonPath("$.data.image_url_pc").value(mockBannerDetail.pcImageUrl())) + .andExpect(jsonPath("$.data.image_url_mobile").value(mockBannerDetail.mobileImageUrl())); + } } } From 00dfdded7ca30827918131d9d12ea94569caefab Mon Sep 17 00:00:00 2001 From: sung-silver Date: Mon, 6 Jan 2025 15:45:58 +0900 Subject: [PATCH 12/14] =?UTF-8?q?[TEST]=20=EB=B0=B0=EB=84=88=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=EC=97=90=20=EB=8C=80=ED=95=9C=20given=20=EC=A0=88=20?= =?UTF-8?q?=EC=A0=81=EC=A0=88=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/web/banner/api/BannerApiControllerTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java index b73d8fd7..1790714f 100644 --- a/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java +++ b/operation-api/src/test/java/org/sopt/makers/operation/web/banner/api/BannerApiControllerTest.java @@ -93,8 +93,7 @@ void getBannerDetail() throws Exception { @DisplayName("(DELETE) Banner Delete") void deleteBanner() throws Exception { //given - bannerService.deleteBanner(MOCK_BANNER_ID); - BannerResponse.BannerDetail mockBannerDetail = bannerService.getBannerDetail(MOCK_BANNER_ID); + doNothing().when(bannerService).deleteBanner(MOCK_BANNER_ID); this.mockMvc.perform( //when From 43c9892466f1fba7c1a4da8715fed73bfc6e3cac Mon Sep 17 00:00:00 2001 From: DongGyu Jung Date: Mon, 13 Jan 2025 03:45:31 +0900 Subject: [PATCH 13/14] =?UTF-8?q?[MODIFY]=20transfer=20=ED=95=9C=20file=20?= =?UTF-8?q?mv=20=EB=AA=85=EB=A0=B9=EC=97=90=20sudo=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-dev.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml index 595adf37..7ccad43f 100644 --- a/.github/workflows/cd-dev.yml +++ b/.github/workflows/cd-dev.yml @@ -92,11 +92,11 @@ jobs: mkdir -p /home/ubuntu/property/op mkdir -p /home/ubuntu/env/op - mv /home/ubuntu/deploy-temp/op/deploy.sh /home/ubuntu/script/op/deploy.sh - mv /home/ubuntu/deploy-temp/op/switch.sh /home/ubuntu/script/op/switch.sh - mv /home/ubuntu/deploy-temp/op/valid.sh /home/ubuntu/script/op/valid.sh - mv /home/ubuntu/deploy-temp/op/application.env /home/ubuntu/env/op/application.env - mv /home/ubuntu/deploy-temp/op/${{ secrets.APPLE_KEY_NAME }} /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} + sudo mv /home/ubuntu/deploy-temp/op/deploy.sh /home/ubuntu/script/op/deploy.sh + sudo mv /home/ubuntu/deploy-temp/op/switch.sh /home/ubuntu/script/op/switch.sh + sudo mv /home/ubuntu/deploy-temp/op/valid.sh /home/ubuntu/script/op/valid.sh + sudo mv /home/ubuntu/deploy-temp/op/application.env /home/ubuntu/env/op/application.env + sudo mv /home/ubuntu/deploy-temp/op/${{ secrets.APPLE_KEY_NAME }} /home/ubuntu/property/op/key/${{ secrets.APPLE_KEY_NAME }} sudo chmod +x /home/ubuntu/script/op/deploy.sh sudo chmod +x /home/ubuntu/script/op/switch.sh @@ -106,4 +106,4 @@ jobs: /home/ubuntu/script/op/deploy.sh /home/ubuntu/script/op/switch.sh - /home/ubuntu/script/op/valid.sh \ No newline at end of file + /home/ubuntu/script/op/valid.sh From 3f8582e7f3f972b6ef041f4750d9176290e9eed4 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Mon, 13 Jan 2025 22:10:02 +0900 Subject: [PATCH 14/14] =?UTF-8?q?[FEAT]=20PreSignedUrl=20=EB=B0=9C?= =?UTF-8?q?=EA=B8=89=20API=EC=9D=98=20=EC=BF=BC=EB=A6=AC=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20snake?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/web/banner/api/BannerApiController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/operation-api/src/main/java/org/sopt/makers/operation/web/banner/api/BannerApiController.java b/operation-api/src/main/java/org/sopt/makers/operation/web/banner/api/BannerApiController.java index 3e950e42..41a83cc9 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/web/banner/api/BannerApiController.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/web/banner/api/BannerApiController.java @@ -63,10 +63,10 @@ public ResponseEntity> getExternalBanners( @Override @GetMapping("/img/pre-signed") public ResponseEntity> getIssuedPreSignedUrlForPutImage( - @RequestParam("content-name") String contentName, - @RequestParam("image-type") String imageType, - @RequestParam("image-extension") String imageExtension, - @RequestParam("content-type") String contentType + @RequestParam("content_name") String contentName, + @RequestParam("image_type") String imageType, + @RequestParam("image_extension") String imageExtension, + @RequestParam("content_type") String contentType ) { val response = bannerService.getIssuedPreSignedUrlForPutImage(contentName, imageType, imageExtension, contentType);