Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation about starting the wiremock container with SSL #164

Open
kosgeia opened this issue Oct 18, 2024 · 4 comments
Open

Documentation about starting the wiremock container with SSL #164

kosgeia opened this issue Oct 18, 2024 · 4 comments

Comments

@kosgeia
Copy link

kosgeia commented Oct 18, 2024

There is no documentation on how to start the container and wiremock to expose a https endpoint.
I have toyed with multiple configurations, including enabling debug mode but the server still exposes default 8080 port in http mode.

@TheRealGuru
Copy link

Looking at the code it doesn't look like HTTPS is at all supported. Writing the code to add it looks relatively simple, but the sheer amount of test code looks a bit scary to get involved with.

It seems currently there is no way to expose a mapped port for HTTPS.

@TheRealGuru
Copy link

The reason why using withExposedPorts does not work is simply because as part of the startup for a container, it calls configure, see here: https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L331

Which calls this method: https://github.com/wiremock/wiremock-testcontainers-java/blob/main/src/main/java/org/wiremock/integrations/testcontainers/WireMockContainer.java#L372

Which then sets the withExposedPorts to 8080 and will wipe all ports that have been set by the user.

A potential hotfix - that shouldn't require much - if at all testing would be to use addExposedPorts instead of withExposedPorts which will not override any user selections.

@TheRealGuru
Copy link

PR created - hopefully up to standards :). Definitely a tactical fix - I think in the future it would make sense to have actual methods for configuring the HTTPS stuff but I needed to unblock myself and fix this issue. I'll come back to this in the future to see if I can create a full solution for HTTPS.

With this change you would need to still configure HTTPS using:

.withCliArg("--https-port PORT_HERE")
.withExposedPorts(PORT_HERE)

Aswell as the other CLI args you require from here: https://wiremock.org/docs/standalone/java-jar/ - Like keystore/truststore etc.

@kosgeia
Copy link
Author

kosgeia commented Jan 9, 2025

Good fix, however it would be good to provide the flexibility to override the containers default entry command. I had initially tried overriding it using withCommand() and it did not seem to start up with the supplied arguments. I will wait for the merge approval to test this. would be good to provide examples of working configurations in the documentation, for clarity's sake ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants