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

Add KeycloakTestResourceLifecycleManager #13957

Closed
sberyozkin opened this issue Dec 17, 2020 · 6 comments · Fixed by #16035
Closed

Add KeycloakTestResourceLifecycleManager #13957

sberyozkin opened this issue Dec 17, 2020 · 6 comments · Fixed by #16035

Comments

@sberyozkin
Copy link
Member

sberyozkin commented Dec 17, 2020

Description
In many OIDC related tests we have to add QuarkusTestResourceLifecycleManager implementations which setup Keycloak - realm, client, users.
@stuartwdouglas has proposed that we provide the one which can be reused in tests, which is a nice idea.

Implementation ideas
Users who would like to test quarkus-oidc against Keycloak should be able to type something like this:

@QuarkusTest
@QuarkusTestResource(TestKeycloakRealmResourceManager.class)
public class CodeFlowTest {

    @Test
    public void testCodeFlow() throws IOException {
    }
}

where TestKeycloakRealmResourceManager.class would by default set up quarkus realm, quarkus-app client, users alice as admin and bob as user, something like that, and possibly be configurable

CC @stuartwdouglas @pedroigor

@cemnura let me know please if it can be of interest once the wiremock issues are complete :-)

@cemnura
Copy link
Contributor

cemnura commented Dec 22, 2020

@sberyozkin I would love to give it a crack. I think we are close to wrapping up the wiremock issues or opaque token.

This would make testing quarkus services that use oidc with keycloak a breeze :)

@gsmet
Copy link
Member

gsmet commented Dec 22, 2020

It should be called KeycloakTestResourceLifecycleManager btw.

@gsmet gsmet changed the title Add TestKeycloakResourceLifecycleManager Add KeycloakTestResourceLifecycleManager Dec 22, 2020
@sberyozkin
Copy link
Member Author

Hi @cemnura, OK, great, let us complete the wiremock issue first (I'll follow up with the docs) and then we'll discuss this one, cheers

@sberyozkin
Copy link
Member Author

@cemnura Hi Cem - assigning to you as agreed, lets have a keycloak-server test module similar to a more generic wiremock based oidc-server - but this one would setup the real live KC instance, moving the code from integration-tests/oidc, thanks

@cemnura
Copy link
Contributor

cemnura commented Mar 25, 2021

@sberyozkin I'm on it 😄

@cemnura
Copy link
Contributor

cemnura commented Mar 26, 2021

I figured out that the current integration-tests/oidc runs a test container via maven plugin.

I migrated the QuarkusTestResourceLifecycleManager to a separate test-framework module and enabled the test container to run programmatically rather then a maven plugin.

All previous test seems to be working.

Also, I did not change the maven profile configurations so that it wont be a problem during CI pipeline.

To run the test

./mvnw -Dquickly
./mvnw package -f integration-tests/oidc -Ptest-keycloak             

@quarkus-bot quarkus-bot bot added this to the 1.14 - main milestone Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants