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

karate mock server interceptor #2443

Closed
sergy8612 opened this issue Nov 9, 2023 · 8 comments
Closed

karate mock server interceptor #2443

sergy8612 opened this issue Nov 9, 2023 · 8 comments
Assignees
Milestone

Comments

@sergy8612
Copy link
Contributor

sergy8612 commented Nov 9, 2023

Hi @ptrthomas

From this question https://stackoverflow.com/questions/77346337/karate-test-framework-are-there-plans-to-include-runtimehooks-for-mockserver we open this issue.

In our case, we need to implement an interceptor in mock http server to track the requests-responses and the scenario and gather all that info to generate a report, with the scenario, the request and response, to validate them against a swagger (we use https://pactflow.io/ which needs to track the request and responses from the mock server to validate the contracts) and in the validation we need not only the http request and response, but the scenario in the mockserver as well. This allows us to generate the report and the Contract Test in our component tests and in our case saves us lots of work.

Unfortunately we don't have that kind of hook .

I created this interface as a hook which meets these needs by extending the karate MockHandler and MockServer

image

Then I included this interceptor interface as a hook in our customzed mockserver
image

image

For these reasons, I'd like to create a pull request as a contribution by including the possibility of adding this intereptor

@ptrthomas
Copy link
Member

@sergy8612 I think it is an interesting idea. if you are ok to submit a PR with a nice sample, I will certainly review it and consider it for merge. I may have some requests to change / improve the design, thanks

@sergy8612
Copy link
Contributor Author

@sergy8612 I think it is an interesting idea. if you are ok to submit a PR with a nice sample, I will certainly review it and consider it for merge. I may have some requests to change / improve the design, thanks

seems I don't have premissions to push a branch into this repo. Can you enable it?

@ptrthomas
Copy link
Member

@sergy8612
Copy link
Contributor Author

sergy8612 commented Nov 11, 2023

Hi @ptrthomas , here is the PR #2445

@ptrthomas ptrthomas added this to the 1.5.0 milestone Nov 15, 2023
@ptrthomas
Copy link
Member

@sergy8612 thanks ! would be good to have documentation and a better unit-test, but I have merged for now

@ptrthomas
Copy link
Member

@sergy8612 FYI 1.5.0.RC2 is available including this merge

@ptrthomas
Copy link
Member

@sergy8612 can you see if mocks are working fine for https://github.com/karatelabs/karate/releases/tag/v1.5.0.RC5 - the reason I ask is because I saw some issues in resolving the correct versions of netty in spring-boot projects, so I'm still holding on releasing 1.5.0 final :|

@ptrthomas
Copy link
Member

1.5.0 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants