Skip to content

Commit

Permalink
Don't use Java properties to pass configuration in kinesis integratio…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
pondzix committed Aug 25, 2023
1 parent 85723b9 commit fbd293c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
30 changes: 30 additions & 0 deletions kinesis/src/it/resources/collector-cookie-attributes-1.hocon
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
collector {
interface = "0.0.0.0"
port = ${PORT}

streams {
good = ${STREAM_GOOD}
bad = ${STREAM_BAD}

sink {
region = ${REGION}
customEndpoint = ${KINESIS_ENDPOINT}

aws {
accessKey = env
secretKey = env
}

maxBytes = ${MAX_BYTES}
}
}

"cookie": {
"enabled": true,
"name": "greatName",
"expiration": "42 days",
"secure": true,
"httpOnly": true,
"sameSite": "Strict"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,17 @@ class CookieSpec extends Specification with Localstack with CatsEffect {
override protected val Timeout = 5.minutes

"collector" should {

"set cookie attributes according to configuration" in {

"name, expiration, secure true, httpOnly true, SameSite" in {
val testName = "cookie-attributes-1"
val streamGood = s"${testName}-raw"
val streamBad = s"${testName}-bad-1"

val name = "greatName"
val expiration = 42 days
val secure = true
val httpOnly = true
val sameSite = SameSite.Strict
val streamGood = s"$testName-raw"
val streamBad = s"$testName-bad-1"

Collector.container(
"kinesis/src/it/resources/collector.hocon",
"kinesis/src/it/resources/collector-cookie-attributes-1.hocon",
testName,
streamGood,
streamBad,
additionalConfig = Some(
mkConfig(
name = name,
expiration = expiration,
secure = secure,
httpOnly = httpOnly,
sameSite = sameSite.toString()
)
)
streamBad
).use { collector =>
val request = EventGenerator.mkTp2Event(collector.host, collector.port)

Expand All @@ -66,16 +49,16 @@ class CookieSpec extends Specification with Localstack with CatsEffect {
} yield {
resp.cookies match {
case List(cookie) =>
cookie.name must beEqualTo(name)
cookie.name must beEqualTo("greatName")
cookie.expires match {
case Some(expiry) =>
expiry.epochSecond should beCloseTo((now + expiration).toSeconds, 10)
expiry.epochSecond should beCloseTo((now + 42.days).toSeconds, 10)
case None =>
ko(s"Cookie [$cookie] doesn't contain the expiry date")
}
cookie.secure should beTrue
cookie.httpOnly should beTrue
cookie.sameSite should beEqualTo(sameSite)
cookie.sameSite should beSome(SameSite.Strict)
case _ => ko(s"There is not 1 cookie but ${resp.cookies.size}")
}
}
Expand Down

0 comments on commit fbd293c

Please sign in to comment.