com.github.tomakehurst.wiremock.security.NotAuthorisedException - when loading stubs - relative and root path
See original GitHub issueWiremock Version 2.15.0 you could define file
stubs like that
stubFor(any(urlPathEqualTo(url))
.withQueryParam(xxxx)
.withQueryParam(xxxx)
.willReturn(aResponse()
.withStatus(HttpStatus.OK.value())
.withBodyFile("/xservice/file.json")));
where /xservice/file.json
was under /src/test/resources/__files/xservice/file.json
Upgrading to Version 2.17.0 and checking the implemantion of com.github.tomakehurst.wiremock.common.AbstractSourceFile
I can see that the same test will fail with
com.github.tomakehurst.wiremock.security.NotAuthorisedException: Access to file /xservice/
If I strip the /
from /xservice
so that we define the stub like
stubFor(any(urlPathEqualTo(url))
.withQueryParam(xxxx)
.withQueryParam(xxxx)
.willReturn(aResponse()
.withStatus(HttpStatus.OK.value())
.withBodyFile("xservice/file.json")));
It works again.
I am not sure is this intentional or a bug? Mostly I am posting it in case others are affected.
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:8
Top Results From Across the Web
com.github.tomakehurst.wiremock.security ...
com.github.tomakehurst.wiremock.security.NotAuthorisedException - when loading stubs - relative and root path #921.
Read more >A brand new website interface for an even better experience!
com.github.tomakehurst.wiremock.security.NotAuthorisedException - when loading stubs - relative and root path.
Read more >com.github.tomakehurst.wiremock.security ... - Tabnine
private void assertFilePathIsUnderRoot(String path) { try { String rootPath = rootDirectory.getCanonicalPath(); File file = new File(path); String filePath ...
Read more >WireMock Tutorial: Introduction to Stubbing - Petri Kainulainen
This blog post describes how we can stub HTTP requests with WireMock. After we have finished this blog post, we: Know what stubbing...
Read more >com.github.tomakehurst.wiremock.client.VerificationException
In your code you are stubbing out a response and then verifying that a request has been made for that stub. You are...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just wanted to mention that bug still exists in version 2.18.0
It works when I run my build on Windows, but it fails on run in Travis CI. When I strip the path from “/” at the beginning it works on both platforms.
Closing this since there’s a trivial workaround. Documented in 95a57b0721f5eea463ee3a663f1f502111f89550.