Can create user without authentication if there is no admin

This commit is contained in:
nicolas.dorier
2020-03-18 23:10:15 +09:00
parent 540a31207e
commit e50e3f662d
9 changed files with 189 additions and 46 deletions

View File

@@ -29,13 +29,13 @@ namespace BTCPayServer.Tests
{
public class ServerTester : IDisposable
{
public static ServerTester Create([CallerMemberNameAttribute]string scope = null)
public static ServerTester Create([CallerMemberNameAttribute]string scope = null, bool newDb = false)
{
return new ServerTester(scope);
return new ServerTester(scope, newDb);
}
string _Directory;
public ServerTester(string scope)
public ServerTester(string scope, bool newDb)
{
_Directory = scope;
if (Directory.Exists(_Directory))
@@ -59,6 +59,12 @@ namespace BTCPayServer.Tests
Postgres = GetEnvironment("TESTS_POSTGRES", "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver"),
MySQL = GetEnvironment("TESTS_MYSQL", "User ID=root;Host=127.0.0.1;Port=33036;Database=btcpayserver")
};
if (newDb)
{
var r = RandomUtils.GetUInt32();
PayTester.Postgres = PayTester.Postgres.Replace("btcpayserver", $"btcpayserver{r}");
PayTester.MySQL = PayTester.MySQL.Replace("btcpayserver", $"btcpayserver{r}");
}
PayTester.Port = int.Parse(GetEnvironment("TESTS_PORT", Utils.FreeTcpPort().ToString(CultureInfo.InvariantCulture)), CultureInfo.InvariantCulture);
PayTester.HostName = GetEnvironment("TESTS_HOSTNAME", "127.0.0.1");
PayTester.InContainer = bool.Parse(GetEnvironment("TESTS_INCONTAINER", "false"));