Additional matchers for wiremock that implement logical operators (AND, OR, XOR, NOT).
Add wiremock_logical_matchers
to your development dependencies:
toml
[dev-dependencies]
wiremock = "0.5.19"
wiremock_logical_matchers = "0.1.2"
or by running:
bash
cargo add wiremock_logical_matchers --dev
```rust use wiremock::{Mock, MockServer, ResponseTemplate}; use wiremock::matchers::{header, headerexists, path, queryparam}; use wiremocklogicalmatchers::{and, not, or, xor};
async fn testgettingstarted() { let mock_server = MockServer::start().await;
Mock::given(path("/test"))
.and(
and(
header_exists("x-for-testing-purposes"),
query_param("page", "1")
)
).and(
or(
header("authorization", "Bearer some_token"),
query_param("override-security", "1")
)
).and(
xor(
header("x-license", "MIT"),
header("x-license-file", "LICENSE")
)
).and(
not(
header_exists("x-voldemort")
)
).respond_with(ResponseTemplate::new(200))
.mount(&mock_server)
.await;
// ...
} ```