This commit is contained in:
Stef Heyenrath
2026-02-14 11:41:25 +01:00
parent 99f42fb255
commit 6cc18e796c
55 changed files with 164 additions and 398 deletions

View File

@@ -1,14 +1,7 @@
// Copyright © WireMock.Net
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
//#if !USE_ASPNETCORE
//using IResponse = Microsoft.Owin.IOwinResponse;
//#else
//using IResponse = Microsoft.AspNetCore.Http.HttpResponse;
//#endif
namespace WireMock.Owin.Mappers;
/// <summary>

View File

@@ -2,14 +2,9 @@
// This source file is based on mock4net by Alexandre Victoor which is licensed under the Apache 2.0 License.
// For more details see 'mock4net/LICENSE.txt' and 'mock4net/readme.md' in this project root.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
//#if USE_ASPNETCORE
//using System.Security.Cryptography.X509Certificates;
//#endif
using System.Text.Json.Serialization;
using Stef.Validation;
using WireMock.Models;
using WireMock.Owin;
@@ -83,11 +78,10 @@ public class RequestMessage : IRequestMessage
/// <inheritdoc />
public byte[]? BodyAsBytes { get; }
//#if MIMEKIT
/// <inheritdoc />
[Newtonsoft.Json.JsonIgnore] // Issue 1001
[JsonIgnore]
public Models.Mime.IMimeMessageData? BodyAsMimeMessage { get; }
//#endif
/// <inheritdoc />
public string? DetectedBodyType { get; }
@@ -110,10 +104,8 @@ public class RequestMessage : IRequestMessage
/// <inheritdoc />
public string Origin { get; }
//#if USE_ASPNETCORE
/// <inheritdoc />
public X509Certificate2? ClientCertificate { get; }
//#endif
/// <summary>
/// Used for Unit Testing
@@ -136,10 +128,8 @@ public class RequestMessage : IRequestMessage
IBodyData? bodyData = null,
IDictionary<string, string[]>? headers = null,
IDictionary<string, string>? cookies = null,
string httpVersion = "1.1"
//#if USE_ASPNETCORE
, X509Certificate2? clientCertificate = null
//#endif
string httpVersion = "1.1",
X509Certificate2? clientCertificate = null
)
{
Guard.NotNull(urlDetails);
@@ -179,16 +169,11 @@ public class RequestMessage : IRequestMessage
Query = QueryStringParser.Parse(RawQuery, options?.QueryParameterMultipleValueSupport);
QueryIgnoreCase = new Dictionary<string, WireMockList<string>>(Query, StringComparer.OrdinalIgnoreCase);
//#if USE_ASPNETCORE
ClientCertificate = clientCertificate;
//#endif
//#if MIMEKIT
if (TypeLoader.TryLoadStaticInstance<IMimeKitUtils>(out var mimeKitUtils) && mimeKitUtils.TryGetMimeMessage(this, out var mimeMessage))
{
BodyAsMimeMessage = mimeMessage;
}
//#endif
}
/// <inheritdoc />

View File

@@ -218,7 +218,6 @@ internal class MatcherMapper
model.ContentTypeMatcher = Map(mimePartMatcher.ContentTypeMatcher);
break;
//#if PROTOBUF
case IProtoBufMatcher protoBufMatcher:
protoBufMatcher.ProtoDefinition().Value(id => model.Pattern = id, texts =>
{
@@ -235,7 +234,6 @@ internal class MatcherMapper
model.ProtoBufMessageType = protoBufMatcher.MessageType;
model.ContentMatcher = Map(protoBufMatcher.Matcher);
break;
//#endif
}
afterMap?.Invoke(model);

View File

@@ -330,12 +330,10 @@ public partial class WireMockServer
InitSettings(_settings);
//#if USE_ASPNETCORE
if (Enum.TryParse<CorsPolicyOptions>(settings.CorsPolicyOptions, true, out var corsPolicyOptions))
{
_settings.CorsPolicyOptions = corsPolicyOptions;
}
//#endif
WireMockMiddlewareOptionsHelper.InitFromSettings(_settings, _options, o =>
{
@@ -344,11 +342,9 @@ public partial class WireMockServer
o.RequestProcessingDelay = TimeSpan.FromMilliseconds(settings.GlobalProcessingDelay.Value);
}
//#if USE_ASPNETCORE
o.CorsPolicyOptions = corsPolicyOptions;
o.ClientCertificateMode = (Microsoft.AspNetCore.Server.Kestrel.Https.ClientCertificateMode) _settings.ClientCertificateMode;
o.AcceptAnyClientCertificate = _settings.AcceptAnyClientCertificate;
//#endif
});
return ResponseMessageBuilder.Create(200, "Settings updated");

View File

@@ -24,7 +24,6 @@ internal static class WireMockHandlebarsHelpers
GetBaseDirectory(),
};
//#if !NETSTANDARD1_3_OR_GREATER
void Add(string? path, ICollection<string> customHelperPaths)
{
if (!string.IsNullOrEmpty(path))
@@ -36,7 +35,7 @@ internal static class WireMockHandlebarsHelpers
Add(Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location), paths);
Add(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), paths);
Add(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule?.FileName), paths);
//#endif
o.CustomHelperPaths = paths;
o.Categories = settings.HandlebarsSettings?.AllowedHandlebarsHelpers ?? HandlebarsSettings.DefaultAllowedHandlebarsHelpers;

View File

@@ -18,12 +18,11 @@ internal static class CultureInfoUtils
try
{
//#if !NETSTANDARD1_3
if (int.TryParse(value, out var culture))
{
return new CultureInfo(culture);
}
//#endif
if (string.Equals(value, nameof(CultureInfo.CurrentCulture), StringComparison.OrdinalIgnoreCase))
{
return CultureInfo.CurrentCulture;

View File

@@ -1,14 +1,8 @@
// Copyright © WireMock.Net
using System;
using Microsoft.AspNetCore.Http;
using WireMock.Models;
using Stef.Validation;
//#if !USE_ASPNETCORE
//using Microsoft.Owin;
//#else
//using Microsoft.AspNetCore.Http;
//#endif
namespace WireMock.Util;