Home > front end >  can I block mappings changes via API in WireMock standalone?
can I block mappings changes via API in WireMock standalone?

Time:06-02

TLDR: Is there a way to disable whole or part of the Stub Mappings API (i.e. disable POST/PUT/DELETE to '/__admin/mappings')? Let's assume I want to do it on Wiremock instance level, not a proxy server level.

In my company we use the WireMock server in standalone mode, and supply it with stub mappings via JSON files in the 'mapping' subdirectory of the root-dir.

I would like to control stubs exclusively via the JSON files, and protect them from being added/updated/removed, using the API... which used to be the practice, and may accidentally still happen (messing the mappings up).

Thanks

CodePudding user response:

You could achieve this by implementing a filter extension. Specifically you'd probably want to extend AdminRequestFilter and use it to apply rules about which methods/URLs you want to allow.

Here's an example implementation of a filter of this kind: https://github.com/wiremock/wiremock/blob/master/src/test/java/com/github/tomakehurst/wiremock/RequestFilterAcceptanceTest.java#L236

You can find general info about creating and registering extensions here: https://wiremock.org/docs/extending-wiremock/

  • Related