mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-21 00:11:44 +02:00
#endif
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using WireMock.Handlers;
|
using WireMock.Handlers;
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
|
|
||||||
@@ -123,7 +122,6 @@ public class SettingsModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<string, string[]>? ProtoDefinitions { get; set; }
|
public Dictionary<string, string[]>? ProtoDefinitions { get; set; }
|
||||||
|
|
||||||
//#if NETSTANDARD1_3_OR_GREATER || NET461
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Server client certificate mode
|
/// Server client certificate mode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -133,5 +131,4 @@ public class SettingsModel
|
|||||||
/// Whether to accept any client certificate
|
/// Whether to accept any client certificate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AcceptAnyClientCertificate { get; set; }
|
public bool AcceptAnyClientCertificate { get; set; }
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
@@ -3,9 +3,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
//#if NETSTANDARD1_3_OR_GREATER || NET461
|
|
||||||
//using System.Security.Cryptography.X509Certificates;
|
|
||||||
//#endif
|
|
||||||
using WireMock.Types;
|
using WireMock.Types;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
|
|
||||||
@@ -119,13 +116,11 @@ public interface IRequestMessage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
byte[]? BodyAsBytes { get; }
|
byte[]? BodyAsBytes { get; }
|
||||||
|
|
||||||
//#if MIMEKIT
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The original body as MimeMessage.
|
/// The original body as MimeMessage.
|
||||||
/// Convenience getter for Handlebars and WireMockAssertions.
|
/// Convenience getter for Handlebars and WireMockAssertions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Models.Mime.IMimeMessageData? BodyAsMimeMessage { get; }
|
Models.Mime.IMimeMessageData? BodyAsMimeMessage { get; }
|
||||||
//#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The detected body type. Convenience getter for Handlebars.
|
/// The detected body type. Convenience getter for Handlebars.
|
||||||
@@ -170,10 +165,8 @@ public interface IRequestMessage
|
|||||||
/// <returns>The query parameter value as WireMockList or null when not found.</returns>
|
/// <returns>The query parameter value as WireMockList or null when not found.</returns>
|
||||||
WireMockList<string>? GetParameter(string key, bool ignoreCase = false);
|
WireMockList<string>? GetParameter(string key, bool ignoreCase = false);
|
||||||
|
|
||||||
//#if NETSTANDARD1_3_OR_GREATER || NET461
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the connection's client certificate
|
/// Gets the connection's client certificate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
X509Certificate2? ClientCertificate { get; }
|
X509Certificate2? ClientCertificate { get; }
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace WireMock.Types;
|
namespace WireMock.Types;
|
||||||
|
|
||||||
//#if NETSTANDARD1_3_OR_GREATER || NET461
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes the client certificate requirements for a HTTPS connection.
|
/// Describes the client certificate requirements for a HTTPS connection.
|
||||||
/// This enum is the same as https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.https.clientcertificatemode
|
/// This enum is the same as https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.https.clientcertificatemode
|
||||||
@@ -29,5 +28,4 @@ public enum ClientCertificateMode
|
|||||||
/// It may be requested by the application later.
|
/// It may be requested by the application later.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DelayCertificate,
|
DelayCertificate,
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
//#if !NETSTANDARD1_3
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
@@ -111,5 +110,4 @@ internal class AzureADAuthenticationMatcher : IStringMatcher
|
|||||||
tenant = null;
|
tenant = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
@@ -56,10 +56,8 @@ internal static class HttpClientBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if !NETSTANDARD1_3
|
|
||||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
|
||||||
ServicePointManager.ServerCertificateValidationCallback = (message, cert, chain, errors) => true;
|
ServicePointManager.ServerCertificateValidationCallback = (message, cert, chain, errors) => true;
|
||||||
//#endif
|
|
||||||
|
|
||||||
return HttpClientFactory2.Create(handler);
|
return HttpClientFactory2.Create(handler);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,11 +43,8 @@ internal static class CertificateLoader
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
//#if NETSTANDARD || NET48
|
|
||||||
certStore.Dispose();
|
certStore.Dispose();
|
||||||
//#else
|
|
||||||
certStore.Close();
|
certStore.Close();
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +110,8 @@ internal static class CertificateLoader
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
//#if NETSTANDARD || NET46
|
|
||||||
certStore.Dispose();
|
certStore.Dispose();
|
||||||
//#else
|
|
||||||
certStore.Close();
|
certStore.Close();
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,9 +11,7 @@ using WireMock.Models;
|
|||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
//#if !NETSTANDARD1_3
|
|
||||||
using Wmhelp.XPath2;
|
using Wmhelp.XPath2;
|
||||||
//#endif
|
|
||||||
|
|
||||||
namespace WireMock.Matchers;
|
namespace WireMock.Matchers;
|
||||||
|
|
||||||
@@ -135,7 +133,7 @@ public class XPathMatcher : IStringMatcher
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
_xmlDocument = default;
|
_xmlDocument = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,25 +149,17 @@ public class XPathMatcher : IStringMatcher
|
|||||||
var xmlNamespaceManager = GetXmlNamespaceManager(xmlNamespaceMap);
|
var xmlNamespaceManager = GetXmlNamespaceManager(xmlNamespaceMap);
|
||||||
if (xmlNamespaceManager == null)
|
if (xmlNamespaceManager == null)
|
||||||
{
|
{
|
||||||
//#if NETSTANDARD1_3
|
|
||||||
//return navigator.Evaluate(xpath);
|
|
||||||
//#else
|
|
||||||
return navigator.XPath2Evaluate(xpath);
|
return navigator.XPath2Evaluate(xpath);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if NETSTANDARD1_3
|
|
||||||
//return navigator.Evaluate(xpath, xmlNamespaceManager);
|
|
||||||
//#else
|
|
||||||
return navigator.XPath2Evaluate(xpath, xmlNamespaceManager);
|
return navigator.XPath2Evaluate(xpath, xmlNamespaceManager);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private XmlNamespaceManager? GetXmlNamespaceManager(IEnumerable<XmlNamespace>? xmlNamespaceMap)
|
private XmlNamespaceManager? GetXmlNamespaceManager(IEnumerable<XmlNamespace>? xmlNamespaceMap)
|
||||||
{
|
{
|
||||||
if (_xpathNavigator == null || xmlNamespaceMap == null)
|
if (_xpathNavigator == null || xmlNamespaceMap == null)
|
||||||
{
|
{
|
||||||
return default;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nsManager = new XmlNamespaceManager(_xpathNavigator.NameTable);
|
var nsManager = new XmlNamespaceManager(_xpathNavigator.NameTable);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
//#if USE_ASPNETCORE && !NETSTANDARD1_3
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@@ -116,5 +115,4 @@ internal static class IWebHostBuilderExtensions
|
|||||||
services.Configure<KestrelServerOptions>(context.Configuration.GetSection("Kestrel"));
|
services.Configure<KestrelServerOptions>(context.Configuration.GetSection("Kestrel"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// Copyright © WireMock.Net
|
// Copyright © WireMock.Net
|
||||||
|
|
||||||
//#if USE_ASPNETCORE
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -96,10 +95,6 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
|||||||
SetHttpsAndUrls(options, _wireMockMiddlewareOptions, _urlOptions.GetDetails());
|
SetHttpsAndUrls(options, _wireMockMiddlewareOptions, _urlOptions.GetDetails());
|
||||||
})
|
})
|
||||||
.ConfigureKestrelServerOptions()
|
.ConfigureKestrelServerOptions()
|
||||||
|
|
||||||
//#if NETSTANDARD1_3
|
|
||||||
// .UseUrls(_urlOptions.GetDetails().Select(u => u.Url).ToArray())
|
|
||||||
//#endif
|
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return RunHost(_cts.Token);
|
return RunHost(_cts.Token);
|
||||||
@@ -137,14 +132,7 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
|||||||
_logger.Info("Server using .NET Framework 4.8");
|
_logger.Info("Server using .NET Framework 4.8");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#if NETSTANDARD1_3
|
|
||||||
// return Task.Run(() =>
|
|
||||||
// {
|
|
||||||
// _host.Run(token);
|
|
||||||
// });
|
|
||||||
//#else
|
|
||||||
return _host.RunAsync(token);
|
return _host.RunAsync(token);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -162,11 +150,6 @@ internal partial class AspNetCoreSelfHost : IOwinSelfHost
|
|||||||
_cts.Cancel();
|
_cts.Cancel();
|
||||||
|
|
||||||
IsStarted = false;
|
IsStarted = false;
|
||||||
//#if NETSTANDARD1_3
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
//#else
|
|
||||||
return _host.StopAsync();
|
return _host.StopAsync();
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
@@ -6,49 +6,24 @@ using Newtonsoft.Json;
|
|||||||
using WireMock.Owin.Mappers;
|
using WireMock.Owin.Mappers;
|
||||||
using Stef.Validation;
|
using Stef.Validation;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
//#if !USE_ASPNETCORE
|
|
||||||
//using Microsoft.Owin;
|
|
||||||
//using IContext = Microsoft.Owin.IOwinContext;
|
|
||||||
//using OwinMiddleware = Microsoft.Owin.OwinMiddleware;
|
|
||||||
//using Next = Microsoft.Owin.OwinMiddleware;
|
|
||||||
//#else
|
|
||||||
//using OwinMiddleware = System.Object;
|
|
||||||
//using IContext = Microsoft.AspNetCore.Http.HttpContext;
|
|
||||||
//using Next = Microsoft.AspNetCore.Http.RequestDelegate;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace WireMock.Owin;
|
namespace WireMock.Owin;
|
||||||
|
|
||||||
internal class GlobalExceptionMiddleware //: OwinMiddleware
|
internal class GlobalExceptionMiddleware
|
||||||
{
|
{
|
||||||
private readonly IWireMockMiddlewareOptions _options;
|
private readonly IWireMockMiddlewareOptions _options;
|
||||||
private readonly IOwinResponseMapper _responseMapper;
|
private readonly IOwinResponseMapper _responseMapper;
|
||||||
|
|
||||||
//#if !USE_ASPNETCORE
|
|
||||||
// public GlobalExceptionMiddleware(Next next, IWireMockMiddlewareOptions options, IOwinResponseMapper responseMapper) : base(next)
|
|
||||||
// {
|
|
||||||
// _options = Guard.NotNull(options);
|
|
||||||
// _responseMapper = Guard.NotNull(responseMapper);;
|
|
||||||
// }
|
|
||||||
//#else
|
|
||||||
public GlobalExceptionMiddleware(RequestDelegate next, IWireMockMiddlewareOptions options, IOwinResponseMapper responseMapper)
|
public GlobalExceptionMiddleware(RequestDelegate next, IWireMockMiddlewareOptions options, IOwinResponseMapper responseMapper)
|
||||||
{
|
{
|
||||||
Next = next;
|
Next = next;
|
||||||
_options = Guard.NotNull(options);
|
_options = Guard.NotNull(options);
|
||||||
_responseMapper = Guard.NotNull(responseMapper);
|
_responseMapper = Guard.NotNull(responseMapper);
|
||||||
}
|
}
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if USE_ASPNETCORE
|
|
||||||
public RequestDelegate? Next { get; }
|
public RequestDelegate? Next { get; }
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#if !USE_ASPNETCORE
|
|
||||||
// public override Task Invoke(IContext ctx)
|
|
||||||
//#else
|
|
||||||
public Task Invoke(HttpContext ctx)
|
public Task Invoke(HttpContext ctx)
|
||||||
//#endif
|
|
||||||
{
|
{
|
||||||
return InvokeInternalAsync(ctx);
|
return InvokeInternalAsync(ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,11 +295,9 @@ public partial class WireMockServer
|
|||||||
WatchStaticMappings = _settings.WatchStaticMappings,
|
WatchStaticMappings = _settings.WatchStaticMappings,
|
||||||
WatchStaticMappingsInSubdirectories = _settings.WatchStaticMappingsInSubdirectories,
|
WatchStaticMappingsInSubdirectories = _settings.WatchStaticMappingsInSubdirectories,
|
||||||
|
|
||||||
//#if USE_ASPNETCORE
|
|
||||||
AcceptAnyClientCertificate = _settings.AcceptAnyClientCertificate,
|
AcceptAnyClientCertificate = _settings.AcceptAnyClientCertificate,
|
||||||
ClientCertificateMode = _settings.ClientCertificateMode,
|
ClientCertificateMode = _settings.ClientCertificateMode,
|
||||||
CorsPolicyOptions = _settings.CorsPolicyOptions?.ToString()
|
CorsPolicyOptions = _settings.CorsPolicyOptions?.ToString()
|
||||||
//#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
model.ProxyAndRecordSettings = TinyMapperUtils.Instance.Map(_settings.ProxyAndRecordSettings);
|
model.ProxyAndRecordSettings = TinyMapperUtils.Instance.Map(_settings.ProxyAndRecordSettings);
|
||||||
|
|||||||
Reference in New Issue
Block a user