Can HTTPS listening be enabled in Play Framework during tests?
Asked Answered
F

1

10

I'm doing some testing in Play right now that involves an HTTPS websocket client. It's going through Netty for HTTPS functionality, so I'm not using any built in HTTP classes (such as anything in the WS namespace). I would like to write a couple of tests to ensure that SSL connects correctly and that it rejects invalid data properly.

My thought was to just have Play run HTTPS during testing with a sample keystore, however in test, it looks like Play is not respecting the https.port setting (I'm getting 'connection refused' during test, but it works fine in development).

I've added this to my build.sbt:

javaOptions in (Test) += "-Dhttps.port=23456"

Is there any way to get HTTPS running in test?

Featured answered 27/8, 2014 at 16:7 Comment(1)
Can you post some example test code that is failing?Notability
U
0

When running normal unit tests written with ScalaTest, the Play application will generally not run in the background. There may be constructs in the following library that could help you test the logic in your endpoints: scalatestplus-play . You can use this library to simulate HTTP/HTTPS requests. If you actually want to test HTTPS, this might actually be easier to do with a short shell script.

Ultimogeniture answered 28/1, 2020 at 11:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.