mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-22 08:18:26 +02:00
Updated Request Matching (markdown)
@@ -4,11 +4,17 @@ WireMock.Net supports matching of requests to stubs and verification queries usi
|
|||||||
* Path
|
* Path
|
||||||
* URL
|
* URL
|
||||||
* HTTP Method
|
* HTTP Method
|
||||||
* Query parameters
|
* [Query parameters](#query-parameters)
|
||||||
* Headers
|
* [Headers](#headers)
|
||||||
* Cookies
|
* Cookies
|
||||||
* Request Body
|
* Request Body
|
||||||
|
|
||||||
|
## Generic information on matchers:
|
||||||
|
|
||||||
|
Most matchers have 2 extra properties:
|
||||||
|
- IgnoreCase = define that the matcher should match ignoring the case
|
||||||
|
- RejectOnMatch = define that when the matcher does match successfully, this should be counted as a invalid (non-matching) match
|
||||||
|
|
||||||
## Example Matching for the elements
|
## Example Matching for the elements
|
||||||
|
|
||||||
### Query Parameters
|
### Query Parameters
|
||||||
@@ -39,6 +45,47 @@ server
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Headers
|
||||||
|
#### C#
|
||||||
|
``` c#
|
||||||
|
// todo
|
||||||
|
```
|
||||||
|
|
||||||
|
#### JSON
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"Request": {
|
||||||
|
"Headers": [
|
||||||
|
{
|
||||||
|
"Name": "api-key",
|
||||||
|
"Matchers": [
|
||||||
|
{
|
||||||
|
"Name": "WildcardMatcher",
|
||||||
|
"Pattern": "abc*"
|
||||||
|
"IgnoreCase": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that when you want to match on a missing header, you need to use this mapping:
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"Request": {
|
||||||
|
"Headers": [
|
||||||
|
{
|
||||||
|
"Name": "api-key",
|
||||||
|
"IgnoreCase": true,
|
||||||
|
"RejectOnMatch": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
This means that when the header-key `api-key` (ignoring the casing) is missing the header mapping will match because `RejectOnMatch` is `true`.
|
||||||
|
|
||||||
# :two: Matchers
|
# :two: Matchers
|
||||||
The following paragraphs describe in detail which matchers can be used.
|
The following paragraphs describe in detail which matchers can be used.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user