+htp #15932 integrate SchemeDirectives from spray codebase
This commit is contained in:
parent
49f2e8bcf5
commit
0966bf6233
3 changed files with 72 additions and 2 deletions
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package akka.http.server
|
||||
package directives
|
||||
|
||||
import akka.http.model.StatusCodes._
|
||||
|
||||
class SchemeDirectivesSpec extends RoutingSpec {
|
||||
"the schemeName directive" should {
|
||||
"extract the Uri scheme" in {
|
||||
Put("http://localhost/", "Hello") ~> schemeName { echoComplete } ~> check { responseAs[String] shouldEqual "http" }
|
||||
}
|
||||
}
|
||||
|
||||
"""the scheme("http") directive""" should {
|
||||
"let requests with an http Uri scheme pass" in {
|
||||
Put("http://localhost/", "Hello") ~> scheme("http") { completeOk } ~> check { response shouldEqual Ok }
|
||||
}
|
||||
"reject requests with an https Uri scheme" in {
|
||||
Get("https://localhost/") ~> scheme("http") { completeOk } ~> check { rejections shouldEqual List(SchemeRejection("http")) }
|
||||
}
|
||||
"cancel SchemeRejection if other scheme passed" in {
|
||||
val route =
|
||||
scheme("https") { completeOk } ~
|
||||
scheme("http") { reject }
|
||||
|
||||
Put("http://localhost/", "Hello") ~> route ~> check {
|
||||
rejections should be(Nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"""the scheme("https") directive""" should {
|
||||
"let requests with an https Uri scheme pass" in {
|
||||
Put("https://localhost/", "Hello") ~> scheme("https") { completeOk } ~> check { response shouldEqual Ok }
|
||||
}
|
||||
"reject requests with an http Uri scheme" in {
|
||||
Get("http://localhost/") ~> scheme("https") { completeOk } ~> check { rejections shouldEqual List(SchemeRejection("https")) }
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue