From 42f7d3974e03d024a7b367a8697065dd3fa237b9 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Thu, 23 Mar 2023 21:51:43 +0100 Subject: [PATCH] Updated Request Matching (markdown) --- Request-Matching.md | 51 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/Request-Matching.md b/Request-Matching.md index dcec8b1..c39c9c0 100644 --- a/Request-Matching.md +++ b/Request-Matching.md @@ -4,11 +4,17 @@ WireMock.Net supports matching of requests to stubs and verification queries usi * Path * URL * HTTP Method -* Query parameters -* Headers +* [Query parameters](#query-parameters) +* [Headers](#headers) * Cookies * 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 ### 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 The following paragraphs describe in detail which matchers can be used.