mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-05-28 10:49:14 +02:00
x
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Security.Authentication;
|
||||
using WireMock.HttpsCertificate;
|
||||
using WireMock.Settings;
|
||||
|
||||
@@ -12,10 +13,13 @@ internal static class HttpClientBuilder
|
||||
public static HttpClient Build(HttpClientSettings settings)
|
||||
{
|
||||
#if NET8_0_OR_GREATER
|
||||
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
CheckCertificateRevocationList = false,
|
||||
SslProtocols = System.Security.Authentication.SslProtocols.Tls13 | System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls11 | System.Security.Authentication.SslProtocols.Tls,
|
||||
#pragma warning disable SYSLIB0039 // Type or member is obsolete
|
||||
SslProtocols = SslProtocols.Tls13 | SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls,
|
||||
#pragma warning restore SYSLIB0039 // Type or member is obsolete
|
||||
ServerCertificateCustomValidationCallback = (_, _, _, _) => true,
|
||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ internal static class CertificateLoader
|
||||
|
||||
if (!string.IsNullOrEmpty(options.X509CertificateFilePath))
|
||||
{
|
||||
if (options.X509CertificateFilePath.EndsWith(ExtensionPem, StringComparison.OrdinalIgnoreCase))
|
||||
if (options.X509CertificateFilePath!.EndsWith(ExtensionPem, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// PEM logic based on: https://www.scottbrady91.com/c-sharp/pem-loading-in-dotnet-core-and-dotnet
|
||||
#if NET8_0_OR_GREATER
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace WireMock.Owin;
|
||||
|
||||
internal class WireMockMiddlewareOptions : IWireMockMiddlewareOptions
|
||||
{
|
||||
public IWireMockLogger Logger { get; set; }
|
||||
public IWireMockLogger Logger { get; set; } = new WireMockConsoleLogger();
|
||||
|
||||
public TimeSpan? RequestProcessingDelay { get; set; }
|
||||
|
||||
|
||||
@@ -586,7 +586,7 @@ public partial class WireMockServer
|
||||
{
|
||||
if (TryParseGuidFromRequestMessage(requestMessage, out var guid))
|
||||
{
|
||||
var entry = LogEntries.SingleOrDefault(r => !r.RequestMessage.Path.StartsWith("/__admin/") && r.Guid == guid);
|
||||
var entry = LogEntries.SingleOrDefault(r => r.RequestMessage != null && !r.RequestMessage.Path.StartsWith("/__admin/") && r.Guid == guid);
|
||||
if (entry is { })
|
||||
{
|
||||
var model = new LogEntryMapper(_options).Map(entry);
|
||||
@@ -615,7 +615,7 @@ public partial class WireMockServer
|
||||
{
|
||||
var logEntryMapper = new LogEntryMapper(_options);
|
||||
var result = LogEntries
|
||||
.Where(r => !r.RequestMessage.Path.StartsWith("/__admin/"))
|
||||
.Where(r => r.RequestMessage != null && !r.RequestMessage.Path.StartsWith("/__admin/"))
|
||||
.Select(logEntryMapper.Map);
|
||||
|
||||
return ToJson(result);
|
||||
@@ -637,10 +637,10 @@ public partial class WireMockServer
|
||||
var request = (Request)InitRequestBuilder(requestModel);
|
||||
|
||||
var dict = new Dictionary<ILogEntry, RequestMatchResult>();
|
||||
foreach (var logEntry in LogEntries.Where(le => !le.RequestMessage.Path.StartsWith("/__admin/")))
|
||||
foreach (var logEntry in LogEntries.Where(le => le.RequestMessage != null && !le.RequestMessage.Path.StartsWith("/__admin/")))
|
||||
{
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
if (request.GetMatchingScore(logEntry.RequestMessage, requestMatchResult) > MatchScores.AlmostPerfect)
|
||||
if (request.GetMatchingScore(logEntry.RequestMessage!, requestMatchResult) > MatchScores.AlmostPerfect)
|
||||
{
|
||||
dict.Add(logEntry, requestMatchResult);
|
||||
}
|
||||
@@ -659,7 +659,7 @@ public partial class WireMockServer
|
||||
Guid.TryParse(value.ToString(), out var mappingGuid)
|
||||
)
|
||||
{
|
||||
var logEntries = LogEntries.Where(le => !le.RequestMessage.Path.StartsWith("/__admin/") && le.MappingGuid == mappingGuid);
|
||||
var logEntries = LogEntries.Where(le => le.RequestMessage != null && !le.RequestMessage.Path.StartsWith("/__admin/") && le.MappingGuid == mappingGuid);
|
||||
var logEntryMapper = new LogEntryMapper(_options);
|
||||
var result = logEntries.Select(logEntryMapper.Map);
|
||||
return ToJson(result);
|
||||
|
||||
@@ -4,66 +4,65 @@ using Scriban;
|
||||
using Scriban.Parsing;
|
||||
using Scriban.Runtime;
|
||||
|
||||
namespace WireMock.Transformers.Scriban
|
||||
namespace WireMock.Transformers.Scriban;
|
||||
|
||||
internal class WireMockListAccessor : IListAccessor, IObjectAccessor
|
||||
{
|
||||
internal class WireMockListAccessor : IListAccessor, IObjectAccessor
|
||||
#region IListAccessor
|
||||
public int GetLength(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
#region IListAccessor
|
||||
public int GetLength(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object GetValue(TemplateContext context, SourceSpan span, object target, int index)
|
||||
{
|
||||
return target.ToString();
|
||||
}
|
||||
|
||||
public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IObjectAccessor
|
||||
public int GetMemberCount(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetMembers(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HasMember(TemplateContext context, SourceSpan span, object target, string member)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetValue(TemplateContext context, SourceSpan span, object target, string member, out object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(TemplateContext context, SourceSpan span, object target, string member, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetItem(TemplateContext context, SourceSpan span, object target, object index, out object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetItem(TemplateContext context, SourceSpan span, object target, object index, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HasIndexer => throw new NotImplementedException();
|
||||
|
||||
public Type IndexType => throw new NotImplementedException();
|
||||
#endregion
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object GetValue(TemplateContext context, SourceSpan span, object target, int index)
|
||||
{
|
||||
return target?.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
public void SetValue(TemplateContext context, SourceSpan span, object target, int index, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IObjectAccessor
|
||||
public int GetMemberCount(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetMembers(TemplateContext context, SourceSpan span, object target)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HasMember(TemplateContext context, SourceSpan span, object target, string member)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetValue(TemplateContext context, SourceSpan span, object target, string member, out object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetValue(TemplateContext context, SourceSpan span, object target, string member, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TryGetItem(TemplateContext context, SourceSpan span, object target, object index, out object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool TrySetItem(TemplateContext context, SourceSpan span, object target, object index, object value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HasIndexer => throw new NotImplementedException();
|
||||
|
||||
public Type IndexType => throw new NotImplementedException();
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user