From a9817fbcd2499a533ea8c785d719babbf3c05d51 Mon Sep 17 00:00:00 2001 From: devxb Date: Wed, 18 Sep 2024 15:59:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Api-Version=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=EB=A5=BC=20cors=20=ED=97=88=EC=9A=A9=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gitanimals/render/controller/filter/CorsFilter.kt | 2 +- .../kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt | 4 +++- .../kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt | 2 ++ .../org/gitanimals/render/app/UserStatisticScheduleTest.kt | 1 + .../org/gitanimals/render/controller/filter/CorsFilterTest.kt | 2 +- src/test/resources/application.properties | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/gitanimals/render/controller/filter/CorsFilter.kt b/src/main/kotlin/org/gitanimals/render/controller/filter/CorsFilter.kt index ee08188..f13c88d 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/filter/CorsFilter.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/filter/CorsFilter.kt @@ -26,7 +26,7 @@ class CorsFilter : Filter { this.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "3600") this.addHeader( HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, - "Origin, X-Requested-With, Content-Type, Accept, Authorization" + "Origin, X-Requested-With, Content-Type, Accept, Authorization, Api-Version" ) return this } diff --git a/src/main/kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt b/src/main/kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt index 4786397..ae4ae43 100644 --- a/src/main/kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt +++ b/src/main/kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt @@ -1,6 +1,7 @@ package org.gitanimals.star.infra import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Profile import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders import org.springframework.stereotype.Component @@ -8,6 +9,7 @@ import org.springframework.web.client.RestClient import java.nio.charset.Charset @Component +@Profile("!test") class GithubStargazerApi( @Value("\${github.token}") private val token: String, ) { @@ -34,7 +36,7 @@ class GithubStargazerApi( ) ).exchange { _, response -> assertIsSuccess(response) - + response.bodyTo(GithubStargazerGraphqlResponse::class.java)!! .data .repository diff --git a/src/main/kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt b/src/main/kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt index b24ae1b..bb8ddbf 100644 --- a/src/main/kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt +++ b/src/main/kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt @@ -2,11 +2,13 @@ package org.gitanimals.star.infra import org.gitanimals.star.domain.StargazerService import org.springframework.boot.context.event.ApplicationStartedEvent +import org.springframework.context.annotation.Profile import org.springframework.context.event.EventListener import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service @Service +@Profile("!test") class StargazerBatchJob( private val githubStargazerApi: GithubStargazerApi, private val stargazerService: StargazerService, diff --git a/src/test/kotlin/org/gitanimals/render/app/UserStatisticScheduleTest.kt b/src/test/kotlin/org/gitanimals/render/app/UserStatisticScheduleTest.kt index dcff858..086d351 100644 --- a/src/test/kotlin/org/gitanimals/render/app/UserStatisticScheduleTest.kt +++ b/src/test/kotlin/org/gitanimals/render/app/UserStatisticScheduleTest.kt @@ -6,6 +6,7 @@ import org.gitanimals.Application import org.gitanimals.render.supports.RedisContainer import org.gitanimals.render.supports.SagaCapture import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.TestPropertySource import kotlin.time.Duration.Companion.seconds diff --git a/src/test/kotlin/org/gitanimals/render/controller/filter/CorsFilterTest.kt b/src/test/kotlin/org/gitanimals/render/controller/filter/CorsFilterTest.kt index e3ca0f5..8944ebe 100644 --- a/src/test/kotlin/org/gitanimals/render/controller/filter/CorsFilterTest.kt +++ b/src/test/kotlin/org/gitanimals/render/controller/filter/CorsFilterTest.kt @@ -46,7 +46,7 @@ internal class CorsFilterTest( { it == Header( "Access-Control-Allow-Headers", - "Origin, X-Requested-With, Content-Type, Accept, Authorization" + "Origin, X-Requested-With, Content-Type, Accept, Authorization, Api-Version" ) } ) diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index 5c27886..9adc0fe 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -1,3 +1,4 @@ +spring.profiles.active=test spring.datasource.driver-class-name = org.h2.Driver spring.datasource.url = jdbc:h2:mem:test;MODE=MySQL;DATABASE_TO_LOWER=TRUE