feat(acl): store a diploma in the Documenten API and relate it to the zaak (refs #103)
IZaakGateway.StoreDocumentAsync creates an enkelvoudiginformatieobject (base64 inhoud, buffered non-chunked body, no CRS) and relates it via zaakinformatieobjecten; AclService.StoreDiplomaAsync default-fills the ZGW document fields (informatieobjecttype, bronorganisatie, taal nld, creatiedatum); POST /documenten exposes it. Adds the InformatieobjecttypeUrl default (wired in a following infra commit). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,15 @@ public class AclServiceTests
|
||||
ReadReferenceFor = zaakUrl;
|
||||
return Task.FromResult("REG-FROM-ZAAK");
|
||||
}
|
||||
|
||||
public DocumentRequest? StoredDocument;
|
||||
public Uri DocumentResult { get; } = new("http://openzaak/documenten/api/v1/enkelvoudiginformatieobjecten/doc-1");
|
||||
|
||||
public Task<Uri> StoreDocumentAsync(DocumentRequest request, CancellationToken ct = default)
|
||||
{
|
||||
StoredDocument = request;
|
||||
return Task.FromResult(DocumentResult);
|
||||
}
|
||||
}
|
||||
|
||||
private static AclDefaults Defaults() => new()
|
||||
@@ -38,6 +47,7 @@ public class AclServiceTests
|
||||
VerantwoordelijkeOrganisatie = "517439943",
|
||||
Vertrouwelijkheidaanduiding = "openbaar",
|
||||
ZaaktypeUrl = new("http://openzaak/catalogi/api/v1/zaaktypen/big"),
|
||||
InformatieobjecttypeUrl = new("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip"),
|
||||
};
|
||||
|
||||
private sealed class FixedClock(DateOnly today) : IClock
|
||||
@@ -55,6 +65,7 @@ public class AclServiceTests
|
||||
VerantwoordelijkeOrganisatie = "517439943",
|
||||
Vertrouwelijkheidaanduiding = "openbaar",
|
||||
ZaaktypeUrl = new("http://openzaak/catalogi/api/v1/zaaktypen/big"),
|
||||
InformatieobjecttypeUrl = new("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip"),
|
||||
};
|
||||
var service = new AclService(gateway, defaults, new FixedClock(new DateOnly(2026, 6, 4)));
|
||||
|
||||
@@ -81,6 +92,7 @@ public class AclServiceTests
|
||||
VerantwoordelijkeOrganisatie = "517439943",
|
||||
Vertrouwelijkheidaanduiding = "openbaar",
|
||||
ZaaktypeUrl = new("http://openzaak/catalogi/api/v1/zaaktypen/big"),
|
||||
InformatieobjecttypeUrl = new("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip"),
|
||||
};
|
||||
var service = new AclService(gateway, defaults, new FixedClock(new DateOnly(2026, 6, 4)));
|
||||
|
||||
@@ -114,6 +126,41 @@ public class AclServiceTests
|
||||
Assert.Null(gateway.Approved);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_diploma_default_fills_the_document_fields_and_returns_its_url()
|
||||
{
|
||||
var gateway = new FakeGateway();
|
||||
var defaults = Defaults();
|
||||
var service = new AclService(gateway, defaults, new FixedClock(new DateOnly(2026, 6, 4)));
|
||||
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
||||
|
||||
var url = await service.StoreDiplomaAsync(zaak, [1, 2, 3], "diploma.pdf", "application/pdf");
|
||||
|
||||
Assert.Equal(gateway.DocumentResult, url);
|
||||
var req = gateway.StoredDocument!;
|
||||
Assert.Equal(zaak, req.Zaak);
|
||||
Assert.Equal(defaults.InformatieobjecttypeUrl, req.Informatieobjecttype);
|
||||
Assert.Equal("517439943", req.Bronorganisatie);
|
||||
Assert.Equal("openbaar", req.Vertrouwelijkheidaanduiding);
|
||||
Assert.Equal(new DateOnly(2026, 6, 4), req.Creatiedatum);
|
||||
Assert.Equal("nld", req.Taal);
|
||||
Assert.Equal("diploma.pdf", req.Bestandsnaam);
|
||||
Assert.Equal("application/pdf", req.Formaat);
|
||||
Assert.Equal(new byte[] { 1, 2, 3 }, req.Inhoud);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Storing_a_diploma_rejects_null_or_blank_arguments()
|
||||
{
|
||||
var service = new AclService(new FakeGateway(), Defaults(), new FixedClock(new DateOnly(2026, 6, 4)));
|
||||
var zaak = new Uri("http://openzaak/zaken/api/v1/zaken/abc");
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => service.StoreDiplomaAsync(null!, [1], "d.pdf", "application/pdf"));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => service.StoreDiplomaAsync(zaak, null!, "d.pdf", "application/pdf"));
|
||||
await Assert.ThrowsAnyAsync<ArgumentException>(() => service.StoreDiplomaAsync(zaak, [1], " ", "application/pdf"));
|
||||
await Assert.ThrowsAnyAsync<ArgumentException>(() => service.StoreDiplomaAsync(zaak, [1], "d.pdf", " "));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Reading_a_zaak_reference_returns_the_zaaks_identificatie()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user