diff options
author | Sergey Nastich <nastich@users.noreply.github.com> | 2018-06-14 01:36:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-14 01:36:52 -0400 |
commit | a43e0a4d8b5cea6124acb0a3dac14e259a154a50 (patch) | |
tree | dfcf680a050c216b6d70bdcc50748839e7c35fed /src/test/scala | |
parent | d503665c743c17b4446c1eef58ac3733af2fde85 (diff) | |
download | driver-core-a43e0a4d8b5cea6124acb0a3dac14e259a154a50.tar.gz driver-core-a43e0a4d8b5cea6124acb0a3dac14e259a154a50.tar.bz2 driver-core-a43e0a4d8b5cea6124acb0a3dac14e259a154a50.zip |
Add `Connection: close` header to all responses in order to mitigate connection pool issues with envoy (#175)v1.11.2
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/xyz/driver/core/rest/DriverRouteTest.scala | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/test/scala/xyz/driver/core/rest/DriverRouteTest.scala b/src/test/scala/xyz/driver/core/rest/DriverRouteTest.scala index aca8fdc..d32fefd 100644 --- a/src/test/scala/xyz/driver/core/rest/DriverRouteTest.scala +++ b/src/test/scala/xyz/driver/core/rest/DriverRouteTest.scala @@ -2,8 +2,9 @@ package xyz.driver.core.rest import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import akka.http.scaladsl.model.StatusCodes +import akka.http.scaladsl.model.headers.Connection import akka.http.scaladsl.server.Directives.{complete => akkaComplete} -import akka.http.scaladsl.server.{Directives, Route} +import akka.http.scaladsl.server.{Directives, Rejection, RejectionHandler, Route} import akka.http.scaladsl.testkit.ScalatestRouteTest import com.typesafe.scalalogging.Logger import org.scalatest.{AsyncFlatSpec, Matchers} @@ -12,6 +13,7 @@ import xyz.driver.core.json.serviceExceptionFormat import xyz.driver.core.FutureExtensions import xyz.driver.core.rest.errors._ +import scala.collection.immutable import scala.concurrent.Future class DriverRouteTest @@ -103,4 +105,19 @@ class DriverRouteTest responseAs[ServiceException] shouldBe DatabaseException() } } + + it should "add a `Connection: close` header to avoid clashing with envoy's timeouts" in { + val rejectionHandler = RejectionHandler.newBuilder().handleNotFound(complete(StatusCodes.NotFound)).result() + val route = new TestRoute(handleRejections(rejectionHandler)((get & path("foo"))(complete("OK")))) + + Get("/foo") ~> route.routeWithDefaults ~> check { + status shouldBe StatusCodes.OK + headers should contain(Connection("close")) + } + + Get("/bar") ~> route.routeWithDefaults ~> check { + status shouldBe StatusCodes.NotFound + headers should contain(Connection("close")) + } + } } |