Adds an ACL↔OpenZaak integration test asserting SetZaakToCancellationStatusAsync records the Geannuleerd status + a resultaat against real OpenZaak, and extends the domain verify script to confirm a timed-out registration's zaak is cancelled to Geannuleerd end-to-end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
165 lines
8.3 KiB
C#
165 lines
8.3 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 Cancelling_a_zaak_records_the_geannuleerd_status_and_a_resultaat()
|
|
{
|
|
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.SetZaakToCancellationStatusAsync(zaakUrl, zaaktype!, DateOnly.FromDateTime(DateTime.UtcNow));
|
|
|
|
// The zaak's current status is the Geannuleerd statustype — distinct from the approval eindstatus.
|
|
var zaak = await stack.GetZaakAsync(zaakUrl);
|
|
var statusUrl = zaak.GetProperty("status").GetString();
|
|
Assert.False(string.IsNullOrEmpty(statusUrl), "the cancelled zaak has no current status");
|
|
|
|
var status = await stack.GetJsonAsync(new Uri(statusUrl!));
|
|
var geannuleerd = await stack.FindStatustypeByOmschrijvingAsync(zaaktype!, "Geannuleerd");
|
|
Assert.Equal(geannuleerd.ToString(), status.GetProperty("statustype").GetString());
|
|
|
|
// ...and a resultaat is recorded (OpenZaak requires it before a closing/terminal status).
|
|
Assert.False(string.IsNullOrEmpty(zaak.GetProperty("resultaat").GetString()),
|
|
"the cancelled zaak has no resultaat");
|
|
}
|
|
|
|
[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());
|
|
}
|
|
}
|