Extends the OpenZaak seam with IDocumentSource, sibling of IZaakSource (WP-49/50): an upload always lands locally first (DocumentStore stays the record of truth for preview/download/audit) and, when Zgw:Enabled=true, is also registered as a DRC enkelvoudiginformatie- object; once a zaak exists (IZaakSource.CreateZaak now also returns its ZaakUrl), submit links each document to it via zaakinformatie- object. FE upload/list DTOs are unchanged. - ZgwOptions gains DrcBaseUrl + a category->informatieobjecttype URL map (the document analogue of ZaaktypeUrls). - LocalDocumentSource is the same DocumentStore.Add/Link calls the endpoints used to make inline — zero behaviour change offline. - OpenZaakDocumentSource POSTs the eio then the zaak link, persisting the DRC url (DocumentStore.SetDrcUrl) so linking doesn't re-upload. - Factored the GET/POST-with-bearer-JWT plumbing shared with OpenZaakZaakSource into ZgwHttpClient; shared the stub handler between the two source test classes as ZgwStubHandler. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using System.Net;
|
|
using System.Text;
|
|
|
|
namespace BigRegister.Tests;
|
|
|
|
/// <summary>
|
|
/// Stub HttpMessageHandler shared by the ZGW source tests (no live server, no mocking
|
|
/// library) — keyed purely by request URL (method-agnostic, since no test scenario reuses a
|
|
/// URL across GET/POST). Records every request's url/body/auth-scheme for assertion.
|
|
/// Factored out of OpenZaakZaakSourceTests once OpenZaakDocumentSourceTests needed the
|
|
/// identical stub.
|
|
/// </summary>
|
|
internal sealed class ZgwStubHandler(Func<string, string> respond) : HttpMessageHandler
|
|
{
|
|
public List<string> Requests { get; } = new();
|
|
public List<string?> AuthSchemes { get; } = new();
|
|
public List<string> Bodies { get; } = new();
|
|
|
|
public string BodyOf(string url) => Bodies[Requests.LastIndexOf(url)];
|
|
|
|
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
{
|
|
var url = request.RequestUri!.ToString();
|
|
Requests.Add(url);
|
|
AuthSchemes.Add(request.Headers.Authorization?.Scheme);
|
|
Bodies.Add(request.Content?.ReadAsStringAsync(cancellationToken).GetAwaiter().GetResult() ?? "");
|
|
return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
Content = new StringContent(respond(url), Encoding.UTF8, "application/json"),
|
|
});
|
|
}
|
|
}
|