playframework / scalatestplus-play

ScalaTest + Play
https://www.playframework.com/documentation/latest/ScalaTestingWithScalaTest
Apache License 2.0
110 stars 61 forks source link

add testServerFactory method in `BaseOneServer` traits #410

Closed xuwei-k closed 1 year ago

xuwei-k commented 1 year ago

playframework DefaultTestServerFactory set sslPort = Some(0) by default.

https://github.com/playframework/playframework/blob/bf0458232c1f0c98e06c2cba48f1cffca0e7df43/testkit/play-test/src/main/scala/play/api/test/TestServerFactory.scala#L64

but enable ssl and SelfSignedSSLEngineProvider cause IllegalAccessError or NoSuchMethodError

https://github.com/playframework/playframework/blob/bf0458232c1f0c98e06c2cba48f1cffca0e7df43/testkit/play-test/src/main/scala/play/api/test/TestServerFactory.scala#L69

I think scalatestplus-play should provide more convenience way for override enable/disable ssl settings.

mkurz commented 1 year ago

Thanks, will take a look later. This port thing needs a bit more attention from my side, I don't want to blindly merge this.

mkurz commented 1 year ago

The problem you solve here is now solved by Play itself already by disabling the https port by default. Please check out https://github.com/xuwei-k/playframework-jdk-20/pull/1 where I fixed your example, it's working now.

Anyway, I adjusted this pull request, so devs are still able to override the TestFactory, it might help in other situations.