mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-19 23:41:41 +02:00
Expose more settings to stand-alone app (#40)
This commit is contained in:
@@ -37,30 +37,31 @@ namespace WireMock.Net.StandAlone
|
|||||||
|
|
||||||
[ValueArgument(typeof(string), "X509Certificate2ThumbprintOrSubjectName", Description = "The X509Certificate2 Thumbprint or SubjectName to use.", Optional = true)]
|
[ValueArgument(typeof(string), "X509Certificate2ThumbprintOrSubjectName", Description = "The X509Certificate2 Thumbprint or SubjectName to use.", Optional = true)]
|
||||||
public string X509Certificate2ThumbprintOrSubjectName { get; set; }
|
public string X509Certificate2ThumbprintOrSubjectName { get; set; }
|
||||||
|
|
||||||
|
[ValueArgument(typeof(string), "AdminUsername", Description = "The username needed for __admin access.", Optional = true)]
|
||||||
|
public string AdminUsername { get; set; }
|
||||||
|
|
||||||
|
[ValueArgument(typeof(string), "AdminPassword", Description = "The password needed for __admin access.", Optional = true)]
|
||||||
|
public string AdminPassword { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start WireMock.Net standalone bases on the FluentMockServerSettings.
|
/// Start WireMock.Net standalone based on the FluentMockServerSettings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="settings">The FluentMockServerSettings</param>
|
/// <param name="settings">The FluentMockServerSettings</param>
|
||||||
/// <param name="allowPartialMapping">Allow Partial Mapping (default set to false).</param>
|
[PublicAPI]
|
||||||
public static FluentMockServer Start([NotNull] FluentMockServerSettings settings, bool allowPartialMapping = false)
|
public static FluentMockServer Start([NotNull] FluentMockServerSettings settings)
|
||||||
{
|
{
|
||||||
Check.NotNull(settings, nameof(settings));
|
Check.NotNull(settings, nameof(settings));
|
||||||
|
|
||||||
var server = FluentMockServer.Start(settings);
|
return FluentMockServer.Start(settings);
|
||||||
if (allowPartialMapping)
|
|
||||||
{
|
|
||||||
server.AllowPartialMapping();
|
|
||||||
}
|
|
||||||
|
|
||||||
return server;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Start WireMock.Net standalone bases on the commandline arguments.
|
/// Start WireMock.Net standalone bases on the commandline arguments.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args">The commandline arguments</param>
|
/// <param name="args">The commandline arguments</param>
|
||||||
|
[PublicAPI]
|
||||||
public static FluentMockServer Start([NotNull] string[] args)
|
public static FluentMockServer Start([NotNull] string[] args)
|
||||||
{
|
{
|
||||||
Check.NotNull(args, nameof(args));
|
Check.NotNull(args, nameof(args));
|
||||||
@@ -83,6 +84,9 @@ namespace WireMock.Net.StandAlone
|
|||||||
Urls = options.Urls.ToArray(),
|
Urls = options.Urls.ToArray(),
|
||||||
StartAdminInterface = options.StartAdminInterface,
|
StartAdminInterface = options.StartAdminInterface,
|
||||||
ReadStaticMappings = options.ReadStaticMappings,
|
ReadStaticMappings = options.ReadStaticMappings,
|
||||||
|
AllowPartialMapping = options.AllowPartialMapping,
|
||||||
|
AdminUsername = options.AdminUsername,
|
||||||
|
AdminPassword = options.AdminPassword
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(options.ProxyURL))
|
if (!string.IsNullOrEmpty(options.ProxyURL))
|
||||||
@@ -95,7 +99,7 @@ namespace WireMock.Net.StandAlone
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
FluentMockServer server = Start(settings, options.AllowPartialMapping);
|
FluentMockServer server = Start(settings);
|
||||||
|
|
||||||
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
|
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
|
||||||
|
|
||||||
|
|||||||
@@ -173,8 +173,18 @@ namespace WireMock.Server
|
|||||||
|
|
||||||
_httpServer.StartAsync();
|
_httpServer.StartAsync();
|
||||||
|
|
||||||
|
if (settings.AllowPartialMapping == true)
|
||||||
|
{
|
||||||
|
AllowPartialMapping();
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.StartAdminInterface == true)
|
if (settings.StartAdminInterface == true)
|
||||||
{
|
{
|
||||||
|
if (!string.IsNullOrEmpty(settings.AdminUsername) && !string.IsNullOrEmpty(settings.AdminPassword))
|
||||||
|
{
|
||||||
|
SetBasicAuthentication(settings.AdminUsername, settings.AdminPassword);
|
||||||
|
}
|
||||||
|
|
||||||
InitAdmin();
|
InitAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,5 +54,20 @@
|
|||||||
/// StartTimeout
|
/// StartTimeout
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int StartTimeout { get; set; } = 10000;
|
public int StartTimeout { get; set; } = 10000;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Allow Partial Mapping (default set to false).
|
||||||
|
/// </summary>
|
||||||
|
public bool? AllowPartialMapping { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The username needed for __admin access.
|
||||||
|
/// </summary>
|
||||||
|
public string AdminUsername { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The password needed for __admin access.
|
||||||
|
/// </summary>
|
||||||
|
public string AdminPassword { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user