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

Make Keycloak DevService work with @QuarkusIntegrationTest and container launches #21995

Closed
wants to merge 1 commit into from

Conversation

geoand
Copy link
Contributor

@geoand geoand commented Dec 7, 2021

This is a WIP to fix #21935.

@sberyozkin unfortunately this does not yet work, (I think) because the token received from the KeycloakTestClient has iss of http://localhost:49267/auth/realms/quarkus (which is the URL the test can access Keycloak from - i.e. a URL accessible on the host machine), but the Quarkus application under test accesses the application using something like http://keycloak-uX81K:8080/auth/realms/quarkus - i.e. the URL that is usable in the container network.
What can we do to address this issue? Can we "patch" the token somehow?

P.S. This contains a lot of hacks, but for most of them, I don't see a way around them for this use case.

@sberyozkin
Copy link
Member

sberyozkin commented Dec 7, 2021

Hi @geoand thanks very much for looking into it.

Re the issuer problem, adding quarkus.oidc.token.issuer=any should do it in the test.
Setting KEYCLOAK_FRONTEND_URL env var should also fix it - but here the host port is dynamic, so not sure if setting KEYCLOAK_FRONTEND_URL=http://localhost in KeycloakDevServicesProcessor can do it; skipping the issuer verification with any is probably the easiest approach.

Let me also check what Keycloak logs, may be it is possible to avoid using HttpWaitStrategy

@geoand
Copy link
Contributor Author

geoand commented Dec 7, 2021

Thanks! Let me try that out

@sberyozkin
Copy link
Member

Re the logs, WildFly based one logs:

13:43:33,804 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 65) WFLYUT0021: Registered web context: '/auth' for server 'default-server'
...
13:43:33,930 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Keycloak 15.0.2 (WildFly Core 15.0.1.Final) started in 17430ms - Started 692 of 977 services (686 services are lazy, passive or on-demand)

I think Registered web context: '/auth' for server check should be enough.. Though let me also check what is logged with Keycloak-X

@sberyozkin
Copy link
Member

Keycloak-X reports:
Keycloak 15.0.2 on JVM (powered by Quarkus 1.13.3.Final) started - the underlying quarkus version will be changed with Keycloak 16.0.0. But I don't see a message like Registered web context:...

So the common pattern is:

  • Default (wildfly) image: Keycloak 15.0.2 (WildFly Core 15.0.1.Final) started
  • Keycloak-X image: Keycloak 15.0.2 on JVM (powered by Quarkus 1.13.3.Final) started

So checking the container log for Keycloak 15.0.2 ... started where the version can be retrieved from DockerImageName should be enough, suppose a regex can get it, what do you think ? If you'd like I can experiment on a PR just to switch away from HttpWaitStrategy ?

@geoand
Copy link
Contributor Author

geoand commented Dec 7, 2021

Thanks for checking @sberyozkin!

Yeah, I'll try that, it's a much better idea

@geoand
Copy link
Contributor Author

geoand commented Dec 7, 2021

Keep in mind however that some of the other hacks in this PR will remain

@sberyozkin
Copy link
Member

Thanks, sure, having a few hacks will be not bad :-)

@geoand
Copy link
Contributor Author

geoand commented Dec 7, 2021

The fewer the better :)

@geoand
Copy link
Contributor Author

geoand commented Dec 7, 2021

Closing in favor of #21999

@geoand geoand closed this Dec 7, 2021
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Dec 7, 2021
@geoand geoand deleted the #21935 branch December 7, 2021 15:42
geoand added a commit to geoand/quarkus that referenced this pull request Dec 7, 2021
geoand added a commit to geoand/quarkus that referenced this pull request Dec 7, 2021
Postremus pushed a commit to Postremus/quarkus that referenced this pull request Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keycloak DevService not considered healthy when running in docker shared network mode
2 participants