-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZIO HTTP Server should not fold set-cookie headers
This change makes the behaviour of handling multiple Set-Cookie headers consistent among multiple server backends. See #3654 for more details.
- Loading branch information
Showing
3 changed files
with
56 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
server/tests/src/main/scala/sttp/tapir/server/tests/ServerCookieHeadersTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package sttp.tapir.server.tests | ||
|
||
import cats.implicits.catsSyntaxEitherId | ||
import org.scalatest.matchers.should.Matchers._ | ||
import sttp.client3._ | ||
import sttp.model._ | ||
import sttp.model.headers.CookieWithMeta | ||
import sttp.monad.MonadError | ||
import sttp.tapir._ | ||
import sttp.tapir.tests.Test | ||
|
||
class ServerCookieHeadersTests[F[_], OPTIONS, ROUTE](createServerTest: CreateServerTest[F, Any, OPTIONS, ROUTE])(implicit m: MonadError[F]) { | ||
|
||
import createServerTest._ | ||
|
||
def tests(): List[Test] = requestTests | ||
|
||
val requestTests = List( | ||
testServerLogic( | ||
endpoint.in("cookies-test").get.out(setCookies).serverLogic { _ => | ||
pureResult( | ||
List( | ||
CookieWithMeta.unsafeApply("name1", "value1", path = Some("/path1")), | ||
CookieWithMeta.unsafeApply("name2", "value2", path = Some("/path2")) | ||
).asRight[Unit] | ||
) | ||
}, | ||
"Multple Set-Cookie headers should not be compacted" | ||
) { (backend, baseUri) => | ||
basicRequest.response(asStringAlways).get(uri"$baseUri/cookies-test").send(backend).map { r => | ||
r.headers should contain allOf( | ||
Header.setCookie(CookieWithMeta.unsafeApply("name1", "value1", path = Some("/path1"))), | ||
Header.setCookie(CookieWithMeta.unsafeApply("name2", "value2", path = Some("/path2"))) | ||
) | ||
} | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters