Allow localhost:9000 explicitly in example.#81
Conversation
|
Beware the tests are failing because they are using another port (not 9000). |
|
I think this is failing because class FakeRequestFactory(requestFactory: RequestFactory) {
def apply(): FakeRequest[AnyContentAsEmpty.type] = {
apply(method = "GET", uri = "/", headers = FakeHeaders(Seq(HeaderNames.HOST -> "localhost")), body = AnyContentAsEmpty)
}
}whereas it should be using the default test port (or whatever it is overridden to in the application). class FunctionalSpec extends PlaySpec with GuiceOneServerPerSuite {
"Routes" should {
"send 404 on a bad request" in {
route(app, FakeRequest(GET, "/boum").withHeaders(FakeHeaders(Seq(HeaderNames.HOST -> s"localhost:$port")))).map(status(_)) mustBe Some(NOT_FOUND)
}
"send 200 on a good request" in {
route(app, FakeRequest(GET, "/").withHeaders(FakeHeaders(Seq(HeaderNames.HOST -> s"localhost:$port")))).map(status(_)) mustBe Some(OK)
}
}
}The problem is that |
|
Fix needs to change documentation as well. https://www.playframework.com/documentation/2.6.x/AllowedHostsFilter#Testing Also note the original example was actually about |
Same as playframework/play-java-starter-example#61