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

feat: allow exporting endpoints from integration tests #99

Open
DarkAtra opened this issue Jul 20, 2023 · 0 comments
Open

feat: allow exporting endpoints from integration tests #99

DarkAtra opened this issue Jul 20, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@DarkAtra
Copy link
Member

DarkAtra commented Jul 20, 2023

Context

The current version of the exporter allows you to export endpoints from a compiled application (jar or extracted jar). This is mostly useful for integration with tools like ZAP. However, most teams are no longer deploying jar files but docker images instead. In such situations, the current implementation could become hard to use.

Describe the solution you'd like

We're aiming to introduce another version of the exporter, preferably in the same repo (multi module), that allows exporting endpoints from integration tests.

This could be implemented as a junit extension that resolves the current application context and fetches all HandlerMappings:

private RequestMappingHandlerMapping getRequestMappingHandlerMapping(final ExtensionContext extensionContext) {
    final ApplicationContext applicationContext = SpringExtension.getApplicationContext(extensionContext);
    return applicationContext.getBean(RequestMappingHandlerMapping.class);
}

The HandlerMappings could then be mapped to the OpenAPI format we're currently using. Here a POC.

Pros

  • you no longer have to build a jar file to export endpoints, potentially reducing build times
  • easier to use than the standalone version - extending an existing integration test with @ExtendWith(SpringEndpointExporterExtension.class) is all there is to do

Cons

  • the export is based on the test context, some endpoints might be disabled (e.g. by excluding the controller class from the test context) - it's your responsibility to ensure the export includes all relevant endpoints
@DarkAtra DarkAtra added the enhancement New feature or request label Jul 20, 2023
@DarkAtra DarkAtra self-assigned this Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant