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

Enable contract testing on OIDC protected resources on Quarkus testing tools #94

Closed
patoulatchi opened this issue Oct 15, 2024 · 3 comments
Assignees
Labels
component/settings Relates to API/settings availables kind/enhancement Enhancement of existing feature
Milestone

Comments

@patoulatchi
Copy link

Reason/Context

The context of the feature request has been discussed here:
https://github.com/orgs/microcks/discussions/1379

Description

Support of creation of valid bearer tokens against the OIDC Quarkus devservice tools (keycloak) to be able to contract test API which are authenticated.

Implementation ideas

The keycloak related information (url/port/client/secret/username/password) could be provided by the test implementer in the TestRequest builder. Something similar to this below:

TestRequest testRequest = new TestRequest.Builder()
      .serviceId("My API:1.0.0-SNAPSHOT")
      .runnerType(TestRunnerType.OPEN_API_SCHEMA.name())
      .testEndpoint("http://host.testcontainers.internal:" + quarkusHttpPort)
      .withKeycloakUrl("http://host.testcontainers.internal:" + keycloakPort).withClient("myOidcClient").with....
      .build();
Copy link

👋 @patoulatchi

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first issue here! Be sure to follow the issue template or please update it accordingly.

📢 If you're using Microcks in your organization, please add your company name to this list. 🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

If you need to know why and how to add yourself to the list, please read the blog post "Join the Microcks Adopters list and Empower the vibrant open source Community 🙌"

Hope you have a great time there!

🌟 ~~~~~~~~~ 🌟

📢 If you like Microcks, please ⭐ star ⭐ our repo to support it!

🙏 It really helps the project to gain momentum and credibility. It's a small contribution back to the project with a big impact.

@lbroudoux lbroudoux added kind/enhancement Enhancement of existing feature component/settings Relates to API/settings availables labels Oct 24, 2024
@lbroudoux lbroudoux self-assigned this Nov 4, 2024
@lbroudoux lbroudoux added this to the 0.2.10 milestone Nov 4, 2024
lbroudoux added a commit that referenced this issue Nov 4, 2024
lbroudoux added a commit that referenced this issue Nov 4, 2024
lbroudoux added a commit that referenced this issue Nov 4, 2024
Signed-off-by: Laurent Broudoux <[email protected]>
@lbroudoux
Copy link
Member

You can now use constructs as:

// Issue a TestRequest with OAuth2 context.
TestRequest testRequest = new TestRequest.Builder()
   .serviceId("API Pastries:0.0.1")
   .runnerType(TestRunnerType.OPEN_API_SCHEMA.name())
   .testEndpoint("http://good-impl:3002")
   .timeout(2000L)
   .oAuth2Context(new OAuth2ClientContext.Builder()
      .clientId("myrealm-serviceaccount")
      .clientSecret("ab54d329-e435-41ae-a900-ec6b3fe15c54")
      .tokenUri("http://keycloak:8080/realms/myrealm/protocol/openid-connect/token")
      .grantType(OAuth2GrantType.CLIENT_CREDENTIALS)
      .build())
   .build();

@lbroudoux
Copy link
Member

Now done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/settings Relates to API/settings availables kind/enhancement Enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

2 participants