Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add property to configure the max allowed size for a request body #986

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.egm.stellio.search.config

import org.springframework.boot.context.properties.ConfigurationProperties

@ConfigurationProperties("search")
data class SearchProperties(
val payloadMaxBodySize: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.egm.stellio.search.config

import org.springframework.context.annotation.Configuration
import org.springframework.http.codec.ServerCodecConfigurer
import org.springframework.web.reactive.config.WebFluxConfigurer

@Configuration
class WebFluxConfig(private val searchProperties: SearchProperties) : WebFluxConfigurer {

override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
configurer.defaultCodecs().maxInMemorySize(searchProperties.payloadMaxBodySize)
}
}
3 changes: 3 additions & 0 deletions search-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ spring.flyway.user = ${spring.r2dbc.username}
spring.flyway.password = ${spring.r2dbc.password}

server.port = 8083

# Allow body size in payloads up to 2Mb
search.payload-max-body-size = 2048000
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.egm.stellio.search.web

import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.service.EntityEventService
import com.egm.stellio.search.service.EntityPayloadService
import com.egm.stellio.search.service.QueryService
Expand All @@ -20,7 +21,7 @@ import org.springframework.test.web.reactive.server.WebTestClient

@ActiveProfiles("test")
@WebFluxTest(EntityHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
@Suppress("unused")
class AnonymousUserHandlerTests {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.egm.stellio.search.web

import arrow.core.left
import arrow.core.right
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.AttributeDetails
import com.egm.stellio.search.model.AttributeList
import com.egm.stellio.search.model.AttributeType
Expand All @@ -11,9 +12,10 @@ import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.ResourceNotFoundException
import com.egm.stellio.shared.util.*
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_CORE_CONTEXT
import com.egm.stellio.shared.util.MOCK_USER_SUB
import com.ninjasquad.springmockk.MockkBean
import io.mockk.*
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.mockkClass
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -28,7 +30,7 @@ import org.springframework.test.web.reactive.server.WebTestClient

@ActiveProfiles("test")
@WebFluxTest(AttributeHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class AttributeHandlerTests {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.authorization.EntityAccessRights
import com.egm.stellio.search.authorization.EntityAccessRightsService
import com.egm.stellio.search.authorization.User
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.service.EntityPayloadService
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.*
Expand Down Expand Up @@ -53,7 +54,7 @@ import java.time.Duration
@OptIn(ExperimentalCoroutinesApi::class)
@ActiveProfiles("test")
@WebFluxTest(EntityAccessControlHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class EntityAccessControlHandlerTests {

private val authzHeaderLink = buildContextLinkHeader(AUTHORIZATION_CONTEXT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.egm.stellio.search.web
import arrow.core.left
import arrow.core.right
import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.*
import com.egm.stellio.search.service.EntityEventService
import com.egm.stellio.search.service.EntityPayloadService
Expand Down Expand Up @@ -49,7 +50,7 @@ import java.time.*

@ActiveProfiles("test")
@WebFluxTest(EntityHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class EntityHandlerTests {

private val aquacHeaderLink = buildContextLinkHeader(AQUAC_COMPOUND_CONTEXT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.egm.stellio.search.web
import arrow.core.left
import arrow.core.right
import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.EntityPayload
import com.egm.stellio.search.model.UpdateResult
import com.egm.stellio.search.service.EntityEventService
Expand Down Expand Up @@ -39,7 +40,7 @@ import java.net.URI
@AutoConfigureWebTestClient(timeout = "30000")
@ActiveProfiles("test")
@WebFluxTest(EntityOperationHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class EntityOperationHandlerTests {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ package com.egm.stellio.search.web

import arrow.core.left
import arrow.core.right
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.*
import com.egm.stellio.search.model.AttributeType
import com.egm.stellio.search.service.EntityTypeService
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.model.ResourceNotFoundException
import com.egm.stellio.shared.util.*
import com.egm.stellio.shared.util.JsonLdUtils.NGSILD_CORE_CONTEXT
import com.egm.stellio.shared.util.MOCK_USER_SUB
import com.ninjasquad.springmockk.MockkBean
import io.mockk.*
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.mockkClass
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -26,7 +28,7 @@ import org.springframework.test.web.reactive.server.WebTestClient

@ActiveProfiles("test")
@WebFluxTest(EntityTypeHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class EntityTypeHandlerTests {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import arrow.core.Some
import arrow.core.left
import arrow.core.right
import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.*
import com.egm.stellio.search.model.SimplifiedAttributeInstanceResult
import com.egm.stellio.search.model.TemporalEntityAttribute
Expand Down Expand Up @@ -50,7 +51,7 @@ import java.util.UUID
@OptIn(ExperimentalCoroutinesApi::class)
@ActiveProfiles("test")
@WebFluxTest(TemporalEntityHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class TemporalEntityHandlerTests {

private lateinit var apicHeaderLink: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package com.egm.stellio.search.web

import arrow.core.Either
import com.egm.stellio.search.authorization.AuthorizationService
import com.egm.stellio.search.config.SearchProperties
import com.egm.stellio.search.model.TemporalQuery
import com.egm.stellio.search.service.QueryService
import com.egm.stellio.shared.config.ApplicationProperties
import com.egm.stellio.shared.util.*
import com.egm.stellio.shared.util.MOCK_USER_SUB
import com.ninjasquad.springmockk.MockkBean
import io.mockk.*
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.confirmVerified
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
Expand All @@ -24,7 +26,7 @@ import java.time.ZonedDateTime

@ActiveProfiles("test")
@WebFluxTest(TemporalEntityOperationsHandler::class)
@EnableConfigurationProperties(ApplicationProperties::class)
@EnableConfigurationProperties(ApplicationProperties::class, SearchProperties::class)
class TemporalEntityOperationsHandlerTests {

private lateinit var apicHeaderLink: String
Expand Down