I have a Micronaut application that uses JWT and JWKS.
In my application yaml for tests, I have configured the jwks url as follows:
micronaut:
security:
token:
jwt:
signatures:
jwks:
securityservice:
url: "http://127.0.0.1:9090/keys"
I'm using WireMock for mocking the /keys
endpoint that Micronaut exposes for JWT validation. I have a hard-coded port that matches the configuration one:
new WireMockServer(wireMockConfig().port(9090)
And everything works fine so far.
The point is that I want to be able to generate a random port to avoid concurrent test collisions with the WireMock port.
So, I've tried with url: "http://127.0.0.1:${wiremock.server.port}/keys"
(inspiration from here) as well by using the micronaut.server.port
set to -1
and something like url: "http://127.0.0.1:${micronaut.server.port + 1}/keys"
but non of them are resolved by Micronaut.
Do you know how this could be achieved? Any workaround maybe by not using WireMock and following another approach?