2026-01-14 09:14:21 -05:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2026-01-13 20:34:11 -05:00
|
|
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
2026-01-14 13:32:52 -05:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2026-01-13 20:34:11 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Server.IntegrationTest;
|
|
|
|
|
|
|
|
|
|
|
|
public class Server : WebApplicationFactory<Program>
|
|
|
|
|
|
{
|
|
|
|
|
|
public string? ContentRoot { get; set; }
|
|
|
|
|
|
public string? WebRoot { get; set; }
|
|
|
|
|
|
public bool ServeUnknown { get; set; }
|
|
|
|
|
|
public bool? WebVault { get; set; }
|
|
|
|
|
|
public string? AppIdLocation { get; set; }
|
|
|
|
|
|
|
2026-01-14 13:32:52 -05:00
|
|
|
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
2026-01-13 20:34:11 -05:00
|
|
|
|
{
|
2026-01-14 13:32:52 -05:00
|
|
|
|
base.ConfigureWebHost(builder);
|
|
|
|
|
|
|
|
|
|
|
|
var config = new Dictionary<string, string?>
|
2026-01-13 20:34:11 -05:00
|
|
|
|
{
|
2026-01-14 13:32:52 -05:00
|
|
|
|
{"contentRoot", ContentRoot},
|
|
|
|
|
|
{"webRoot", WebRoot},
|
|
|
|
|
|
{"serveUnknown", ServeUnknown.ToString().ToLowerInvariant()},
|
2026-01-13 20:34:11 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (WebVault.HasValue)
|
|
|
|
|
|
{
|
2026-01-14 13:32:52 -05:00
|
|
|
|
config["webVault"] = WebVault.Value.ToString().ToLowerInvariant();
|
2026-01-13 20:34:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(AppIdLocation))
|
|
|
|
|
|
{
|
2026-01-14 13:32:52 -05:00
|
|
|
|
config["appIdLocation"] = AppIdLocation;
|
2026-01-13 20:34:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-14 13:32:52 -05:00
|
|
|
|
builder.UseConfiguration(new ConfigurationBuilder().AddInMemoryCollection(config).Build());
|
2026-01-13 20:34:11 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|