Initial curated itworx-knowledge-hub source from 3b1751d0d9dee551aa6994eee0093704dc334817
This commit is contained in:
commit
ad8ad252a9
825 files changed
+124216
No files matched your search
@@ -0,0 +1,67 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using ItWorx.KnowledgeHub.Contracts.Setup;
|
||||
using ItWorx.KnowledgeHub.IntegrationTests.Infrastructure;
|
||||
|
||||
namespace ItWorx.KnowledgeHub.IntegrationTests.Setup;
|
||||
|
||||
[Collection(PostgresTestGroup.Name)]
|
||||
public sealed class FirstRunSetupTests(PostgresContainerFixture postgres) : IAsyncLifetime, IDisposable
|
||||
{
|
||||
private readonly KnowledgeHubIntegrationFactory _factory = new(postgres);
|
||||
|
||||
public Task InitializeAsync() => ((IAsyncLifetime)_factory).InitializeAsync();
|
||||
|
||||
public Task DisposeAsync() => ((IAsyncLifetime)_factory).DisposeAsync();
|
||||
|
||||
public void Dispose() => _factory.Dispose();
|
||||
|
||||
[Fact]
|
||||
public async Task Status_reports_setup_required_before_first_run()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
|
||||
var status = await client.GetFromJsonAsync<SetupStatusResponse>("/api/v1/setup/status");
|
||||
|
||||
Assert.NotNull(status);
|
||||
Assert.True(status.SetupRequired);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Complete_creates_the_owner_and_permanently_disables_further_setup()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
|
||||
var first = await SetupHelper.CompleteFirstRunSetupAsync(
|
||||
client, "ItWorx Kennisbank", "Eerste Eigenaar", "eigenaar@itworx.test", "correct-horse-battery-staple");
|
||||
Assert.Equal(HttpStatusCode.OK, first.StatusCode);
|
||||
|
||||
var payload = await first.Content.ReadFromJsonAsync<CompleteSetupResponse>();
|
||||
Assert.NotNull(payload);
|
||||
Assert.NotEqual(Guid.Empty, payload.WorkspaceId);
|
||||
Assert.NotEqual(Guid.Empty, payload.UserId);
|
||||
|
||||
var statusAfter = await client.GetFromJsonAsync<SetupStatusResponse>("/api/v1/setup/status");
|
||||
Assert.NotNull(statusAfter);
|
||||
Assert.False(statusAfter.SetupRequired);
|
||||
|
||||
// A second attempt with different owner details must never succeed. This is the
|
||||
// "single-use" M1-A01
|
||||
// acceptance criterion, not just "the UI hides the form afterward".
|
||||
var second = await SetupHelper.CompleteFirstRunSetupAsync(
|
||||
client, "Andere Werkruimte", "Tweede Poging", "indringer@itworx.test", "another-strong-password");
|
||||
Assert.Equal(HttpStatusCode.Conflict, second.StatusCode);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task Complete_rejects_a_password_below_the_minimum_length()
|
||||
{
|
||||
using var client = _factory.CreateClient();
|
||||
|
||||
var response = await SetupHelper.CompleteFirstRunSetupAsync(
|
||||
client, "ItWorx Kennisbank", "Iemand", "iemand@itworx.test", "kort");
|
||||
|
||||
Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user