mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 02:12:02 +01:00
@@ -9,15 +9,5 @@
|
|||||||
/// Gets or sets the matcher.
|
/// Gets or sets the matcher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatcherModel Matcher { get; set; }
|
public MatcherModel Matcher { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the function.
|
|
||||||
///// </summary>
|
|
||||||
//public string Func { get; set; }
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the data function.
|
|
||||||
///// </summary>
|
|
||||||
//public string DataFunc { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,5 @@
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatcherModel[] Matchers { get; set; }
|
public MatcherModel[] Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,5 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IList<MatcherModel> Matchers { get; set; }
|
public IList<MatcherModel> Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
// using System.Collections.Generic;
|
namespace WireMock.Admin.Mappings
|
||||||
|
|
||||||
namespace WireMock.Admin.Mappings
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Param Model
|
/// Param Model
|
||||||
@@ -12,19 +10,9 @@ namespace WireMock.Admin.Mappings
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the values.
|
|
||||||
///// </summary>
|
|
||||||
//public IList<string> Values { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatcherModel[] Matchers { get; set; }
|
public MatcherModel[] Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,5 @@
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatcherModel[] Matchers { get; set; }
|
public MatcherModel[] Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,5 @@
|
|||||||
/// Gets or sets the matchers.
|
/// Gets or sets the matchers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatcherModel[] Matchers { get; set; }
|
public MatcherModel[] Matchers { get; set; }
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Gets or sets the functions.
|
|
||||||
///// </summary>
|
|
||||||
//public string[] Funcs { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace WireMock.HttpsCertificate
|
namespace WireMock.HttpsCertificate
|
||||||
@@ -10,19 +11,19 @@ namespace WireMock.HttpsCertificate
|
|||||||
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
X509Store certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Certificate must be in the local machine store
|
// Certificate must be in the local machine store
|
||||||
certStore.Open(OpenFlags.ReadOnly);
|
certStore.Open(OpenFlags.ReadOnly);
|
||||||
|
|
||||||
//Attempt to find by thumbprint first
|
// Attempt to find by thumbprint first
|
||||||
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectName, false);
|
var matchingCertificates = certStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprintOrSubjectName, false);
|
||||||
if (matchingCertificates.Count == 0)
|
if (matchingCertificates.Count == 0)
|
||||||
{
|
{
|
||||||
//Fallback to subject name
|
// Fallback to subject name
|
||||||
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectName, false);
|
matchingCertificates = certStore.Certificates.Find(X509FindType.FindBySubjectName, thumbprintOrSubjectName, false);
|
||||||
if (matchingCertificates.Count == 0)
|
if (matchingCertificates.Count == 0)
|
||||||
{
|
{
|
||||||
// No certificates matched the search criteria.
|
// No certificates matched the search criteria.
|
||||||
throw new Exception($"No certificate found with Thumbprint or SubjectName '{thumbprintOrSubjectName}'");
|
throw new FileNotFoundException("No certificate found with specified Thumbprint or SubjectName.", thumbprintOrSubjectName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use the first matching certificate.
|
// Use the first matching certificate.
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ namespace WireMock.Logging
|
|||||||
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
|
/// Writes the LogEntryModel (LogRequestModel, LogResponseModel and more).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logEntryModel">The Request Log Model.</param>
|
/// <param name="logEntryModel">The Request Log Model.</param>
|
||||||
/// <param name="isAdminrequest">Defines if this request is an admin request.</param>
|
/// <param name="isAdminRequest">Defines if this request is an admin request.</param>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminrequest);
|
void DebugRequestResponse([NotNull] LogEntryModel logEntryModel, bool isAdminRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,26 +11,31 @@ namespace WireMock.Logging
|
|||||||
/// <see cref="IWireMockLogger.Debug"/>
|
/// <see cref="IWireMockLogger.Debug"/>
|
||||||
public void Debug(string formatString, params object[] args)
|
public void Debug(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Info"/>
|
/// <see cref="IWireMockLogger.Info"/>
|
||||||
public void Info(string formatString, params object[] args)
|
public void Info(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Warn"/>
|
/// <see cref="IWireMockLogger.Warn"/>
|
||||||
public void Warn(string formatString, params object[] args)
|
public void Warn(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.Error"/>
|
/// <see cref="IWireMockLogger.Error"/>
|
||||||
public void Error(string formatString, params object[] args)
|
public void Error(string formatString, params object[] args)
|
||||||
{
|
{
|
||||||
|
// Log nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
/// <see cref="IWireMockLogger.DebugRequestResponse"/>
|
||||||
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest)
|
||||||
{
|
{
|
||||||
|
// Log nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,6 @@ namespace WireMock.Matchers.Request
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher
|
internal class RequestMessageScenarioAndStateMatcher : IRequestMatcher
|
||||||
{
|
{
|
||||||
///// <summary>
|
|
||||||
///// Scenario.
|
|
||||||
///// </summary>
|
|
||||||
//[CanBeNull] private string _scenario;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execution state condition for the current mapping.
|
/// Execution state condition for the current mapping.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using System.Linq;
|
|||||||
using WireMock.Matchers;
|
using WireMock.Matchers;
|
||||||
using WireMock.Util;
|
using WireMock.Util;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using WireMock.Admin.Mappings;
|
|
||||||
using WireMock.Http;
|
using WireMock.Http;
|
||||||
using WireMock.Serialization;
|
using WireMock.Serialization;
|
||||||
#if !NETSTANDARD
|
#if !NETSTANDARD
|
||||||
@@ -24,8 +23,6 @@ namespace WireMock.Owin
|
|||||||
internal class WireMockMiddleware
|
internal class WireMockMiddleware
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
private readonly IDictionary<string, WireMockList<string>> _contentTypeJsonHeaders = new Dictionary<string, WireMockList<string>> { { HttpKnownHeaderNames.ContentType, new WireMockList<string> { "application/json" } } };
|
|
||||||
|
|
||||||
private static readonly Task CompletedTask = Task.FromResult(false);
|
private static readonly Task CompletedTask = Task.FromResult(false);
|
||||||
private readonly WireMockMiddlewareOptions _options;
|
private readonly WireMockMiddlewareOptions _options;
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithCookie: matching based on functions.
|
/// WithCookie: matching based on functions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cookieFuncs">The funcs.</param>
|
/// <param name="funcs">The funcs.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] cookieFuncs);
|
IRequestBuilder WithCookie([NotNull] params Func<IDictionary<string, string>, bool>[] funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// UsingAnyVerb: add HTTP Method matching on any method.
|
/// UsingAnyVerb: add HTTP Method matching on any method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
[Obsolete]
|
[Obsolete("Use the method UsingAnyMethod().")]
|
||||||
IRequestBuilder UsingAnyVerb();
|
IRequestBuilder UsingAnyVerb();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -84,7 +84,7 @@ namespace WireMock.RequestBuilders
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="verbs">The methods.</param>
|
/// <param name="verbs">The methods.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
[Obsolete]
|
[Obsolete("Use the method UsingMethod(...).")]
|
||||||
IRequestBuilder UsingVerb([NotNull] params string[] verbs);
|
IRequestBuilder UsingVerb([NotNull] params string[] verbs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,8 +63,8 @@ namespace WireMock.RequestBuilders
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// WithUrl: add url matching based on functions.
|
/// WithUrl: add url matching based on functions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="func">The path func.</param>
|
/// <param name="funcs">The url functions.</param>
|
||||||
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
/// <returns>The <see cref="IRequestBuilder"/>.</returns>
|
||||||
IRequestBuilder WithUrl([NotNull] params Func<string, bool>[] func);
|
IRequestBuilder WithUrl([NotNull] params Func<string, bool>[] funcs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
/// <param name="bodyAsbase64">The body.</param>
|
/// <param name="bodyAsbase64">The body.</param>
|
||||||
/// <param name="encoding">The Encoding.</param>
|
/// <param name="encoding">The Encoding.</param>
|
||||||
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
/// <returns>A <see cref="IResponseBuilder"/>.</returns>
|
||||||
[Obsolete]
|
[Obsolete("Should not be used, will be removed in future.")]
|
||||||
IResponseBuilder WithBodyFromBase64([NotNull] string bodyAsbase64, [CanBeNull] Encoding encoding = null);
|
IResponseBuilder WithBodyFromBase64([NotNull] string bodyAsbase64, [CanBeNull] Encoding encoding = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace WireMock.ResponseBuilders
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IBodyResponseBuilder.WithBody(byte[], string, Encoding)"/>
|
/// <inheritdoc cref="IBodyResponseBuilder.WithBody(byte[], string, Encoding)"/>
|
||||||
public IResponseBuilder WithBody(byte[] body, string destination, Encoding encoding = null)
|
public IResponseBuilder WithBody(byte[] body, string destination = BodyDestinationFormat.SameAsSource, Encoding encoding = null)
|
||||||
{
|
{
|
||||||
Check.NotNull(body, nameof(body));
|
Check.NotNull(body, nameof(body));
|
||||||
|
|
||||||
|
|||||||
@@ -146,15 +146,5 @@ namespace WireMock.Serialization
|
|||||||
|
|
||||||
return newDictionary;
|
return newDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private static string[] Map<T>([CanBeNull] IEnumerable<Func<T, bool>> funcs)
|
|
||||||
//{
|
|
||||||
// return funcs?.Select(Map).Where(x => x != null).ToArray();
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private static string Map<T>([CanBeNull] Func<T, bool> func)
|
|
||||||
//{
|
|
||||||
// return func?.ToString();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,30 @@ namespace WireMock.Server
|
|||||||
/// Gets the scenarios.
|
/// Gets the scenarios.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public ConcurrentDictionary<string, object> Scenarios => new ConcurrentDictionary<string, object>(_options.Scenarios); // Checked
|
public ConcurrentDictionary<string, object> Scenarios => new ConcurrentDictionary<string, object>(_options.Scenarios);
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (_httpServer != null && _httpServer.IsStarted)
|
||||||
|
{
|
||||||
|
_httpServer.StopAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Start/Stop
|
#region Start/Stop
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -267,17 +290,6 @@ namespace WireMock.Server
|
|||||||
.RespondWith(new DynamicResponseProvider(request => ResponseMessageBuilder.Create("No matching mapping found", 404)));
|
.RespondWith(new DynamicResponseProvider(request => ResponseMessageBuilder.Create("No matching mapping found", 404)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_httpServer != null && _httpServer.IsStarted)
|
|
||||||
{
|
|
||||||
_httpServer.StopAsync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets LogEntries and Mappings.
|
/// Resets LogEntries and Mappings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ namespace WireMock.Util
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
|
/// An EnhancedFileSystemWatcher, which can be used to suppress duplicate events that fire on a single change to the file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="System.IO.FileSystemWatcher" />
|
/// <seealso cref="FileSystemWatcher" />
|
||||||
/// <seealso cref="System.IDisposable" />
|
public class EnhancedFileSystemWatcher : FileSystemWatcher
|
||||||
public class EnhancedFileSystemWatcher : FileSystemWatcher, IDisposable
|
|
||||||
{
|
{
|
||||||
#region Private Members
|
#region Private Members
|
||||||
// Default Watch Interval in Milliseconds
|
// Default Watch Interval in Milliseconds
|
||||||
@@ -251,15 +250,5 @@ namespace WireMock.Util
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
/// <summary>
|
|
||||||
/// Releases all resources used by the <see cref="T:System.ComponentModel.Component" />.
|
|
||||||
/// </summary>
|
|
||||||
public new void Dispose()
|
|
||||||
{
|
|
||||||
base.Dispose();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,10 +38,7 @@ namespace WireMock.Util
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (this != null && this.Any())
|
return this.Any() ? this.First().ToString() : base.ToString();
|
||||||
return this.First().ToString();
|
|
||||||
|
|
||||||
return base.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user