Skip to content

Instantly share code, notes, and snippets.

@khalidr
Last active August 29, 2015 14:14
Show Gist options
  • Save khalidr/54c6d67fa6b7cd5efa8b to your computer and use it in GitHub Desktop.
Save khalidr/54c6d67fa6b7cd5efa8b to your computer and use it in GitHub Desktop.
import spray.routing._
class UsersRouteSpec extends RouteSpec with UsersRoute with PlayJsonSupport with MockitoSugar{
//TODO: write some negative tests - particularly, failed credential update
it must "reject a get request if the session user is not authorized" in {
val fakeRoute = authorize(false){
complete{
StatusCodes.OK
}
}
Get("/") ~> addHeader("session", fakeSessionId.toString) ~>
fakeRoute ~> check{
println("^^^^^^^^"+status)
rejection mustBe AuthorizationFailedRejection
//status mustBe StatusCodes.Unauthorized
}
}
}
@khalidr
Copy link
Author

khalidr commented Feb 5, 2015

i get

[info] - must reject a get request if the session user is not authorized *** FAILED ***
[info]   Request was rejected with List(AuthorizationFailedRejection) (RouteTest.scala:74)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment