## 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
This commit was merged in pull request #108.
This commit is contained in:
@@ -432,4 +432,114 @@ public class OpenZaakGatewayTests
|
||||
b64 = (b64.Length % 4) switch { 2 => b64 + "==", 3 => b64 + "=", _ => b64 };
|
||||
return Encoding.UTF8.GetString(Convert.FromBase64String(b64));
|
||||
}
|
||||
|
||||
// --- StoreDocumentAsync (diploma upload / S-10b) ---
|
||||
|
||||
private static readonly Uri Informatieobjecttype =
|
||||
new("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip");
|
||||
|
||||
private static DocumentRequest SampleDocument(byte[]? inhoud = null) => new(
|
||||
Bronorganisatie: "517439943",
|
||||
Informatieobjecttype: Informatieobjecttype,
|
||||
Vertrouwelijkheidaanduiding: "openbaar",
|
||||
Zaak: new Uri(ZaakUrl),
|
||||
Creatiedatum: new DateOnly(2026, 6, 4),
|
||||
Titel: "Diploma",
|
||||
Auteur: "zorgprofessional",
|
||||
Taal: "nld",
|
||||
Bestandsnaam: "diploma.pdf",
|
||||
Formaat: "application/pdf",
|
||||
Inhoud: inhoud ?? [1, 2, 3, 4]);
|
||||
|
||||
// Routes the two document calls: POST /enkelvoudiginformatieobjecten (documenten) then
|
||||
// POST /zaakinformatieobjecten (zaken).
|
||||
private static StubHandler DocumentStub(Recorder rec) => new(async req =>
|
||||
{
|
||||
rec.Requests.Add(req);
|
||||
rec.ContentLengths.Add(req.Content?.Headers.ContentLength);
|
||||
rec.Bodies.Add(req.Content is null ? null : await req.Content.ReadAsStringAsync());
|
||||
|
||||
return req.RequestUri!.ToString().Contains("/enkelvoudiginformatieobjecten")
|
||||
? Json(HttpStatusCode.Created, """{"url":"http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/doc-1"}""")
|
||||
: Json(HttpStatusCode.Created, """{"url":"http://openzaak/zaken/api/v1/zaakinformatieobjecten/rel-1"}""");
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_document_creates_the_informatieobject_then_relates_it_to_the_zaak()
|
||||
{
|
||||
var rec = new Recorder();
|
||||
|
||||
var url = await Gateway(DocumentStub(rec)).StoreDocumentAsync(SampleDocument([10, 20, 30]));
|
||||
|
||||
Assert.Equal("http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/doc-1", url.ToString());
|
||||
|
||||
// 1. Create the enkelvoudiginformatieobject in the Documenten API.
|
||||
var create = rec.Sent("/enkelvoudiginformatieobjecten");
|
||||
Assert.Equal(HttpMethod.Post, create.Request.Method);
|
||||
Assert.Equal("http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten",
|
||||
create.Request.RequestUri!.ToString());
|
||||
Assert.Equal("Bearer", create.Request.Headers.Authorization!.Scheme);
|
||||
Assert.Contains("\"bronorganisatie\":\"517439943\"", create.Body);
|
||||
Assert.Contains("\"informatieobjecttype\":\"http://openzaak/catalogi/api/v1/informatieobjecttypen/dip\"", create.Body);
|
||||
Assert.Contains("\"creatiedatum\":\"2026-06-04\"", create.Body);
|
||||
Assert.Contains("\"titel\":\"Diploma\"", create.Body);
|
||||
Assert.Contains("\"auteur\":\"zorgprofessional\"", create.Body);
|
||||
Assert.Contains("\"taal\":\"nld\"", create.Body);
|
||||
Assert.Contains("\"bestandsnaam\":\"diploma.pdf\"", create.Body);
|
||||
Assert.Contains("\"formaat\":\"application/pdf\"", create.Body);
|
||||
Assert.Contains("\"vertrouwelijkheidaanduiding\":\"openbaar\"", create.Body);
|
||||
Assert.Contains("\"status\":\"definitief\"", create.Body);
|
||||
// indicatieGebruiksrecht must be set explicitly (false = no usage restrictions); left null,
|
||||
// OpenZaak refuses to close the zaak this document is related to ("indicatiegebruiksrecht-unset").
|
||||
Assert.Contains("\"indicatieGebruiksrecht\":false", create.Body);
|
||||
// The file content is base64-encoded into `inhoud`, with its byte length in `bestandsomvang`.
|
||||
Assert.Contains($"\"inhoud\":\"{Convert.ToBase64String([10, 20, 30])}\"", create.Body);
|
||||
Assert.Contains("\"bestandsomvang\":3", create.Body);
|
||||
|
||||
// 2. Relate that informatieobject to the zaak (Zaken API — no CRS).
|
||||
var relate = rec.Sent("/zaakinformatieobjecten");
|
||||
Assert.Equal(HttpMethod.Post, relate.Request.Method);
|
||||
Assert.Equal("http://openzaak/zaken/api/v1/zaakinformatieobjecten",
|
||||
relate.Request.RequestUri!.ToString());
|
||||
Assert.Contains($"\"zaak\":\"{ZaakUrl}\"", relate.Body);
|
||||
Assert.Contains("\"informatieobject\":\"http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/doc-1\"", relate.Body);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_document_buffers_the_body_and_sends_no_crs_headers()
|
||||
{
|
||||
// uwsgi rejects a chunked body (Content-Length must be present); the Documenten API is not a
|
||||
// geo API, so no CRS headers (unlike the Zaken zaak-create).
|
||||
var rec = new Recorder();
|
||||
|
||||
await Gateway(DocumentStub(rec)).StoreDocumentAsync(SampleDocument());
|
||||
|
||||
var create = rec.Sent("/enkelvoudiginformatieobjecten");
|
||||
Assert.NotNull(create.Length);
|
||||
Assert.True(create.Length > 0);
|
||||
Assert.False(create.Request.Headers.Contains("Accept-Crs"));
|
||||
Assert.False(create.Request.Content!.Headers.Contains("Content-Crs"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_document_surfaces_an_openzaak_rejection()
|
||||
{
|
||||
var handler = new StubHandler(_ =>
|
||||
Task.FromResult(new HttpResponseMessage(HttpStatusCode.BadRequest)
|
||||
{
|
||||
Content = new StringContent("""{"detail":"bad"}""", Encoding.UTF8, "application/json"),
|
||||
}));
|
||||
|
||||
var ex = await Assert.ThrowsAsync<HttpRequestException>(
|
||||
() => Gateway(handler).StoreDocumentAsync(SampleDocument()));
|
||||
Assert.Contains("bad", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_document_rejects_a_null_request()
|
||||
{
|
||||
var handler = new StubHandler(_ => throw new InvalidOperationException("should not be sent"));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => Gateway(handler).StoreDocumentAsync(null!));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user