Initial curated itworx-knowledge-hub source from 3b1751d0d9dee551aa6994eee0093704dc334817
This commit is contained in:
commit
ad8ad252a9
825 files changed
+124216
No files matched your search
+47
@@ -0,0 +1,47 @@
|
||||
namespace ItWorx.KnowledgeHub.IntegrationTests.Infrastructure;
|
||||
|
||||
/// <summary>
|
||||
/// Base for test classes that need an already-completed first-run setup (an owner
|
||||
/// account, in an isolated database, ready to log in). Each test class gets its own
|
||||
/// database and its own owner — never a shared mutable fixture between test classes.
|
||||
/// </summary>
|
||||
public abstract class OwnerSetupTestBase : IAsyncLifetime
|
||||
{
|
||||
protected OwnerSetupTestBase(
|
||||
PostgresContainerFixture postgres,
|
||||
IReadOnlyDictionary<string, string?>? additionalConfiguration = null)
|
||||
{
|
||||
Factory = new KnowledgeHubIntegrationFactory(postgres, additionalConfiguration);
|
||||
}
|
||||
|
||||
protected KnowledgeHubIntegrationFactory Factory { get; }
|
||||
|
||||
protected string OwnerEmail { get; } = "eigenaar@itworx.test";
|
||||
|
||||
protected string OwnerPassword { get; } = "correct-horse-battery-staple";
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
await ((IAsyncLifetime)Factory).InitializeAsync();
|
||||
|
||||
using var client = Factory.CreateClient();
|
||||
|
||||
var response = await SetupHelper.CompleteFirstRunSetupAsync(
|
||||
client,
|
||||
"ItWorx Testomgeving",
|
||||
"Eigenaar Testpersoon",
|
||||
OwnerEmail,
|
||||
OwnerPassword);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var body = await response.Content.ReadAsStringAsync();
|
||||
throw new InvalidOperationException($"First-run setup failed ({response.StatusCode}): {body}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DisposeAsync()
|
||||
{
|
||||
await ((IAsyncLifetime)Factory).DisposeAsync();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user