Files
Justin Baur 550968bf41 Update to IHostBuilder style (#6843)
* Add some integration tests for the Server project

* Not sure why this project got removed?

* Format

* capture debug output

* Update tests to work with the now legacy WebHostBuilder

- I accidentally had the updated Program locally and that was why tests were working for me locally

* Formatting...again

* Update to `IHostBuilder` style

* Formatting
2026-03-27 11:09:05 -04:00

39 lines
1.1 KiB
C#

using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
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; }
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);
var config = new Dictionary<string, string?>
{
{"contentRoot", ContentRoot},
{"webRoot", WebRoot},
{"serveUnknown", ServeUnknown.ToString().ToLowerInvariant()},
};
if (WebVault.HasValue)
{
config["webVault"] = WebVault.Value.ToString().ToLowerInvariant();
}
if (!string.IsNullOrEmpty(AppIdLocation))
{
config["appIdLocation"] = AppIdLocation;
}
builder.UseConfiguration(new ConfigurationBuilder().AddInMemoryCollection(config).Build());
}
}