mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-18 15:23:47 +01:00
FindLogEntries and refactored some code (#34)
This commit is contained in:
@@ -131,5 +131,12 @@ namespace WireMock.Client
|
||||
/// <param name="guid">The Guid</param>
|
||||
[Delete("__admin/requests/{guid}")]
|
||||
Task<string> DeleteRequestAsync([Path] Guid guid);
|
||||
|
||||
/// <summary>
|
||||
/// Find a request based on the criteria
|
||||
/// </summary>
|
||||
/// <param name="model">The RequestModel</param>
|
||||
[Post("__admin/requests/find")]
|
||||
Task<IList<LogRequestModel>> FindRequestsAsync([Body] RequestModel model);
|
||||
}
|
||||
}
|
||||
@@ -30,15 +30,12 @@ namespace WireMock.Http
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (certStore != null)
|
||||
{
|
||||
#if NETSTANDARD || NET46
|
||||
certStore.Dispose();
|
||||
certStore.Dispose();
|
||||
#else
|
||||
certStore.Close();
|
||||
certStore.Close();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace WireMock.Http
|
||||
{
|
||||
internal static class HttpClientHelper
|
||||
{
|
||||
|
||||
|
||||
private static HttpClient CreateHttpClient(string clientX509Certificate2ThumbprintOrSubjectName = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(clientX509Certificate2ThumbprintOrSubjectName))
|
||||
@@ -69,29 +69,22 @@ namespace WireMock.Http
|
||||
}
|
||||
|
||||
// Call the URL
|
||||
try
|
||||
var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
|
||||
|
||||
|
||||
// Transform response
|
||||
var responseMessage = new ResponseMessage
|
||||
{
|
||||
var httpResponseMessage = await client.SendAsync(httpRequestMessage, HttpCompletionOption.ResponseContentRead);
|
||||
StatusCode = (int)httpResponseMessage.StatusCode,
|
||||
Body = await httpResponseMessage.Content.ReadAsStringAsync()
|
||||
};
|
||||
|
||||
|
||||
// Transform response
|
||||
var responseMessage = new ResponseMessage
|
||||
{
|
||||
StatusCode = (int)httpResponseMessage.StatusCode,
|
||||
Body = await httpResponseMessage.Content.ReadAsStringAsync()
|
||||
};
|
||||
|
||||
foreach (var header in httpResponseMessage.Headers)
|
||||
{
|
||||
responseMessage.AddHeader(header.Key, header.Value.FirstOrDefault());
|
||||
}
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
catch(Exception ex)
|
||||
foreach (var header in httpResponseMessage.Headers)
|
||||
{
|
||||
throw ex;
|
||||
responseMessage.AddHeader(header.Key, header.Value.FirstOrDefault());
|
||||
}
|
||||
|
||||
return responseMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,12 +44,6 @@ namespace WireMock.Owin
|
||||
{
|
||||
StartServers();
|
||||
}, _cts.Token);
|
||||
|
||||
//if (_internalThread != null)
|
||||
// throw new InvalidOperationException("Cannot start a multiple threads.");
|
||||
|
||||
//_internalThread = new Thread(ThreadWorkInternal);
|
||||
//_internalThread.Start();
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
@@ -72,22 +66,6 @@ namespace WireMock.Owin
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private void ThreadWorkInternal()
|
||||
{
|
||||
try
|
||||
{
|
||||
StartServers();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_internalThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartServers()
|
||||
{
|
||||
Action<IAppBuilder> startup = app =>
|
||||
|
||||
@@ -7,19 +7,12 @@ namespace WireMock.ResponseBuilders
|
||||
/// </summary>
|
||||
public interface IProxyResponseBuilder : IStatusCodeResponseBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// With Proxy URL.
|
||||
/// </summary>
|
||||
/// <param name="proxyUrl">The proxy url.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
IResponseBuilder WithProxy([NotNull] string proxyUrl);
|
||||
|
||||
/// <summary>
|
||||
/// With Proxy URL using X509Certificate2.
|
||||
/// </summary>
|
||||
/// <param name="proxyUrl">The proxy url.</param>
|
||||
/// <param name="clientX509Certificate2ThumbprintOrSubjectName">The X509Certificate2 file to use for client authentication.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
IResponseBuilder WithProxy([NotNull] string proxyUrl, [CanBeNull] string clientX509Certificate2ThumbprintOrSubjectName);
|
||||
IResponseBuilder WithProxy([NotNull] string proxyUrl, [CanBeNull] string clientX509Certificate2ThumbprintOrSubjectName = null);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace WireMock.ResponseBuilders
|
||||
/// <summary>
|
||||
/// The client X509Certificate2 Thumbprint or SubjectName to use.
|
||||
/// </summary>
|
||||
public string X509Certificate2ThumbprintOrSubjectName { get; private set; }
|
||||
public string X509Certificate2ThumbprintOrSubjectName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the response message.
|
||||
@@ -241,30 +241,15 @@ namespace WireMock.ResponseBuilders
|
||||
return WithDelay(TimeSpan.FromMilliseconds(milliseconds));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// With Proxy URL.
|
||||
/// </summary>
|
||||
/// <param name="proxyUrl">The proxy url.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
[PublicAPI]
|
||||
public IResponseBuilder WithProxy([NotNull] string proxyUrl)
|
||||
{
|
||||
Check.NotEmpty(proxyUrl, nameof(proxyUrl));
|
||||
|
||||
ProxyUrl = proxyUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// With Proxy URL.
|
||||
/// </summary>
|
||||
/// <param name="proxyUrl">The proxy url.</param>
|
||||
/// <param name="clientX509Certificate2ThumbprintOrSubjectName">The X509Certificate2 file to use for client authentication.</param>
|
||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||
public IResponseBuilder WithProxy([NotNull] string proxyUrl, [NotNull] string clientX509Certificate2ThumbprintOrSubjectName)
|
||||
public IResponseBuilder WithProxy(string proxyUrl, string clientX509Certificate2ThumbprintOrSubjectName = null)
|
||||
{
|
||||
Check.NotEmpty(proxyUrl, nameof(proxyUrl));
|
||||
Check.NotEmpty(clientX509Certificate2ThumbprintOrSubjectName, nameof(clientX509Certificate2ThumbprintOrSubjectName));
|
||||
|
||||
ProxyUrl = proxyUrl;
|
||||
X509Certificate2ThumbprintOrSubjectName = clientX509Certificate2ThumbprintOrSubjectName;
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using SimMetrics.Net;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Admin.Requests;
|
||||
using WireMock.Admin.Settings;
|
||||
@@ -431,7 +430,9 @@ namespace WireMock.Server
|
||||
{
|
||||
var requestMatchResult = new RequestMatchResult();
|
||||
if (request.GetMatchingScore(logEntry.RequestMessage, requestMatchResult) > 0.99)
|
||||
{
|
||||
dict.Add(logEntry, requestMatchResult);
|
||||
}
|
||||
}
|
||||
|
||||
var result = dict.OrderBy(x => x.Value.AverageTotalScore).Select(x => x.Key);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WireMock.Server
|
||||
{
|
||||
@@ -41,11 +40,5 @@ namespace WireMock.Server
|
||||
/// </summary>
|
||||
/// <param name="provider">The provider.</param>
|
||||
void RespondWith(IResponseProvider provider);
|
||||
|
||||
///// <summary>
|
||||
///// The respond with.
|
||||
///// </summary>
|
||||
///// <param name="provider">The provider.</param>
|
||||
//Task RespondWithAsync(IResponseProvider provider);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user