mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-19 07:54:53 +01:00
Fix MappingModel to map IgnoreCase and RejectOnMatch for Headers, Cookies and Parameters (#1004)
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
{
|
||||
Guid: Guid_1,
|
||||
UpdatedAt: DateTime_1,
|
||||
Request: {
|
||||
Headers: [
|
||||
{
|
||||
Name: MatchBehaviour.RejectOnMatch,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: hv-1,
|
||||
IgnoreCase: true,
|
||||
RejectOnMatch: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true,
|
||||
RejectOnMatch: true
|
||||
},
|
||||
{
|
||||
Name: MatchBehaviour.AcceptOnMatch,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: hv-2,
|
||||
IgnoreCase: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_false,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: hv-3,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_true,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: hv-4,
|
||||
IgnoreCase: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true
|
||||
},
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Matchers: [
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: h-exact,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
Cookies: [
|
||||
{
|
||||
Name: MatchBehaviour.RejectOnMatch,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: cv-1,
|
||||
IgnoreCase: true,
|
||||
RejectOnMatch: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true,
|
||||
RejectOnMatch: true
|
||||
},
|
||||
{
|
||||
Name: MatchBehaviour.AcceptOnMatch,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: cv-2,
|
||||
IgnoreCase: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_false,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: cv-3,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_true,
|
||||
Matchers: [
|
||||
{
|
||||
Name: WildcardMatcher,
|
||||
Pattern: cv-4,
|
||||
IgnoreCase: true
|
||||
}
|
||||
],
|
||||
IgnoreCase: true
|
||||
},
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Matchers: [
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: c-exact,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
Response: {},
|
||||
UseWebhooksFireAndForget: false
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
Guid: Guid_1,
|
||||
UpdatedAt: DateTime_1,
|
||||
Request: {
|
||||
Params: [
|
||||
{
|
||||
Name: MatchBehaviour.RejectOnMatch,
|
||||
RejectOnMatch: true
|
||||
},
|
||||
{
|
||||
Name: MatchBehaviour.RejectOnMatch|IgnoreCase_false,
|
||||
RejectOnMatch: true
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_false,
|
||||
Matchers: [
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: pv-3a,
|
||||
IgnoreCase: false
|
||||
},
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: pv-3b,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Name: IgnoreCase_true,
|
||||
IgnoreCase: true,
|
||||
Matchers: [
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: pv-3a,
|
||||
IgnoreCase: true
|
||||
},
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: pv-3b,
|
||||
IgnoreCase: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Matchers: [
|
||||
{
|
||||
Name: ExactMatcher,
|
||||
Pattern: exact,
|
||||
IgnoreCase: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
Response: {},
|
||||
UseWebhooksFireAndForget: false
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using VerifyXunit;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Models;
|
||||
using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
@@ -362,6 +363,60 @@ public partial class MappingConverterTests
|
||||
return Verifier.Verify(model);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ToMappingModel_WithHeader_And_Cookie_ReturnsCorrectModel()
|
||||
{
|
||||
// Assign
|
||||
var request = Request.Create()
|
||||
.WithHeader("MatchBehaviour.RejectOnMatch", "hv-1", MatchBehaviour.RejectOnMatch)
|
||||
.WithHeader("MatchBehaviour.AcceptOnMatch", "hv-2", MatchBehaviour.AcceptOnMatch)
|
||||
.WithHeader("IgnoreCase_false", "hv-3", false)
|
||||
.WithHeader("IgnoreCase_true", "hv-4")
|
||||
.WithHeader("ExactMatcher", new ExactMatcher("h-exact"))
|
||||
|
||||
.WithCookie("MatchBehaviour.RejectOnMatch", "cv-1", MatchBehaviour.RejectOnMatch)
|
||||
.WithCookie("MatchBehaviour.AcceptOnMatch", "cv-2", MatchBehaviour.AcceptOnMatch)
|
||||
.WithCookie("IgnoreCase_false", "cv-3", false)
|
||||
.WithCookie("IgnoreCase_true", "cv-4")
|
||||
.WithCookie("ExactMatcher", new ExactMatcher("c-exact"))
|
||||
;
|
||||
var response = Response.Create();
|
||||
var mapping = new Mapping(_guid, _updatedAt, null, null, null, _settings, request, response, 0, null, null, null, null, null, false, null, data: null, probability: null);
|
||||
|
||||
// Act
|
||||
var model = _sut.ToMappingModel(mapping);
|
||||
|
||||
// Assert
|
||||
model.Should().NotBeNull();
|
||||
|
||||
// Verify
|
||||
return Verifier.Verify(model);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public Task ToMappingModel_WithParam_ReturnsCorrectModel()
|
||||
{
|
||||
// Assign
|
||||
var request = Request.Create()
|
||||
.WithParam("MatchBehaviour.RejectOnMatch", MatchBehaviour.RejectOnMatch)
|
||||
.WithParam("MatchBehaviour.RejectOnMatch|IgnoreCase_false", false, MatchBehaviour.RejectOnMatch)
|
||||
.WithParam("IgnoreCase_false", false, "pv-3a", "pv-3b")
|
||||
.WithParam("IgnoreCase_true", true, "pv-3a", "pv-3b")
|
||||
.WithParam("ExactMatcher", new ExactMatcher("exact"))
|
||||
;
|
||||
var response = Response.Create();
|
||||
var mapping = new Mapping(_guid, _updatedAt, null, null, null, _settings, request, response, 0, null, null, null, null, null, false, null, data: null, probability: null);
|
||||
|
||||
// Act
|
||||
var model = _sut.ToMappingModel(mapping);
|
||||
|
||||
// Assert
|
||||
model.Should().NotBeNull();
|
||||
|
||||
// Verify
|
||||
return Verifier.Verify(model);
|
||||
}
|
||||
|
||||
#if GRAPHQL
|
||||
[Fact]
|
||||
public Task ToMappingModel_Request_WithBodyAsGraphQLSchema_ReturnsCorrectModel()
|
||||
|
||||
Reference in New Issue
Block a user