All checks were successful
## What & why S-09b (#75, split from #10) — the **approval flow** that completes the walking skeleton. A behandelaar can now approve a submitted registration; the entry flips from `INGEDIEND` to `INGESCHREVEN` in the public register. Flow: `POST /registrations/{id}/approve` (domain) → ACL sets the zaak eindstatus (ZGW `/statussen`) → OpenZaak → NRC → event-subscriber → projection → openbaar. ## Changes (bottom-up, each red→green TDD) - **Domain** — `RegistrationStatus.Ingeschreven` + `Registration.Approve()` (guards: opened zaak, only from INGEDIEND); `ApproveRegistration` use case (idempotent) + temp `POST /registrations/{id}/approve` endpoint; `IAclClient.ApproveZaakAsync`. - **ACL** — resolves the zaaktype's **eindstatus** from the catalogus (`isEindstatus` / highest volgnummer) and POSTs a ZGW status; exposed as `POST /statussen`. Unit + real-OpenZaak integration test. - **Event-subscriber** — binds NRC `hoofdObject`, projects a `status`/`create` as `INGESCHREVEN` keyed on the zaak (updates the existing row), **without reading OpenZaak** (§8.1). Retains the ZGW `resource` in the log (new column + EF migration) so a rebuild reproduces the status. - **e2e** — extended: submit → public INGEDIEND → approve → public INGESCHREVEN. - **Docs** — ADR-0011 (the two non-obvious decisions + the walking-skeleton assumption) + demo note. ## Key decisions (see ADR-0011) - **ACL discovers the eindstatus** (chosen over injecting a statustype URL): no new config/seed plumbing, domain stays ZGW-ignorant. - **Any post-creation status-set ⇒ INGESCHREVEN**: in the walking skeleton the only status ever set after creation is the approval, and the subscriber may not read ZGW — documented to tighten when more transitions arrive (S-12+). ## Verification - All .NET unit suites green locally (domain 47, acl 11, event-subscriber 14, bff 16, acceptance 7); Release build + `dotnet format` clean. - No new compose config (the eindstatus-discovery approach avoided it). - The real-OpenZaak integration test (ACL status-set) and the full submit→approve→visible e2e run in CI `verify-stack` (live NRC→projection + selectielijst egress, not reproducible locally). closes #75 Reviewed-on: #77
74 lines
3.4 KiB
C#
74 lines
3.4 KiB
C#
using Acl.Application;
|
|
using Acl.Infrastructure;
|
|
|
|
namespace Acl.IntegrationTests;
|
|
|
|
/// <summary>
|
|
/// S-04a (#46): the deferred S-04 acceptance criterion — the ACL's OpenZaakGateway
|
|
/// opening a zaak against a *real* OpenZaak, exercising real ZGW JWT auth and the
|
|
/// real POST /zaken/api/v1/zaken contract (CRS headers, default-fill, the created
|
|
/// zaak URL) that the stubbed-HttpMessageHandler unit tests cannot. See ADR-0006.
|
|
/// </summary>
|
|
[Trait("Category", "Integration")]
|
|
[Collection(OpenZaakCollection.Name)]
|
|
public sealed class OpenZaakGatewayIntegrationTests(OpenZaakFixture stack)
|
|
{
|
|
[Fact]
|
|
public async Task Opens_a_real_zaak_against_the_published_big_zaaktype_and_returns_its_url()
|
|
{
|
|
var zaaktype = await stack.FindPublishedBigZaaktypeAsync();
|
|
Assert.True(zaaktype is not null,
|
|
"No published BIG-REGISTRATIE zaaktype found in OpenZaak — bring the stack up and " +
|
|
"seed it with OZ_PUBLISH=1 (`make integration` does this).");
|
|
|
|
var gateway = new OpenZaakGateway(stack.Http, stack.Options);
|
|
var request = new ZaakRequest(
|
|
Bronorganisatie: "517439943",
|
|
VerantwoordelijkeOrganisatie: "517439943",
|
|
Vertrouwelijkheidaanduiding: "openbaar",
|
|
Zaaktype: zaaktype!,
|
|
Startdatum: DateOnly.FromDateTime(DateTime.UtcNow));
|
|
|
|
var zaakUrl = await gateway.OpenZaakAsync(request);
|
|
|
|
// The gateway returns the canonical zaak URL on OpenZaak's Zaken API...
|
|
Assert.StartsWith(
|
|
new Uri(stack.BaseUrl, "/zaken/api/v1/zaken/").ToString(),
|
|
zaakUrl.ToString());
|
|
|
|
// ...and that zaak is really persisted with the default-filled fields.
|
|
var zaak = await stack.GetZaakAsync(zaakUrl);
|
|
Assert.Equal(zaaktype.ToString(), zaak.GetProperty("zaaktype").GetString());
|
|
Assert.Equal("517439943", zaak.GetProperty("bronorganisatie").GetString());
|
|
Assert.Equal("openbaar", zaak.GetProperty("vertrouwelijkheidaanduiding").GetString());
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Setting_a_zaak_to_its_eindstatus_records_the_terminal_statustype()
|
|
{
|
|
var zaaktype = await stack.FindPublishedBigZaaktypeAsync();
|
|
Assert.True(zaaktype is not null,
|
|
"No published BIG-REGISTRATIE zaaktype found in OpenZaak — bring the stack up and " +
|
|
"seed it with OZ_PUBLISH=1 (`make integration` does this).");
|
|
|
|
var gateway = new OpenZaakGateway(stack.Http, stack.Options);
|
|
var zaakUrl = await gateway.OpenZaakAsync(new ZaakRequest(
|
|
Bronorganisatie: "517439943",
|
|
VerantwoordelijkeOrganisatie: "517439943",
|
|
Vertrouwelijkheidaanduiding: "openbaar",
|
|
Zaaktype: zaaktype!,
|
|
Startdatum: DateOnly.FromDateTime(DateTime.UtcNow)));
|
|
|
|
await gateway.SetZaakToEindstatusAsync(zaakUrl, zaaktype!, DateOnly.FromDateTime(DateTime.UtcNow));
|
|
|
|
// The zaak now carries a current status, and it is the zaaktype's eindstatus.
|
|
var zaak = await stack.GetZaakAsync(zaakUrl);
|
|
var statusUrl = zaak.GetProperty("status").GetString();
|
|
Assert.False(string.IsNullOrEmpty(statusUrl), "the approved zaak has no current status");
|
|
|
|
var status = await stack.GetJsonAsync(new Uri(statusUrl!));
|
|
var eindstatustype = await stack.FindEindstatustypeAsync(zaaktype!);
|
|
Assert.Equal(eindstatustype.ToString(), status.GetProperty("statustype").GetString());
|
|
}
|
|
}
|