mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 14:43:40 +02:00
fixes for Cookie and Header Reject on Match (#423)
This commit is contained in:
@@ -16,5 +16,15 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ignore case.
|
||||||
|
/// </summary>
|
||||||
|
public bool? IgnoreCase { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reject on match.
|
||||||
|
/// </summary>
|
||||||
|
public bool? RejectOnMatch { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,15 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ignore case.
|
||||||
|
/// </summary>
|
||||||
|
public bool? IgnoreCase { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reject on match.
|
||||||
|
/// </summary>
|
||||||
|
public bool? RejectOnMatch { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,14 +9,15 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The request cookie matcher.
|
/// The request cookie matcher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <inheritdoc cref="IRequestMatcher"/>
|
||||||
public class RequestMessageCookieMatcher : IRequestMatcher
|
public class RequestMessageCookieMatcher : IRequestMatcher
|
||||||
{
|
{
|
||||||
private readonly MatchBehaviour _matchBehaviour;
|
private readonly MatchBehaviour _matchBehaviour;
|
||||||
private readonly bool _ignoreCase;
|
private readonly bool _ignoreCase;
|
||||||
|
|
||||||
/// <value>
|
/// <summary>
|
||||||
/// The funcs.
|
/// The functions
|
||||||
/// </value>
|
/// </summary>
|
||||||
public Func<IDictionary<string, string>, bool>[] Funcs { get; }
|
public Func<IDictionary<string, string>, bool>[] Funcs { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,11 +33,11 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="pattern">The pattern.</param>
|
/// <param name="pattern">The pattern.</param>
|
||||||
/// <param name="ignoreCase">The ignoreCase.</param>
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase = true)
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(pattern, nameof(pattern));
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
@@ -50,15 +51,32 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) :
|
||||||
|
this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray())
|
||||||
|
{
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="matchers">The matchers.</param>
|
/// <param name="matchers">The matchers.</param>
|
||||||
public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(matchers, nameof(matchers));
|
Check.NotNull(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_matchBehaviour = matchBehaviour;
|
||||||
Name = name;
|
Name = name;
|
||||||
Matchers = matchers;
|
Matchers = matchers;
|
||||||
|
_ignoreCase = ignoreCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -52,33 +52,32 @@ namespace WireMock.Matchers.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="patterns">The patterns.</param>
|
/// <param name="patterns">The patterns.</param>
|
||||||
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params string[] patterns) :
|
||||||
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string[] patterns, bool ignoreCase)
|
this(matchBehaviour, name, ignoreCase, patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray())
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(patterns, nameof(patterns));
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
_matchBehaviour = matchBehaviour;
|
|
||||||
_ignoreCase = ignoreCase;
|
|
||||||
Name = name;
|
|
||||||
Matchers = patterns.Select(pattern => new WildcardMatcher(matchBehaviour, pattern, ignoreCase)).Cast<IStringMatcher>().ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
/// Initializes a new instance of the <see cref="RequestMessageHeaderMatcher"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
/// <param name="name">The name.</param>
|
/// <param name="name">The name.</param>
|
||||||
/// <param name="matchers">The matchers.</param>
|
/// <param name="matchers">The matchers.</param>
|
||||||
public RequestMessageHeaderMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
public RequestMessageHeaderMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers)
|
||||||
{
|
{
|
||||||
Check.NotNull(name, nameof(name));
|
Check.NotNull(name, nameof(name));
|
||||||
Check.NotNull(matchers, nameof(matchers));
|
Check.NotNull(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_matchBehaviour = matchBehaviour;
|
||||||
Name = name;
|
Name = name;
|
||||||
Matchers = matchers;
|
Matchers = matchers;
|
||||||
|
_ignoreCase = ignoreCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -125,7 +124,7 @@ namespace WireMock.Matchers.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
WireMockList<string> list = headers[Name];
|
WireMockList<string> list = headers[Name];
|
||||||
return Matchers.Max(m => list.Max(value => m.IsMatch(value))); // TODO : is this correct ?
|
return Matchers.Max(m => list.Max(m.IsMatch)); // TODO : is this correct ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
85
src/WireMock.Net/RequestBuilders/ICookiesRequestBuilder.cs
Normal file
85
src/WireMock.Net/RequestBuilders/ICookiesRequestBuilder.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The CookieRequestBuilder interface.
|
||||||
|
/// </summary>
|
||||||
|
public interface ICookiesRequestBuilder : IParamsRequestBuilder
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, pattern and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="pattern">The pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string pattern, MatchBehaviour matchBehaviour);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, pattern, ignoreCase and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="pattern">The pattern.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, patterns and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string[] patterns, MatchBehaviour matchBehaviour);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, patterns, ignoreCase and matchBehaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="patterns">The patterns.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, ignoreCase and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the cookie-keys.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on name, ignoreCase, matchBehaviour and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the cookie-keys.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] string name, bool ignoreCase, MatchBehaviour matchBehaviour, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithCookie: matching based on functions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="funcs">The cookies funcs.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,9 +6,9 @@ using WireMock.Matchers;
|
|||||||
namespace WireMock.RequestBuilders
|
namespace WireMock.RequestBuilders
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The HeadersAndCookieRequestBuilder interface.
|
/// The HeadersRequestBuilder interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHeadersAndCookiesRequestBuilder : IParamsRequestBuilder
|
public interface IHeadersRequestBuilder : ICookiesRequestBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithHeader: matching based on name, pattern and matchBehaviour.
|
/// WithHeader: matching based on name, pattern and matchBehaviour.
|
||||||
@@ -56,36 +56,30 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithHeader([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
IRequestBuilder WithHeader([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithHeader: matching based on name, ignoreCase and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the header-keys.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithHeader([NotNull] string name, bool ignoreCase, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WithHeader: matching based on name, ignoreCase, matchBehaviour and IStringMatcher[].
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">The name.</param>
|
||||||
|
/// <param name="ignoreCase">Ignore the case from the header-keys.</param>
|
||||||
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
||||||
|
/// <param name="matchers">The matchers.</param>
|
||||||
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
|
IRequestBuilder WithHeader([NotNull] string name, bool ignoreCase, MatchBehaviour matchBehaviour, [NotNull] params IStringMatcher[] matchers);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithHeader: matching based on functions.
|
/// WithHeader: matching based on functions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="funcs">The headers funcs.</param>
|
/// <param name="funcs">The headers funcs.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithHeader([NotNull] params Func<IDictionary<string, string[]>, bool>[] funcs);
|
IRequestBuilder WithHeader([NotNull] params Func<IDictionary<string, string[]>, bool>[] funcs);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: cookie matching based on name, pattern, ignoreCase and matchBehaviour.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="pattern">The pattern.</param>
|
|
||||||
/// <param name="ignoreCase">Ignore the case from the pattern.</param>
|
|
||||||
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: matching based on name and IStringMatcher[].
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">The name.</param>
|
|
||||||
/// <param name="matchers">The matchers.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] string name, [NotNull] params IStringMatcher[] matchers);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WithCookie: matching based on functions.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="funcs">The funcs.</param>
|
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
|
||||||
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The MethodRequestBuilder interface.
|
/// The MethodRequestBuilder interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IMethodRequestBuilder : IHeadersAndCookiesRequestBuilder
|
public interface IMethodRequestBuilder : IHeadersRequestBuilder
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UsingDelete: add HTTP Method matching on `DELETE` and matchBehaviour (optional).
|
/// UsingDelete: add HTTP Method matching on `DELETE` and matchBehaviour (optional).
|
||||||
|
|||||||
82
src/WireMock.Net/RequestBuilders/Request.WithCookies.cs
Normal file
82
src/WireMock.Net/RequestBuilders/Request.WithCookies.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
public partial class Request
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string pattern, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithCookie(name, pattern, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithCookie(name, patterns, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, patterns));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, bool, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/>
|
||||||
|
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
||||||
|
{
|
||||||
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs
Normal file
82
src/WireMock.Net/RequestBuilders/Request.WithHeaders.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using WireMock.Matchers;
|
||||||
|
using WireMock.Matchers.Request;
|
||||||
|
using WireMock.Validation;
|
||||||
|
|
||||||
|
namespace WireMock.RequestBuilders
|
||||||
|
{
|
||||||
|
public partial class Request
|
||||||
|
{
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string pattern, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithHeader(name, pattern, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string, bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(pattern, nameof(pattern));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string[], MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
||||||
|
{
|
||||||
|
return WithHeader(name, patterns, true, matchBehaviour);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, string[], bool, MatchBehaviour)"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNull(patterns, nameof(patterns));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, patterns));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, bool, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, bool ignoreCase, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
||||||
|
public IRequestBuilder WithHeader(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers)
|
||||||
|
{
|
||||||
|
Check.NotNull(name, nameof(name));
|
||||||
|
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, ignoreCase, matchers));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc cref="IHeadersRequestBuilder.WithHeader(Func{IDictionary{string, string[]}, bool}[])"/>
|
||||||
|
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
||||||
|
{
|
||||||
|
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
||||||
|
|
||||||
|
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -232,81 +232,5 @@ namespace WireMock.RequestBuilders
|
|||||||
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods));
|
_requestMatchers.Add(new RequestMessageMethodMatcher(matchBehaviour, methods));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string pattern, MatchBehaviour matchBehaviour)
|
|
||||||
{
|
|
||||||
return WithHeader(name, pattern, true, matchBehaviour);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string, bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(pattern, nameof(pattern));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, pattern, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
|
||||||
{
|
|
||||||
return WithHeader(name, patterns, true, matchBehaviour);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, string[], bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNull(patterns, nameof(patterns));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(matchBehaviour, name, patterns, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(string, IStringMatcher[])"/>
|
|
||||||
public IRequestBuilder WithHeader(string name, params IStringMatcher[] matchers)
|
|
||||||
{
|
|
||||||
Check.NotNull(name, nameof(name));
|
|
||||||
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(name, matchers));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithHeader(Func{IDictionary{string, string[]}, bool}[])"/>
|
|
||||||
public IRequestBuilder WithHeader(params Func<IDictionary<string, string[]>, bool>[] funcs)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageHeaderMatcher(funcs));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/>
|
|
||||||
public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
||||||
{
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
|
||||||
public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(matchers, nameof(matchers));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(name, matchers));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc cref="IHeadersAndCookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/>
|
|
||||||
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
|
||||||
{
|
|
||||||
Check.NotNullOrEmpty(funcs, nameof(funcs));
|
|
||||||
|
|
||||||
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -797,7 +797,12 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null))
|
foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null))
|
||||||
{
|
{
|
||||||
requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
requestBuilder = requestBuilder.WithHeader(
|
||||||
|
headerModel.Name,
|
||||||
|
headerModel.IgnoreCase == true,
|
||||||
|
headerModel.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch,
|
||||||
|
headerModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,7 +810,11 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null))
|
foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null))
|
||||||
{
|
{
|
||||||
requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
requestBuilder = requestBuilder.WithCookie(
|
||||||
|
cookieModel.Name,
|
||||||
|
cookieModel.IgnoreCase == true,
|
||||||
|
cookieModel.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch,
|
||||||
|
cookieModel.Matchers.Select(_matcherMapper.Map).OfType<IStringMatcher>().ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1");
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1");
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "c", "x");
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "c", false, "x");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
@@ -29,38 +29,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
{
|
{
|
||||||
// Assign
|
// Assign
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1");
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1");
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "c", "x");
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "c", false, "x");
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = new RequestMatchResult();
|
|
||||||
double score = matcher.GetMatchingScore(requestMessage, result);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Check.That(score).IsEqualTo(1.0d);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public void RequestMessageCookieMatcher_GetMatchingScore_AcceptOnMatch_CookieDoesNotMatchPattern()
|
|
||||||
{
|
|
||||||
// Assign
|
|
||||||
var cookies = new Dictionary<string, string> { { "c", "x" } };
|
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "no-match", "123");
|
|
||||||
|
|
||||||
// Act
|
|
||||||
var result = new RequestMatchResult();
|
|
||||||
double score = matcher.GetMatchingScore(requestMessage, result);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
Check.That(score).IsEqualTo(0.0d);
|
|
||||||
}
|
|
||||||
[Fact]
|
|
||||||
public void RequestMessageCookieMatcher_GetMatchingScore_RejectOnMatch_CookieDoesNotMatchPattern()
|
|
||||||
{
|
|
||||||
// Assign
|
|
||||||
var cookies = new Dictionary<string, string> { { "h", "x" } };
|
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "no-match", "123");
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
@@ -76,7 +45,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
// Assign
|
// Assign
|
||||||
var cookies = new Dictionary<string, string> { { "h", "x" } };
|
var cookies = new Dictionary<string, string> { { "h", "x" } };
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "h", "x");
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "h", false, "x");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
@@ -92,7 +61,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
// Assign
|
// Assign
|
||||||
var cookies = new Dictionary<string, string> { { "h", "x" } };
|
var cookies = new Dictionary<string, string> { { "h", "x" } };
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
||||||
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "h", "x");
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "h", false, "x");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
@@ -108,7 +77,23 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
// Assign
|
// Assign
|
||||||
var cookies = new Dictionary<string, string> { { "cook", "x" } };
|
var cookies = new Dictionary<string, string> { { "cook", "x" } };
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
||||||
var matcher = new RequestMessageCookieMatcher("cook", new ExactMatcher("x"));
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, "cook", false, new ExactMatcher("x"));
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var result = new RequestMatchResult();
|
||||||
|
double score = matcher.GetMatchingScore(requestMessage, result);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Check.That(score).IsEqualTo(1.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void RequestMessageCookieMatcher_WithMissingCookie_When_RejectOnMatch_Is_True_Should_Match()
|
||||||
|
{
|
||||||
|
// Assign
|
||||||
|
var cookies = new Dictionary<string, string> { { "cook", "x" } };
|
||||||
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, null, cookies);
|
||||||
|
var matcher = new RequestMessageCookieMatcher(MatchBehaviour.RejectOnMatch, "uhuh", false, new ExactMatcher("x"));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace WireMock.Net.Tests.RequestMatchers
|
|||||||
// Assign
|
// Assign
|
||||||
var headers = new Dictionary<string, string[]> { { "h", new[] { "x" } } };
|
var headers = new Dictionary<string, string[]> { { "h", new[] { "x" } } };
|
||||||
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, headers);
|
var requestMessage = new RequestMessage(new UrlDetails("http://localhost"), "GET", "127.0.0.1", null, headers);
|
||||||
var matcher = new RequestMessageHeaderMatcher("h", new ExactMatcher("x"));
|
var matcher = new RequestMessageHeaderMatcher(MatchBehaviour.AcceptOnMatch, "h", false, new ExactMatcher("x"));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = new RequestMatchResult();
|
var result = new RequestMatchResult();
|
||||||
|
|||||||
Reference in New Issue
Block a user