wiremock / python-wiremock

A Python library for API mocking and testing with Testcontainers module and WireMock
https://wiremock.readthedocs.io
Other
58 stars 26 forks source link

`Requests.reset_request_journal()` doesn't work with Wiremock V3 #95

Open EvgeniyaGorobets opened 1 year ago

EvgeniyaGorobets commented 1 year ago

Apologies if this is considered in scope for https://github.com/wiremock/python-wiremock/issues/91, but I wanted to call out a specific bug.

The class method Requests.reset_request_journal() (code) throws a 404 NotFoundException after upgrading to Wiremock V3, because the POST __admin/requests/reset endpoint was deleted: https://github.com/wiremock/wiremock/commit/47d420197738bb28ece30a2d7c86c7f828bf985f#diff-629cfdfeca71797a13d4138932081242b849e382a194fd6784736ce83c310350L84

I believe this method should call DELETE __admin/requests instead, since this endpoint fires the new ResetRequestsTask: https://github.com/wiremock/wiremock/blob/master/src/main/java/com/github/tomakehurst/wiremock/admin/AdminRoutes.java#L84

Reproduction steps

Start up wiremock and call Requests.reset_request_journal()

References

No response

EvgeniyaGorobets commented 1 year ago

I tried to make a branch with the proposed fix but I got permission denied when I tried to push my branch to GitHub. Here's what I think that method should look like:

@classmethod
def reset_request_journal(cls, parameters={}):
    response = cls.REST_CLIENT.delete(cls.get_base_uri(cls.endpoint()), headers=make_headers(), params=parameters)
    return cls.REST_CLIENT.handle_response(response)
oleg-nenashev commented 1 year ago

Sorry, I missed this issue. Indeed, it needs to be updated as a Part of the WireMock 3 compatibility effort