mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
[PS-1928] Add BumpAccountRevisionDate
methods (#2458)
* Move RevisionDate Bumps to Extension Class * Add Tests against live databases * Run Formatting * Fix Typo * Fix Test Solution Typo * Await ReplaceAsync
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Infrastructure.IntegrationTest;
|
||||
|
||||
public class DatabaseTheoryAttribute : TheoryAttribute
|
||||
{
|
||||
private static IConfiguration? _cachedConfiguration;
|
||||
|
||||
public const string DapperSqlServerKey = "Dapper:SqlServer";
|
||||
public const string EfPostgresKey = "Ef:Postgres";
|
||||
public const string EfMySqlKey = "Ef:MySql";
|
||||
|
||||
public DatabaseTheoryAttribute()
|
||||
{
|
||||
if (!HasAnyDatabaseSetup())
|
||||
{
|
||||
Skip = "No database connections strings setup.";
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasAnyDatabaseSetup()
|
||||
{
|
||||
var config = GetConfiguration();
|
||||
return config.TryGetConnectionString(DapperSqlServerKey, out _) ||
|
||||
config.TryGetConnectionString(EfPostgresKey, out _) ||
|
||||
config.TryGetConnectionString(EfMySqlKey, out _);
|
||||
}
|
||||
|
||||
public static IConfiguration GetConfiguration()
|
||||
{
|
||||
return _cachedConfiguration ??= new ConfigurationBuilder()
|
||||
.AddUserSecrets<DatabaseDataAttribute>(optional: true, reloadOnChange: false)
|
||||
.AddEnvironmentVariables("BW_TEST_")
|
||||
.AddCommandLine(Environment.GetCommandLineArgs())
|
||||
.Build();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user