mirror of
https://github.com/bitwarden/server.git
synced 2026-02-05 16:43:14 +08:00
Add some integration tests for the Server project
This commit is contained in:
44
test/Server.IntegrationTest/Server.cs
Normal file
44
test/Server.IntegrationTest/Server.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
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);
|
||||
|
||||
builder.ConfigureLogging(logging =>
|
||||
{
|
||||
logging.SetMinimumLevel(LogLevel.Debug);
|
||||
});
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user