Skip to content

Commit a9817fb

Browse files
committed
feat: Api-Version 헤더를 cors 허용한다
1 parent 389f3c9 commit a9817fb

File tree

6 files changed

+9
-3
lines changed

6 files changed

+9
-3
lines changed

src/main/kotlin/org/gitanimals/render/controller/filter/CorsFilter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CorsFilter : Filter {
2626
this.addHeader(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "3600")
2727
this.addHeader(
2828
HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
29-
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
29+
"Origin, X-Requested-With, Content-Type, Accept, Authorization, Api-Version"
3030
)
3131
return this
3232
}

src/main/kotlin/org/gitanimals/star/infra/GithubStargazerApi.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package org.gitanimals.star.infra
22

33
import org.springframework.beans.factory.annotation.Value
4+
import org.springframework.context.annotation.Profile
45
import org.springframework.core.io.ClassPathResource
56
import org.springframework.http.HttpHeaders
67
import org.springframework.stereotype.Component
78
import org.springframework.web.client.RestClient
89
import java.nio.charset.Charset
910

1011
@Component
12+
@Profile("!test")
1113
class GithubStargazerApi(
1214
@Value("\${github.token}") private val token: String,
1315
) {
@@ -34,7 +36,7 @@ class GithubStargazerApi(
3436
)
3537
).exchange { _, response ->
3638
assertIsSuccess(response)
37-
39+
3840
response.bodyTo(GithubStargazerGraphqlResponse::class.java)!!
3941
.data
4042
.repository

src/main/kotlin/org/gitanimals/star/infra/StargazerBatchJob.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package org.gitanimals.star.infra
22

33
import org.gitanimals.star.domain.StargazerService
44
import org.springframework.boot.context.event.ApplicationStartedEvent
5+
import org.springframework.context.annotation.Profile
56
import org.springframework.context.event.EventListener
67
import org.springframework.scheduling.annotation.Scheduled
78
import org.springframework.stereotype.Service
89

910
@Service
11+
@Profile("!test")
1012
class StargazerBatchJob(
1113
private val githubStargazerApi: GithubStargazerApi,
1214
private val stargazerService: StargazerService,

src/test/kotlin/org/gitanimals/render/app/UserStatisticScheduleTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.gitanimals.Application
66
import org.gitanimals.render.supports.RedisContainer
77
import org.gitanimals.render.supports.SagaCapture
88
import org.springframework.boot.test.context.SpringBootTest
9+
import org.springframework.test.context.ActiveProfiles
910
import org.springframework.test.context.TestPropertySource
1011
import kotlin.time.Duration.Companion.seconds
1112

src/test/kotlin/org/gitanimals/render/controller/filter/CorsFilterTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ internal class CorsFilterTest(
4646
{
4747
it == Header(
4848
"Access-Control-Allow-Headers",
49-
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
49+
"Origin, X-Requested-With, Content-Type, Accept, Authorization, Api-Version"
5050
)
5151
}
5252
)

src/test/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
spring.profiles.active=test
12
spring.datasource.driver-class-name = org.h2.Driver
23
spring.datasource.url = jdbc:h2:mem:test;MODE=MySQL;DATABASE_TO_LOWER=TRUE
34

0 commit comments

Comments
 (0)