## What & why S-10b: the self-service **diploma upload** is now real. After submitting, the citizen picks a PDF and uploads it; the portal base64-encodes it client-side → BFF → domain → **ACL**, which stores it in the ZGW **Documenten (DRC) API** as an `enkelvoudiginformatieobject` and relates it to the zaak, then the `WachtOpDocumenten` wait completes and the case advances to beoordeling. Per §8.1 only the ACL talks to ZGW. Closes #103 Mechanism in **ADR-0018** (proposal #107). Builds on S-10a (#102). The zaak-close-on-expiry item is carved to **#106 (S-10c)**. ## Definition of Done - [x] Linked Gitea issue (above). - [x] Failing test committed before the implementation (red→green per layer). - [x] Conventional Commits referencing the issue (`refs #103`). - [ ] CI green — all Gitea Actions jobs (pending on this PR). - [x] `docker compose up` health unaffected (ACL boots on a placeholder informatieobjecttype URL; the real one is injected by verify-domain). - [x] Docs updated (ADR-0018, demo-script, BACKLOG + S-10c). - [x] ADR added (`docs/architecture/adr-0018-diploma-upload-via-acl-documenten.md`). - [x] Demo note in `docs/demo-script.md`. ## Notes for reviewers - **ACL** (`OpenZaakGateway.StoreDocumentAsync` + `AclService.StoreDiplomaAsync` + `POST /documenten`) reuses the existing gateway patterns (ZGW Bearer, buffered non-chunked body, **no CRS** — Documenten isn't geo). Unit-tested via the stub handler; an **integration test** stores a real document against live OpenZaak (verify-acl). - **Transport:** base64 JSON on every hop (portal encodes client-side) — I deviated from proposal #107's multipart to keep one contract shape and avoid `IFormFile`/antiforgery/multipart-client plumbing; fine at diploma size (ADR-0018 §Alternatives). - **Infra:** `seed_catalogus.py` seeds + publishes a "Diploma" `informatieobjecttype` and relates it to the zaaktype (while both concept); `verify-domain` injects its URL into the ACL. No new ZGW scopes (seed applicatie has `heeft_alle_autorisaties`). - **e2e:** uploads a real PDF (`setInputFiles`) after the openbaar INGEDIEND row confirms the zaak is open (so storage doesn't race the OpenZaak worker). - **Scope boundary:** the ZGW zaak is not set to a cancellation status on 30-day expiry — that's #106 (S-10c). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #108
132 lines
6.6 KiB
C#
132 lines
6.6 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 reference = Guid.NewGuid().ToString(); // zaak identificatie must be unique per bronorganisatie
|
|
var request = new ZaakRequest(
|
|
Bronorganisatie: "517439943",
|
|
VerantwoordelijkeOrganisatie: "517439943",
|
|
Vertrouwelijkheidaanduiding: "openbaar",
|
|
Zaaktype: zaaktype!,
|
|
Startdatum: DateOnly.FromDateTime(DateTime.UtcNow),
|
|
Identificatie: reference);
|
|
|
|
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 + the reference identificatie.
|
|
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());
|
|
Assert.Equal(reference, zaak.GetProperty("identificatie").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),
|
|
Identificatie: Guid.NewGuid().ToString()));
|
|
|
|
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());
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Storing_a_diploma_creates_a_real_informatieobject_related_to_the_zaak()
|
|
{
|
|
var zaaktype = await stack.FindPublishedBigZaaktypeAsync();
|
|
Assert.True(zaaktype is not null,
|
|
"No published BIG-REGISTRATIE zaaktype found — seed the stack with OZ_PUBLISH=1.");
|
|
var informatieobjecttype = await stack.FindPublishedDiplomaInformatieobjecttypeAsync();
|
|
Assert.True(informatieobjecttype is not null,
|
|
"No published Diploma informatieobjecttype found — seed the stack with OZ_PUBLISH=1.");
|
|
|
|
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),
|
|
Identificatie: Guid.NewGuid().ToString()));
|
|
|
|
var content = System.Text.Encoding.UTF8.GetBytes("%PDF-1.4 synthetic diploma\n");
|
|
var documentUrl = await gateway.StoreDocumentAsync(new DocumentRequest(
|
|
Bronorganisatie: "517439943",
|
|
Informatieobjecttype: informatieobjecttype!,
|
|
Vertrouwelijkheidaanduiding: "openbaar",
|
|
Zaak: zaakUrl,
|
|
Creatiedatum: DateOnly.FromDateTime(DateTime.UtcNow),
|
|
Titel: "Diploma",
|
|
Auteur: "zorgprofessional",
|
|
Taal: "nld",
|
|
Bestandsnaam: "diploma.pdf",
|
|
Formaat: "application/pdf",
|
|
Inhoud: content));
|
|
|
|
// The gateway returns the canonical informatieobject URL...
|
|
Assert.StartsWith(
|
|
new Uri(stack.BaseUrl, "/documenten/api/v1/enkelvoudiginformatieobjecten/").ToString(),
|
|
documentUrl.ToString());
|
|
|
|
// ...the document is really persisted with the default-filled fields...
|
|
var doc = await stack.GetJsonAsync(documentUrl);
|
|
Assert.Equal("diploma.pdf", doc.GetProperty("bestandsnaam").GetString());
|
|
Assert.Equal(informatieobjecttype.ToString(), doc.GetProperty("informatieobjecttype").GetString());
|
|
Assert.Equal(content.Length, doc.GetProperty("bestandsomvang").GetInt32());
|
|
// indicatieGebruiksrecht is recorded as "no restrictions"; left null, OpenZaak would refuse to
|
|
// close the zaak this document is related to (the S-10b regression that broke the e2e flow).
|
|
Assert.False(doc.GetProperty("indicatieGebruiksrecht").GetBoolean());
|
|
|
|
// ...and it is related to the zaak (a zaakinformatieobject links the two).
|
|
var relations = await stack.GetJsonAsync(new Uri(stack.BaseUrl,
|
|
"/zaken/api/v1/zaakinformatieobjecten?informatieobject=" + Uri.EscapeDataString(documentUrl.ToString())));
|
|
Assert.Contains(relations.EnumerateArray(),
|
|
r => r.GetProperty("zaak").GetString() == zaakUrl.ToString());
|
|
}
|
|
}
|