Remove interface for all Settings (#736)

This commit is contained in:
Stef Heyenrath
2022-03-10 20:58:18 +01:00
committed by GitHub
parent 3087ce55b1
commit bb3147eb8d
34 changed files with 238 additions and 511 deletions

View File

@@ -1,17 +1,24 @@
namespace WireMock.Settings
namespace WireMock.Settings
{
/// <summary>
/// HttpClientSettings
/// </summary>
public class HttpClientSettings : IHttpClientSettings
public class HttpClientSettings
{
/// <inheritdoc cref="IHttpClientSettings.ClientX509Certificate2ThumbprintOrSubjectName"/>
/// <summary>
/// The clientCertificate thumbprint or subject name fragment to use.
/// Example thumbprint : "D2DBF135A8D06ACCD0E1FAD9BFB28678DF7A9818". Example subject name: "www.google.com""
/// </summary>
public string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }
/// <inheritdoc cref="IHttpClientSettings.WebProxySettings"/>
public IWebProxySettings WebProxySettings { get; set; }
/// <summary>
/// Defines the WebProxySettings.
/// </summary>
public WebProxySettings WebProxySettings { get; set; }
/// <inheritdoc cref="IHttpClientSettings.AllowAutoRedirect"/>
/// <summary>
/// Proxy requests should follow redirection (30x).
/// </summary>
public bool? AllowAutoRedirect { get; set; }
}
}

View File

@@ -1,24 +0,0 @@
namespace WireMock.Settings
{
/// <summary>
/// IHttpClientSettings
/// </summary>
public interface IHttpClientSettings
{
/// <summary>
/// The clientCertificate thumbprint or subject name fragment to use.
/// Example thumbprint : "D2DBF135A8D06ACCD0E1FAD9BFB28678DF7A9818". Example subject name: "www.google.com""
/// </summary>
string ClientX509Certificate2ThumbprintOrSubjectName { get; set; }
/// <summary>
/// Defines the WebProxySettings.
/// </summary>
IWebProxySettings WebProxySettings { get; set; }
/// <summary>
/// Proxy requests should follow redirection (30x).
/// </summary>
bool? AllowAutoRedirect { get; set; }
}
}

View File

@@ -1,42 +0,0 @@
using JetBrains.Annotations;
namespace WireMock.Settings
{
/// <summary>
/// IProxyAndRecordSettings
/// </summary>
public interface IProxyAndRecordSettings : IHttpClientSettings
{
/// <summary>
/// The URL to proxy.
/// </summary>
string Url { get; set; }
/// <summary>
/// Save the mapping for each request/response to the internal Mappings.
/// </summary>
bool SaveMapping { get; set; }
/// <summary>
/// Only save request/response to the internal Mappings if the status code is included in this pattern. (Note that SaveMapping must also be set to true.)
/// The pattern can contain a single value like "200", but also ranges like "2xx", "100,300,600" or "100-299,6xx" are supported.
/// </summary>
[CanBeNull]
string SaveMappingForStatusCodePattern { get; set; }
/// <summary>
/// Save the mapping for each request/response to a .json mapping file.
/// </summary>
bool SaveMappingToFile { get; set; }
/// <summary>
/// Defines a list from headers which will be excluded from the saved mappings.
/// </summary>
string[] ExcludedHeaders { get; set; }
/// <summary>
/// Defines a list of cookies which will be excluded from the saved mappings.
/// </summary>
string[] ExcludedCookies { get; set; }
}
}

View File

@@ -1,23 +0,0 @@
namespace WireMock.Settings
{
/// <summary>
/// IWebProxySettings
/// </summary>
public interface IWebProxySettings
{
/// <summary>
/// A string instance that contains the address of the proxy server.
/// </summary>
string Address { get; set; }
/// <summary>
/// The user name associated with the credentials.
/// </summary>
string UserName { get; set; }
/// <summary>
/// The password for the user name associated with the credentials.
/// </summary>
string Password { get; set; }
}
}

View File

@@ -1,9 +0,0 @@
namespace WireMock.Settings
{
/// <summary>
/// IWebhookSettings
/// </summary>
public interface IWebhookSettings : IHttpClientSettings
{
}
}

View File

@@ -1,44 +0,0 @@
namespace WireMock.Settings
{
/// <summary>
/// If https is used, these settings can be used to configure the CertificateSettings in case a custom certificate instead the default .NET certificate should be used.
///
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
public interface IWireMockCertificateSettings
{
/// <summary>
/// X509 StoreName (AddressBook, AuthRoot, CertificateAuthority, My, Root, TrustedPeople or TrustedPublisher)
/// </summary>
string X509StoreName { get; set; }
/// <summary>
/// X509 StoreLocation (CurrentUser or LocalMachine)
/// </summary>
string X509StoreLocation { get; set; }
/// <summary>
/// X509 Thumbprint or SubjectName (if not defined, the 'host' is used)
/// </summary>
string X509StoreThumbprintOrSubjectName { get; set; }
/// <summary>
/// X509Certificate FilePath
/// </summary>
string X509CertificateFilePath { get; set; }
/// <summary>
/// X509Certificate Password
/// </summary>
string X509CertificatePassword { get; set; }
/// <summary>
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
bool IsDefined { get; }
}
}

View File

@@ -1,249 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using HandlebarsDotNet;
using JetBrains.Annotations;
using Newtonsoft.Json;
using WireMock.Admin.Mappings;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.RegularExpressions;
#if USE_ASPNETCORE
using Microsoft.Extensions.DependencyInjection;
using WireMock.Types;
#endif
namespace WireMock.Settings
{
/// <summary>
/// IWireMockServerSettings
/// </summary>
public interface IWireMockServerSettings
{
/// <summary>
/// Gets or sets the port.
/// </summary>
[PublicAPI]
int? Port { get; set; }
/// <summary>
/// Gets or sets the use SSL.
/// </summary>
// ReSharper disable once InconsistentNaming
[PublicAPI]
bool? UseSSL { get; set; }
/// <summary>
/// Gets or sets whether to start admin interface.
/// </summary>
[PublicAPI]
bool? StartAdminInterface { get; set; }
/// <summary>
/// Gets or sets if the static mappings should be read at startup.
/// </summary>
[PublicAPI]
bool? ReadStaticMappings { get; set; }
/// <summary>
/// Watch the static mapping files + folder for changes when running.
/// </summary>
[PublicAPI]
bool? WatchStaticMappings { get; set; }
/// <summary>
/// A value indicating whether subdirectories within the static mappings path should be monitored.
/// </summary>
[PublicAPI]
bool? WatchStaticMappingsInSubdirectories { get; set; }
/// <summary>
/// Gets or sets if the proxy and record settings.
/// </summary>
[PublicAPI]
IProxyAndRecordSettings ProxyAndRecordSettings { get; set; }
/// <summary>
/// Gets or sets the urls.
/// </summary>
[PublicAPI]
string[] Urls { get; set; }
/// <summary>
/// StartTimeout
/// </summary>
[PublicAPI]
int StartTimeout { get; set; }
/// <summary>
/// Allow Partial Mapping (default set to false).
/// </summary>
[PublicAPI]
bool? AllowPartialMapping { get; set; }
/// <summary>
/// The username needed for __admin access.
/// </summary>
[PublicAPI]
string AdminUsername { get; set; }
/// <summary>
/// The password needed for __admin access.
/// </summary>
[PublicAPI]
string AdminPassword { get; set; }
/// <summary>
/// The AzureAD Tenant needed for __admin access.
/// </summary>
[PublicAPI]
string AdminAzureADTenant { get; set; }
/// <summary>
/// The AzureAD Audience / Resource for __admin access.
/// </summary>
[PublicAPI]
string AdminAzureADAudience { get; set; }
/// <summary>
/// The RequestLog expiration in hours (optional).
/// </summary>
[PublicAPI]
int? RequestLogExpirationDuration { get; set; }
/// <summary>
/// The MaxRequestLog count (optional).
/// </summary>
[PublicAPI]
int? MaxRequestLogCount { get; set; }
/// <summary>
/// Action which is called (with the IAppBuilder or IApplicationBuilder) before the internal WireMockMiddleware is initialized. [Optional]
/// </summary>
[PublicAPI]
Action<object> PreWireMockMiddlewareInit { get; set; }
/// <summary>
/// Action which is called (with the IAppBuilder or IApplicationBuilder) after the internal WireMockMiddleware is initialized. [Optional]
/// </summary>
[PublicAPI]
Action<object> PostWireMockMiddlewareInit { get; set; }
#if USE_ASPNETCORE
/// <summary>
/// Action which is called with IServiceCollection when ASP.NET Core DI is being configured. [Optional]
/// </summary>
[PublicAPI]
Action<IServiceCollection> AdditionalServiceRegistration { get; set; }
/// <summary>
/// Policies to use when using CORS. By default CORS is disabled. [Optional]
/// </summary>
[PublicAPI]
CorsPolicyOptions? CorsPolicyOptions { get; set; }
#endif
/// <summary>
/// The IWireMockLogger which logs Debug, Info, Warning or Error
/// </summary>
[PublicAPI]
IWireMockLogger Logger { get; set; }
/// <summary>
/// Handler to interact with the file system to read and write static mapping files.
/// </summary>
[PublicAPI]
IFileSystemHandler FileSystemHandler { get; set; }
/// <summary>
/// Action which can be used to add additional Handlebars registrations. [Optional]
/// </summary>
[PublicAPI]
Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; }
/// <summary>
/// Allow the usage of CSharpCodeMatcher (default is not allowed).
/// </summary>
[PublicAPI]
bool? AllowCSharpCodeMatcher { get; set; }
/// <summary>
/// Allow a Body for all HTTP Methods. (default set to false).
/// </summary>
[PublicAPI]
bool? AllowBodyForAllHttpMethods { get; set; }
/// <summary>
/// Allow only a HttpStatus Code in the response which is defined. (default set to false).
/// - false : also null, 0, empty or invalid HttpStatus codes are allowed.
/// - true : only codes defined in <see cref="System.Net.HttpStatusCode"/> are allowed.
/// </summary>
[PublicAPI]
bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
/// <summary>
/// Set to true to disable Json deserialization when processing requests. (default set to false).
/// </summary>
[PublicAPI]
bool? DisableJsonBodyParsing { get; set; }
/// <summary>
/// Disable support for GZip and Deflate request body decompression. (default set to false).
/// </summary>
[PublicAPI]
bool? DisableRequestBodyDecompressing { get; set; }
/// <summary>
/// Handle all requests synchronously. (default set to false).
/// </summary>
[PublicAPI]
bool? HandleRequestsSynchronously { get; set; }
/// <summary>
/// Throw an exception when the <see cref="IMatcher"/> fails because of invalid input. (default set to false).
/// </summary>
[PublicAPI]
bool? ThrowExceptionWhenMatcherFails { get; set; }
/// <summary>
/// If https is used, these settings can be used to configure the CertificateSettings in case a custom certificate instead the default .NET certificate should be used.
///
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
[PublicAPI]
IWireMockCertificateSettings CertificateSettings { get; set; }
/// <summary>
/// Defines if custom CertificateSettings are defined
/// </summary>
[PublicAPI]
bool CustomCertificateDefined { get; }
/// <summary>
/// Defines the global IWebhookSettings to use.
/// </summary>
[PublicAPI]
IWebhookSettings WebhookSettings { get; set; }
/// <summary>
/// Use the <see cref="RegexExtended"/> instead of the default <see cref="Regex"/> (default set to true).
/// </summary>
[PublicAPI]
bool? UseRegexExtended { get; set; }
/// <summary>
/// Save unmatched requests to a file using the <see cref="IFileSystemHandler"/> (default set to false).
/// </summary>
[PublicAPI]
bool? SaveUnmatchedRequests { get; set; }
/// <summary>
/// Custom matcher mappings for static mappings
/// </summary>
[PublicAPI, JsonIgnore]
IDictionary<string, Func<MatcherModel, IMatcher>> CustomMatcherMappings { get; set; }
}
}

View File

@@ -1,11 +1,11 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
namespace WireMock.Settings
{
/// <summary>
/// ProxyAndRecordSettings
/// </summary>
public class ProxyAndRecordSettings : HttpClientSettings, IProxyAndRecordSettings
public class ProxyAndRecordSettings : HttpClientSettings
{
/// <summary>
/// The URL to proxy.
@@ -32,11 +32,15 @@ namespace WireMock.Settings
[PublicAPI]
public string SaveMappingForStatusCodePattern { get; set; } = "*";
/// <inheritdoc cref="IProxyAndRecordSettings.ExcludedHeaders"/>
/// <summary>
/// Defines a list from headers which will be excluded from the saved mappings.
/// </summary>
[PublicAPI]
public string[] ExcludedHeaders { get; set; }
/// <inheritdoc cref="IProxyAndRecordSettings.ExcludedCookies"/>
/// <summary>
/// Defines a list of cookies which will be excluded from the saved mappings.
/// </summary>
[PublicAPI]
public string[] ExcludedCookies { get; set; }
}

View File

@@ -1,19 +1,27 @@
using JetBrains.Annotations;
using JetBrains.Annotations;
namespace WireMock.Settings
{
/// <seealso cref="IWebProxySettings" />
public class WebProxySettings : IWebProxySettings
/// <summary>
/// WebProxySettings
/// </summary>
public class WebProxySettings
{
/// <inheritdoc cref="IWebProxySettings.Address"/>
/// <summary>
/// A string instance that contains the address of the proxy server.
/// </summary>
[PublicAPI]
public string Address { get; set; }
/// <inheritdoc cref="IWebProxySettings.UserName"/>
/// <summary>
/// The user name associated with the credentials.
/// </summary>
[PublicAPI]
public string UserName { get; set; }
/// <inheritdoc cref="IWebProxySettings.Password"/>
/// <summary>
/// The password for the user name associated with the credentials.
/// </summary>
[PublicAPI]
public string Password { get; set; }
}

View File

@@ -1,9 +1,9 @@
namespace WireMock.Settings
namespace WireMock.Settings
{
/// <summary>
/// WebhookSettings
/// </summary>
public class WebhookSettings : HttpClientSettings, IWebhookSettings
public class WebhookSettings : HttpClientSettings
{
}
}

View File

@@ -3,31 +3,49 @@ using JetBrains.Annotations;
namespace WireMock.Settings
{
/// <summary>
/// <see cref="IWireMockCertificateSettings"/>
/// If https is used, these settings can be used to configure the CertificateSettings in case a custom certificate instead the default .NET certificate should be used.
///
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
public class WireMockCertificateSettings : IWireMockCertificateSettings
public class WireMockCertificateSettings
{
/// <inheritdoc cref="IWireMockCertificateSettings.X509StoreName"/>
/// <summary>
/// X509 StoreName (AddressBook, AuthRoot, CertificateAuthority, My, Root, TrustedPeople or TrustedPublisher)
/// </summary>
[PublicAPI]
public string X509StoreName { get; set; }
/// <inheritdoc cref="IWireMockCertificateSettings.X509StoreLocation"/>
/// <summary>
/// X509 StoreLocation (CurrentUser or LocalMachine)
/// </summary>
[PublicAPI]
public string X509StoreLocation { get; set; }
/// <inheritdoc cref="IWireMockCertificateSettings.X509StoreThumbprintOrSubjectName"/>
/// <summary>
/// X509 Thumbprint or SubjectName (if not defined, the 'host' is used)
/// </summary>
[PublicAPI]
public string X509StoreThumbprintOrSubjectName { get; set; }
/// <inheritdoc cref="IWireMockCertificateSettings.X509CertificateFilePath"/>
/// <summary>
/// X509Certificate FilePath
/// </summary>
[PublicAPI]
public string X509CertificateFilePath { get; set; }
/// <inheritdoc cref="IWireMockCertificateSettings.X509CertificatePassword"/>
/// <summary>
/// X509Certificate Password
/// </summary>
[PublicAPI]
public string X509CertificatePassword { get; set; }
/// <inheritdoc cref="IWireMockCertificateSettings.IsDefined"/>
/// <summary>
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
[PublicAPI]
public bool IsDefined =>
!string.IsNullOrEmpty(X509StoreName) && !string.IsNullOrEmpty(X509StoreLocation) ||

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using HandlebarsDotNet;
using JetBrains.Annotations;
using Newtonsoft.Json;
@@ -7,6 +8,7 @@ using WireMock.Admin.Mappings;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.RegularExpressions;
using WireMock.Types;
#if USE_ASPNETCORE
using Microsoft.Extensions.DependencyInjection;
@@ -17,157 +19,236 @@ namespace WireMock.Settings
/// <summary>
/// WireMockServerSettings
/// </summary>
public class WireMockServerSettings : IWireMockServerSettings
public class WireMockServerSettings
{
/// <inheritdoc cref="IWireMockServerSettings.Port"/>
/// <summary>
/// Gets or sets the port.
/// </summary>
[PublicAPI]
public int? Port { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.UseSSL"/>
/// <summary>
/// Gets or sets the use SSL.
/// </summary>
// ReSharper disable once InconsistentNaming
[PublicAPI]
public bool? UseSSL { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.StartAdminInterface"/>
/// <summary>
/// Gets or sets whether to start admin interface.
/// </summary>
[PublicAPI]
public bool? StartAdminInterface { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.ReadStaticMappings"/>
/// <summary>
/// Gets or sets if the static mappings should be read at startup.
/// </summary>
[PublicAPI]
public bool? ReadStaticMappings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.WatchStaticMappings"/>
/// <summary>
/// Watch the static mapping files + folder for changes when running.
/// </summary>
[PublicAPI]
public bool? WatchStaticMappings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.WatchStaticMappingsInSubdirectories"/>
/// <summary>
/// A value indicating whether subdirectories within the static mappings path should be monitored.
/// </summary>
[PublicAPI]
public bool? WatchStaticMappingsInSubdirectories { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.ProxyAndRecordSettings"/>
/// <summary>
/// Gets or sets if the proxy and record settings.
/// </summary>
[PublicAPI]
public IProxyAndRecordSettings ProxyAndRecordSettings { get; set; }
public ProxyAndRecordSettings ProxyAndRecordSettings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.Urls"/>
/// <summary>
/// Gets or sets the urls.
/// </summary>
[PublicAPI]
public string[] Urls { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.StartTimeout"/>
/// <summary>
/// StartTimeout
/// </summary>
[PublicAPI]
public int StartTimeout { get; set; } = 10000;
/// <inheritdoc cref="IWireMockServerSettings.AllowPartialMapping"/>
/// <summary>
/// Allow Partial Mapping (default set to false).
/// </summary>
[PublicAPI]
public bool? AllowPartialMapping { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AdminUsername"/>
/// <summary>
/// The username needed for __admin access.
/// </summary>
[PublicAPI]
public string AdminUsername { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AdminPassword"/>
/// <summary>
/// The password needed for __admin access.
/// </summary>
[PublicAPI]
public string AdminPassword { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AdminAzureADTenant"/>
/// <summary>
/// The AzureAD Tenant needed for __admin access.
/// </summary>
[PublicAPI]
public string AdminAzureADTenant { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AdminAzureADAudience"/>
/// <summary>
/// The AzureAD Audience / Resource for __admin access.
/// </summary>
[PublicAPI]
public string AdminAzureADAudience { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.RequestLogExpirationDuration"/>
/// <summary>
/// The RequestLog expiration in hours (optional).
/// </summary>
[PublicAPI]
public int? RequestLogExpirationDuration { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.MaxRequestLogCount"/>
/// <summary>
/// The MaxRequestLog count (optional).
/// </summary>
[PublicAPI]
public int? MaxRequestLogCount { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.PreWireMockMiddlewareInit"/>
/// <summary>
/// Action which is called (with the IAppBuilder or IApplicationBuilder) before the internal WireMockMiddleware is initialized. [Optional]
/// </summary>
[PublicAPI]
[JsonIgnore]
public Action<object> PreWireMockMiddlewareInit { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.PostWireMockMiddlewareInit"/>
/// <summary>
/// Action which is called (with the IAppBuilder or IApplicationBuilder) after the internal WireMockMiddleware is initialized. [Optional]
/// </summary>
[PublicAPI]
[JsonIgnore]
public Action<object> PostWireMockMiddlewareInit { get; set; }
#if USE_ASPNETCORE
/// <inheritdoc cref="IWireMockServerSettings.AdditionalServiceRegistration"/>
/// <summary>
/// Action which is called with IServiceCollection when ASP.NET Core DI is being configured. [Optional]
/// </summary>
[PublicAPI]
[JsonIgnore]
public Action<IServiceCollection> AdditionalServiceRegistration { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.CorsPolicyOptions"/>
/// <summary>
/// Policies to use when using CORS. By default CORS is disabled. [Optional]
/// </summary>
[PublicAPI]
public CorsPolicyOptions? CorsPolicyOptions { get; set; }
#endif
/// <inheritdoc cref="IWireMockServerSettings.Logger"/>
/// <summary>
/// The IWireMockLogger which logs Debug, Info, Warning or Error
/// </summary>
[PublicAPI]
[JsonIgnore]
public IWireMockLogger Logger { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.FileSystemHandler"/>
/// <summary>
/// Handler to interact with the file system to read and write static mapping files.
/// </summary>
[PublicAPI]
[JsonIgnore]
public IFileSystemHandler FileSystemHandler { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.HandlebarsRegistrationCallback"/>
/// <summary>
/// Action which can be used to add additional Handlebars registrations. [Optional]
/// </summary>
[PublicAPI]
[JsonIgnore]
public Action<IHandlebars, IFileSystemHandler> HandlebarsRegistrationCallback { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AllowCSharpCodeMatcher"/>
/// <summary>
/// Allow the usage of CSharpCodeMatcher (default is not allowed).
/// </summary>
[PublicAPI]
public bool? AllowCSharpCodeMatcher { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AllowBodyForAllHttpMethods"/>
/// <summary>
/// Allow a Body for all HTTP Methods. (default set to false).
/// </summary>
[PublicAPI]
public bool? AllowBodyForAllHttpMethods { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.AllowOnlyDefinedHttpStatusCodeInResponse"/>
/// <summary>
/// Allow only a HttpStatus Code in the response which is defined. (default set to false).
/// - false : also null, 0, empty or invalid HttpStatus codes are allowed.
/// - true : only codes defined in <see cref="System.Net.HttpStatusCode"/> are allowed.
/// </summary>
[PublicAPI]
public bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.DisableJsonBodyParsing"/>
/// <summary>
/// Set to true to disable Json deserialization when processing requests. (default set to false).
/// </summary>
[PublicAPI]
public bool? DisableJsonBodyParsing { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.DisableRequestBodyDecompressing"/>
/// <summary>
/// Disable support for GZip and Deflate request body decompression. (default set to false).
/// </summary>
[PublicAPI]
public bool? DisableRequestBodyDecompressing { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.HandleRequestsSynchronously"/>
/// <summary>
/// Handle all requests synchronously. (default set to false).
/// </summary>
[PublicAPI]
public bool? HandleRequestsSynchronously { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.ThrowExceptionWhenMatcherFails"/>
/// <summary>
/// Throw an exception when the <see cref="IMatcher"/> fails because of invalid input. (default set to false).
/// </summary>
[PublicAPI]
public bool? ThrowExceptionWhenMatcherFails { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.CertificateSettings"/>
/// <summary>
/// If https is used, these settings can be used to configure the CertificateSettings in case a custom certificate instead the default .NET certificate should be used.
///
/// X509StoreName and X509StoreLocation should be defined
/// OR
/// X509CertificateFilePath and X509CertificatePassword should be defined
/// </summary>
[PublicAPI]
public IWireMockCertificateSettings CertificateSettings { get; set; }
public WireMockCertificateSettings CertificateSettings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.CustomCertificateDefined"/>
/// <summary>
/// Defines if custom CertificateSettings are defined
/// </summary>
[PublicAPI]
public bool CustomCertificateDefined => CertificateSettings?.IsDefined == true;
/// <inheritdoc cref="IWireMockServerSettings.WebhookSettings"/>
/// <summary>
/// Defines the global IWebhookSettings to use.
/// </summary>
[PublicAPI]
public IWebhookSettings WebhookSettings { get; set; }
public WebhookSettings WebhookSettings { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.UseRegexExtended"/>
/// <summary>
/// Use the <see cref="RegexExtended"/> instead of the default <see cref="Regex"/> (default set to true).
/// </summary>
[PublicAPI]
public bool? UseRegexExtended { get; set; } = true;
/// <inheritdoc cref="IWireMockServerSettings.SaveUnmatchedRequests"/>
/// <summary>
/// Save unmatched requests to a file using the <see cref="IFileSystemHandler"/> (default set to false).
/// </summary>
[PublicAPI]
public bool? SaveUnmatchedRequests { get; set; }
/// <inheritdoc cref="IWireMockServerSettings.CustomMatcherMappings"/>
/// <summary>
/// Custom matcher mappings for static mappings
/// </summary>
[PublicAPI, JsonIgnore]
public IDictionary<string, Func<MatcherModel, IMatcher>> CustomMatcherMappings { get; set; }
}

View File

@@ -8,7 +8,7 @@ using WireMock.Types;
namespace WireMock.Settings
{
/// <summary>
/// A static helper class to parse commandline arguments into IWireMockServerSettings.
/// A static helper class to parse commandline arguments into WireMockServerSettings.
/// </summary>
public static class WireMockServerSettingsParser
{
@@ -19,7 +19,7 @@ namespace WireMock.Settings
/// <param name="logger">The logger (optional, can be null)</param>
/// <param name="settings">The parsed settings</param>
[PublicAPI]
public static bool TryParseArguments([NotNull] string[] args, out IWireMockServerSettings settings, [CanBeNull] IWireMockLogger logger = null)
public static bool TryParseArguments([NotNull] string[] args, out WireMockServerSettings settings, [CanBeNull] IWireMockLogger logger = null)
{
Guard.HasNoNulls(args, nameof(args));
@@ -42,8 +42,8 @@ namespace WireMock.Settings
WatchStaticMappingsInSubdirectories = parser.GetBoolValue("WatchStaticMappingsInSubdirectories"),
AdminUsername = parser.GetStringValue("AdminUsername"),
AdminPassword = parser.GetStringValue("AdminPassword"),
AdminAzureADTenant = parser.GetStringValue(nameof(IWireMockServerSettings.AdminAzureADTenant)),
AdminAzureADAudience = parser.GetStringValue(nameof(IWireMockServerSettings.AdminAzureADAudience)),
AdminAzureADTenant = parser.GetStringValue(nameof(WireMockServerSettings.AdminAzureADTenant)),
AdminAzureADAudience = parser.GetStringValue(nameof(WireMockServerSettings.AdminAzureADAudience)),
MaxRequestLogCount = parser.GetIntValue("MaxRequestLogCount"),
RequestLogExpirationDuration = parser.GetIntValue("RequestLogExpirationDuration"),
AllowCSharpCodeMatcher = parser.GetBoolValue("AllowCSharpCodeMatcher"),
@@ -52,13 +52,13 @@ namespace WireMock.Settings
DisableJsonBodyParsing = parser.GetBoolValue("DisableJsonBodyParsing"),
HandleRequestsSynchronously = parser.GetBoolValue("HandleRequestsSynchronously"),
ThrowExceptionWhenMatcherFails = parser.GetBoolValue("ThrowExceptionWhenMatcherFails"),
UseRegexExtended = parser.GetBoolValue(nameof(IWireMockServerSettings.UseRegexExtended), true),
SaveUnmatchedRequests = parser.GetBoolValue(nameof(IWireMockServerSettings.SaveUnmatchedRequests)),
UseRegexExtended = parser.GetBoolValue(nameof(WireMockServerSettings.UseRegexExtended), true),
SaveUnmatchedRequests = parser.GetBoolValue(nameof(WireMockServerSettings.SaveUnmatchedRequests)),
};
#if USE_ASPNETCORE
settings.CorsPolicyOptions = parser.GetValue(
nameof(IWireMockServerSettings.CorsPolicyOptions), values =>
nameof(WireMockServerSettings.CorsPolicyOptions), values =>
{
var value = string.Join(string.Empty, values);
return Enum.TryParse<CorsPolicyOptions>(value, true, out var corsPolicyOptions) ? corsPolicyOptions : CorsPolicyOptions.None;