Comments (3)
Hi,
It's not possible to do that quite as simply you've stated, but you could achieve the same thing by pulling down the logged requests and inspecting them e.g.
List<LoggedRequest> requests = findAll(getRequestedFor(urlEqualTo("/test")));
assertThat(requests, hasItem(withoutHeader("Some-Header", "some-value")));
where withoutHeader()
returns a Hamcrest matcher over HttpHeader
values.
Hope that's some help.
I've got a bit of a backlog of stuff I want to do at the moment, but I'll try and get your suggestion added at some point.
Tom
from wiremock.
Great, thanks.
I've gone with something like this to tide me over...
@Test
public void headerIsNotSet() throws MalformedURLException {
// make http call
verifyNoHeadersFor(urlEqualTo("/test"));
}
private void verifyNoHeadersFor(UrlMatchingStrategy url) {
List<LoggedRequest> requests = findAll(getRequestedFor(url));
assertThat(requests, not(contains(HeaderMatcher.header("Authorization"))));
}
private static class HeaderMatcher extends TypeSafeMatcher<LoggedRequest> {
private final String header;
private HeaderMatcher(String header) {
this.header = header;
}
public static HeaderMatcher header(String header) {
return new HeaderMatcher(header);
}
@Override
protected boolean matchesSafely(LoggedRequest actual) {
return actual.containsHeader(header);
}
@Override
public void describeTo(Description description) {
description.appendValue(header);
}
}
from wiremock.
I've added withoutHeader() now. Please let me know if you use it and have any issues with it.
Cheers,
Tom
from wiremock.
Related Issues (20)
- Support mTLS (client certificate) for standalone WireMock client
- urlPathTemplate does not work in combination with queryParameters HOT 1
- Allow loading a stub for a single file instead of a directory
- Make checking for duplicate IDs optional HOT 2
- No command line option to set template escape disabled to false
- ID reported as already taken when registering a single stub HOT 2
- Optimal order of offsetting and truncating expected date/time values
- Recording fails when JSON in a request was invalid
- could not find helper: "jsonMerge" HOT 3
- Add idle timeout configuration when running as forward (browser) proxy
- Add support for HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables
- PatternSyntaxException in PathTemplate.SPECIAL_SYMBOL_REGEX on Android HOT 2
- Support removeAndGet method on stores
- Support for configuring cipher suites of WiremockServer in WireMockConfiguration
- Adding support for compressed stub for snappy compression HOT 1
- Response Template behaviour changed in 3.X version HOT 1
- WireMock alters both strong and weak etags values when serving a gzipped response
- Diff rendering fails when path template contains multiple params but not all have matchers
- Support `multipart/related` Requests for SOAP-Requests with MTOM HOT 1
- headers -> hasExactly with several variants not match in request checkinf
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wiremock.