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
78 lines
2.8 KiB
C#
78 lines
2.8 KiB
C#
using System.Net;
|
|
using Big.Infrastructure;
|
|
|
|
namespace Big.Tests;
|
|
|
|
public class AclHttpClientTests
|
|
{
|
|
private static AclHttpClient Client(StubHandler handler) => new(
|
|
new HttpClient(handler), new AclOptions { BaseUrl = new("http://acl/") });
|
|
|
|
[Fact]
|
|
public async Task Opens_a_zaak_by_posting_the_bsn_and_returns_the_zaak_url()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.OK,
|
|
"""{"zaakUrl":"http://openzaak/zaken/api/v1/zaken/abc"}"""));
|
|
|
|
var url = await client.OpenZaakAsync("123456782");
|
|
|
|
Assert.Equal("http://openzaak/zaken/api/v1/zaken/abc", url.ToString());
|
|
Assert.Equal(HttpMethod.Post, capture.Seen!.Method);
|
|
Assert.Equal("http://acl/zaken", capture.Seen.RequestUri!.ToString());
|
|
Assert.Contains("\"bsn\":\"123456782\"", capture.Body);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Throws_when_the_acl_rejects_the_request()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.BadGateway));
|
|
|
|
await Assert.ThrowsAsync<HttpRequestException>(() => client.OpenZaakAsync("123456782"));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Throws_when_the_acl_returns_an_empty_body()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.OK, "null"));
|
|
|
|
var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => client.OpenZaakAsync("123456782"));
|
|
Assert.Contains("empty", ex.Message, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Approves_a_zaak_by_posting_its_url_to_statussen()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.NoContent));
|
|
|
|
await client.ApproveZaakAsync(new Uri("http://openzaak/zaken/api/v1/zaken/abc"));
|
|
|
|
Assert.Equal(HttpMethod.Post, capture.Seen!.Method);
|
|
Assert.Equal("http://acl/statussen", capture.Seen.RequestUri!.ToString());
|
|
Assert.Contains("\"zaakUrl\":\"http://openzaak/zaken/api/v1/zaken/abc\"", capture.Body);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Approve_throws_when_the_acl_rejects_the_request()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.BadGateway));
|
|
|
|
await Assert.ThrowsAsync<HttpRequestException>(
|
|
() => client.ApproveZaakAsync(new Uri("http://openzaak/zaken/api/v1/zaken/abc")));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Approve_rejects_a_null_zaak_url_without_sending_a_request()
|
|
{
|
|
var capture = new RequestCapture();
|
|
var client = Client(capture.Responds(HttpStatusCode.NoContent));
|
|
|
|
await Assert.ThrowsAsync<ArgumentNullException>(() => client.ApproveZaakAsync(null!));
|
|
Assert.Null(capture.Seen);
|
|
}
|
|
}
|