https://linen.dev logo
#help
Title
# help
e

Ekta Bansal

07/13/2023, 6:05 AM
<title>Error 500 com.github.tomakehurst.wiremock.security.NotAuthorisedException: Access to file ../resources/__files/get-users-200.json is not permitted</title> getting this error when i am trying to connect to my json file.
o

Oleg Nenashev

07/13/2023, 6:12 AM
Is it on the filesystem? Or do you have a custom WireMock JAR build?
e

Ekta Bansal

07/13/2023, 6:19 AM
i am using java+wirwmock
WireMockServer wireMockServer = new WireMockServer(_wireMockConfig_().port(8089)); //No-args constructor will start on port 8089, no HTTPS wireMockServer.start(); // Setup the WireMock mapping stub for the test wireMockServer.stubFor(_post_("/carts") .willReturn(_aResponse_() .withStatus(201) .withHeader("Content-Type", "application/json") .withBodyFile("../resources/__files/get-users-200.json")));
@Oleg Nenashev
o

Oleg Nenashev

07/13/2023, 9:46 AM
So you must pass absolute path according to https://github.com/wiremock/wiremock/blob/4a2593e576ae5732e469119c5ecd84605f3fc594[…]/com/github/tomakehurst/wiremock/common/AbstractFileSource.java IMHO we need a better error message for such a situation
@Ekta Bansal submitted a pull request: https://github.com/wiremock/wiremock/pull/2267
@Ekta Bansal the patch will be in the next WireMock release, just FYI
It only makes the error more explicit, I have not changed the behavior because it looks reasonable to me for the Java code when absolute paths could be easily used. If it impacts the configuration files, this is something to revise
5 Views