'Unit testing of tls enabled in akka http
I have enabled tls in my application to use HTTPS instead of HTTP. Now I want to write its unit test.
path("Ping") {
complete("Pong")
}
Get("/Ping") ~> routes ~> check {
status shouldEqual StatusCodes.OK
}
So I expect it to be break if request sent using http and work only if sent using https.
I have tried many things which I found on internet.
Could anyone please help me how can I test it.
Thanks
Solution 1:[1]
Akka Http TestKit is designed to test your route functionality and not how the route is served.
The route serving mechanism (plain text/ssl) is controlled when you bind to http port like in the following code
Http().newServerAt("127.0.0.1", 8080).enableHttps(https).bind(routes)
For more details refer to the docs
Thus, you could only test your https setup with the help of integration tests, where you boot your application and use a real http client and not akka-http-testkit to talk to your service over https. How to do it is outside of the scope of this question.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
