How to do integration tests when using Quarkus OIDC code flow authentication? #43910
-
Here is how I am testing my authenticated endpoints using org.htmlunit:
It feels hacky to depend on elements of the HTML page as it is Keycloak's not mine, but I guess there is no other way. Also, sending the cookies like that feels like brute force, is there another option? I could just send the "q_session" but I am still not sure where this cookie name is defined and which Quarkus OIDC configuration is responsible for defining the session strategy (I'm guessing the one that I am using is stateless and encrypted in the cookie). Also, writing the I wish there were something as simple as For reference, here's what my properties look like:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
/cc @pedroigor (oidc), @sberyozkin (oidc) |
Beta Was this translation helpful? Give feedback.
@douglas444, to test OIDC code flow, we offer https://quarkus.io/guides/security-oidc-code-flow-authentication#code-flow-integration-testing-wiremock.
Several default stubs are available there, for the auto-discovery, key acquisition, code flow redirect which is a tricky part. Additionally you can add more stubs directly in the test code, inject first, and then set required stubs like this one, etc.
It indeed does not matter, the default Wiremock stub presents it as if if it were a challenge from Keycloak, but it is not what is tested, this page only supports the test f…