mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Fixing CanCreateApiKeys test admin user check
This commit is contained in:
parent
2934c27ee5
commit
a303e793b4
3 changed files with 9 additions and 8 deletions
|
@ -53,6 +53,9 @@ namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
NBXplorerUri = ExplorerClient.Address,
|
NBXplorerUri = ExplorerClient.Address,
|
||||||
TestDatabase = Enum.Parse<TestDatabases>(GetEnvironment("TESTS_DB", TestDatabases.Postgres.ToString()), true),
|
TestDatabase = Enum.Parse<TestDatabases>(GetEnvironment("TESTS_DB", TestDatabases.Postgres.ToString()), true),
|
||||||
|
// TODO: The fact that we use same conn string as development database can cause huge problems with tests
|
||||||
|
// since in dev we already can have some users / stores registered, while on CI database is being initalized
|
||||||
|
// for the first time and first registered user gets admin status by default
|
||||||
Postgres = GetEnvironment("TESTS_POSTGRES", "User ID=postgres;Host=127.0.0.1;Port=39372;Database=btcpayserver"),
|
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")
|
MySQL = GetEnvironment("TESTS_MYSQL", "User ID=root;Host=127.0.0.1;Port=33036;Database=btcpayserver")
|
||||||
};
|
};
|
||||||
|
|
|
@ -146,6 +146,7 @@ namespace BTCPayServer.Tests
|
||||||
};
|
};
|
||||||
await account.Register(RegisterDetails);
|
await account.Register(RegisterDetails);
|
||||||
UserId = account.RegisteredUserId;
|
UserId = account.RegisteredUserId;
|
||||||
|
IsAdmin = account.RegisteredAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegisterViewModel RegisterDetails{ get; set; }
|
public RegisterViewModel RegisterDetails{ get; set; }
|
||||||
|
|
|
@ -447,12 +447,13 @@ namespace BTCPayServer.Controllers
|
||||||
var settings = await _SettingsRepository.GetSettingAsync<ThemeSettings>();
|
var settings = await _SettingsRepository.GetSettingAsync<ThemeSettings>();
|
||||||
settings.FirstRun = false;
|
settings.FirstRun = false;
|
||||||
await _SettingsRepository.UpdateSetting<ThemeSettings>(settings);
|
await _SettingsRepository.UpdateSetting<ThemeSettings>(settings);
|
||||||
if(_Options.DisableRegistration)
|
if (_Options.DisableRegistration)
|
||||||
{
|
{
|
||||||
// Once the admin user has been created lock subsequent user registrations (needs to be disabled for unit tests that require multiple users).
|
// Once the admin user has been created lock subsequent user registrations (needs to be disabled for unit tests that require multiple users).
|
||||||
policies.LockSubscription = true;
|
policies.LockSubscription = true;
|
||||||
await _SettingsRepository.UpdateSetting(policies);
|
await _SettingsRepository.UpdateSetting(policies);
|
||||||
}
|
}
|
||||||
|
RegisteredAdmin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
|
||||||
|
@ -479,13 +480,9 @@ namespace BTCPayServer.Controllers
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
// Properties used by tests
|
||||||
/// Test property
|
public string RegisteredUserId { get; set; }
|
||||||
/// </summary>
|
public bool RegisteredAdmin { get; set; }
|
||||||
public string RegisteredUserId
|
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Logout()
|
public async Task<IActionResult> Logout()
|
||||||
|
|
Loading…
Add table
Reference in a new issue