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; using WireMock.Types; #if USE_ASPNETCORE using Microsoft.Extensions.DependencyInjection; #endif namespace WireMock.Settings { /// /// WireMockServerSettings /// public class WireMockServerSettings { /// /// Gets or sets the port. /// [PublicAPI] public int? Port { get; set; } /// /// Gets or sets the use SSL. /// // ReSharper disable once InconsistentNaming [PublicAPI] public bool? UseSSL { get; set; } /// /// Gets or sets whether to start admin interface. /// [PublicAPI] public bool? StartAdminInterface { get; set; } /// /// Gets or sets if the static mappings should be read at startup. /// [PublicAPI] public bool? ReadStaticMappings { get; set; } /// /// Watch the static mapping files + folder for changes when running. /// [PublicAPI] public bool? WatchStaticMappings { get; set; } /// /// A value indicating whether subdirectories within the static mappings path should be monitored. /// [PublicAPI] public bool? WatchStaticMappingsInSubdirectories { get; set; } /// /// Gets or sets if the proxy and record settings. /// [PublicAPI] public ProxyAndRecordSettings ProxyAndRecordSettings { get; set; } /// /// Gets or sets the urls. /// [PublicAPI] public string[] Urls { get; set; } /// /// StartTimeout /// [PublicAPI] public int StartTimeout { get; set; } = 10000; /// /// Allow Partial Mapping (default set to false). /// [PublicAPI] public bool? AllowPartialMapping { get; set; } /// /// The username needed for __admin access. /// [PublicAPI] public string AdminUsername { get; set; } /// /// The password needed for __admin access. /// [PublicAPI] public string AdminPassword { get; set; } /// /// The AzureAD Tenant needed for __admin access. /// [PublicAPI] public string AdminAzureADTenant { get; set; } /// /// The AzureAD Audience / Resource for __admin access. /// [PublicAPI] public string AdminAzureADAudience { get; set; } /// /// The RequestLog expiration in hours (optional). /// [PublicAPI] public int? RequestLogExpirationDuration { get; set; } /// /// The MaxRequestLog count (optional). /// [PublicAPI] public int? MaxRequestLogCount { get; set; } /// /// Action which is called (with the IAppBuilder or IApplicationBuilder) before the internal WireMockMiddleware is initialized. [Optional] /// [PublicAPI] [JsonIgnore] public Action PreWireMockMiddlewareInit { get; set; } /// /// Action which is called (with the IAppBuilder or IApplicationBuilder) after the internal WireMockMiddleware is initialized. [Optional] /// [PublicAPI] [JsonIgnore] public Action PostWireMockMiddlewareInit { get; set; } #if USE_ASPNETCORE /// /// Action which is called with IServiceCollection when ASP.NET Core DI is being configured. [Optional] /// [PublicAPI] [JsonIgnore] public Action AdditionalServiceRegistration { get; set; } /// /// Policies to use when using CORS. By default CORS is disabled. [Optional] /// [PublicAPI] public CorsPolicyOptions? CorsPolicyOptions { get; set; } #endif /// /// The IWireMockLogger which logs Debug, Info, Warning or Error /// [PublicAPI] [JsonIgnore] public IWireMockLogger Logger { get; set; } /// /// Handler to interact with the file system to read and write static mapping files. /// [PublicAPI] [JsonIgnore] public IFileSystemHandler FileSystemHandler { get; set; } /// /// Action which can be used to add additional Handlebars registrations. [Optional] /// [PublicAPI] [JsonIgnore] public Action HandlebarsRegistrationCallback { get; set; } /// /// Allow the usage of CSharpCodeMatcher (default is not allowed). /// [PublicAPI] public bool? AllowCSharpCodeMatcher { get; set; } /// /// Allow a Body for all HTTP Methods. (default set to false). /// [PublicAPI] public bool? AllowBodyForAllHttpMethods { get; set; } /// /// 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 are allowed. /// [PublicAPI] public bool? AllowOnlyDefinedHttpStatusCodeInResponse { get; set; } /// /// Set to true to disable Json deserialization when processing requests. (default set to false). /// [PublicAPI] public bool? DisableJsonBodyParsing { get; set; } /// /// Disable support for GZip and Deflate request body decompression. (default set to false). /// [PublicAPI] public bool? DisableRequestBodyDecompressing { get; set; } /// /// Handle all requests synchronously. (default set to false). /// [PublicAPI] public bool? HandleRequestsSynchronously { get; set; } /// /// Throw an exception when the fails because of invalid input. (default set to false). /// [PublicAPI] public bool? ThrowExceptionWhenMatcherFails { get; set; } /// /// 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 /// [PublicAPI] public WireMockCertificateSettings CertificateSettings { get; set; } /// /// Defines if custom CertificateSettings are defined /// [PublicAPI] public bool CustomCertificateDefined => CertificateSettings?.IsDefined == true; /// /// Defines the global IWebhookSettings to use. /// [PublicAPI] public WebhookSettings WebhookSettings { get; set; } /// /// Use the instead of the default (default set to true). /// [PublicAPI] public bool? UseRegexExtended { get; set; } = true; /// /// Save unmatched requests to a file using the (default set to false). /// [PublicAPI] public bool? SaveUnmatchedRequests { get; set; } /// /// Custom matcher mappings for static mappings /// [PublicAPI, JsonIgnore] public IDictionary> CustomMatcherMappings { get; set; } } }