diff options
author | zachdriver <zach@driver.xyz> | 2018-02-22 11:31:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-22 11:31:51 -0800 |
commit | d48406367be713fe8fd24f8dea15545817906cd4 (patch) | |
tree | 0ae98459f1c3d28953922a0ab1170fa83fc5f85b /src/test/scala/xyz/driver/core/rest/DriverAppTest.scala | |
parent | d534ce2309052329506b31b17ae137950757890f (diff) | |
parent | 2059634d2fa2c28ddf2b992bc36ab3d96f3c2512 (diff) | |
download | driver-core-d48406367be713fe8fd24f8dea15545817906cd4.tar.gz driver-core-d48406367be713fe8fd24f8dea15545817906cd4.tar.bz2 driver-core-d48406367be713fe8fd24f8dea15545817906cd4.zip |
Merge pull request #104 from drivergroup/zsmith/reject-corsv1.8.2
Respond with correct cors headers for all rejections
Diffstat (limited to 'src/test/scala/xyz/driver/core/rest/DriverAppTest.scala')
-rw-r--r-- | src/test/scala/xyz/driver/core/rest/DriverAppTest.scala | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala b/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala deleted file mode 100644 index f5602be..0000000 --- a/src/test/scala/xyz/driver/core/rest/DriverAppTest.scala +++ /dev/null @@ -1,58 +0,0 @@ -package xyz.driver.core.rest - -import akka.http.scaladsl.model.headers._ -import akka.http.scaladsl.model.{HttpMethods, StatusCodes} -import akka.http.scaladsl.server.Directives._ -import akka.http.scaladsl.server.Route -import akka.http.scaladsl.settings.RoutingSettings -import akka.http.scaladsl.testkit.ScalatestRouteTest -import com.typesafe.config.Config -import com.typesafe.scalalogging.Logger -import org.scalatest.{FlatSpec, Matchers} -import xyz.driver.core.app.{DriverApp, Module} - -import scala.reflect.runtime.universe._ - -class DriverAppTest extends FlatSpec with ScalatestRouteTest with Matchers { - class TestRoute extends DriverRoute { - override def log: Logger = xyz.driver.core.logging.NoLogger - override def route: Route = path("api" / "v1" / "test")(post(complete("OK"))) - } - - val module: Module = new Module { - val testRoute = new TestRoute - override def route: Route = testRoute.routeWithDefaults - override def routeTypes: Seq[Type] = Seq(typeOf[TestRoute]) - override val name: String = "test-module" - } - - val app: DriverApp = new DriverApp( - appName = "test-app", - version = "0.1", - gitHash = "deadb33f", - modules = Seq(module) - ) - - val config: Config = xyz.driver.core.config.loadDefaultConfig - val routingSettings: RoutingSettings = RoutingSettings(config) - val appRoute: Route = - Route.seal(app.appRoute)(routingSettings = routingSettings, rejectionHandler = DriverApp.rejectionHandler) - - "DriverApp" should "respond with the correct CORS headers for the swagger OPTIONS route" in { - Options(s"/api-docs/swagger.json") ~> appRoute ~> check { - status shouldBe StatusCodes.OK - info(response.toString()) - headers should contain(`Access-Control-Allow-Origin`(HttpOriginRange.*)) - headers should contain(`Access-Control-Allow-Methods`(HttpMethods.GET)) - } - } - - it should "respond with the correct CORS headers for the test route" in { - Options(s"/api/v1/test") ~> appRoute ~> check { - status shouldBe StatusCodes.OK - info(response.toString()) - headers should contain(`Access-Control-Allow-Origin`(HttpOriginRange.*)) - headers should contain(`Access-Control-Allow-Methods`(HttpMethods.GET, HttpMethods.POST)) - } - } -} |