test(acl): cover the resolve null/error paths to hold the mutation ratchet (refs #113)
CI / lint (pull_request) Successful in 1m20s
CI / build (pull_request) Failing after 54s
CI / unit (pull_request) Failing after 1m3s
CI / frontend (pull_request) Successful in 2m32s
CI / mutation (pull_request) Successful in 5m39s
CI / verify-stack (pull_request) Successful in 8m11s
CI / lint (pull_request) Successful in 1m20s
CI / build (pull_request) Failing after 54s
CI / unit (pull_request) Failing after 1m3s
CI / frontend (pull_request) Successful in 2m32s
CI / mutation (pull_request) Successful in 5m39s
CI / verify-stack (pull_request) Successful in 8m11s
Kills the survivors the new resolution code introduced: null Results (no "results" in the response) must throw "none found" not NRE; a non-success catalogi response must surface an error naming the resource. ACL mutation score 93.89% (break 90%). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -721,7 +721,11 @@ public class OpenZaakGatewayTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task Resolves_the_informatieobjecttype_url_by_omschrijving()
|
public async Task Resolves_the_informatieobjecttype_url_by_omschrijving()
|
||||||
{
|
{
|
||||||
var handler = new StubHandler(_ => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
|
HttpRequestMessage? seen = null;
|
||||||
|
var handler = new StubHandler(req =>
|
||||||
|
{
|
||||||
|
seen = req;
|
||||||
|
return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
Content = JsonContent.Create(new
|
Content = JsonContent.Create(new
|
||||||
{
|
{
|
||||||
@@ -731,14 +735,71 @@ public class OpenZaakGatewayTests
|
|||||||
new { url = "http://openzaak/catalogi/api/v1/informatieobjecttypen/dip", omschrijving = "Diploma" },
|
new { url = "http://openzaak/catalogi/api/v1/informatieobjecttypen/dip", omschrijving = "Diploma" },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var url = await Gateway(handler).ResolveInformatieobjecttypeUrlAsync("Diploma");
|
var url = await Gateway(handler).ResolveInformatieobjecttypeUrlAsync("Diploma");
|
||||||
|
|
||||||
// Matches on omschrijving, not position.
|
// Queries the published informatieobjecttypen collection, and matches on omschrijving (not position).
|
||||||
|
Assert.Contains("/catalogi/api/v1/informatieobjecttypen", seen!.RequestUri!.ToString());
|
||||||
|
Assert.Contains("status=definitief", seen.RequestUri!.Query);
|
||||||
Assert.Equal("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip", url.ToString());
|
Assert.Equal("http://openzaak/catalogi/api/v1/informatieobjecttypen/dip", url.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Resolving_a_zaaktype_throws_when_the_response_carries_no_results()
|
||||||
|
{
|
||||||
|
// No "results" property → the page's Results is null; the gateway must treat that as "none
|
||||||
|
// found" (not dereference null).
|
||||||
|
var handler = new StubHandler(_ => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = JsonContent.Create(new { count = 0 }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
|
() => Gateway(handler).ResolveZaaktypeUrlAsync("BIG-REGISTRATIE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Resolving_an_informatieobjecttype_throws_when_the_response_carries_no_results()
|
||||||
|
{
|
||||||
|
var handler = new StubHandler(_ => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
Content = JsonContent.Create(new { count = 0 }),
|
||||||
|
}));
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<InvalidOperationException>(
|
||||||
|
() => Gateway(handler).ResolveInformatieobjecttypeUrlAsync("Diploma"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Resolving_a_zaaktype_surfaces_a_non_success_catalogi_response()
|
||||||
|
{
|
||||||
|
var handler = new StubHandler(_ => Task.FromResult(new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
||||||
|
{
|
||||||
|
Content = new StringContent("boom"),
|
||||||
|
}));
|
||||||
|
|
||||||
|
var ex = await Assert.ThrowsAsync<HttpRequestException>(
|
||||||
|
() => Gateway(handler).ResolveZaaktypeUrlAsync("BIG-REGISTRATIE"));
|
||||||
|
// The error names the resource being queried and includes OpenZaak's body.
|
||||||
|
Assert.Contains("zaaktypen", ex.Message);
|
||||||
|
Assert.Contains("boom", ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Resolving_an_informatieobjecttype_surfaces_a_non_success_catalogi_response()
|
||||||
|
{
|
||||||
|
var handler = new StubHandler(_ => Task.FromResult(new HttpResponseMessage(HttpStatusCode.InternalServerError)
|
||||||
|
{
|
||||||
|
Content = new StringContent("boom"),
|
||||||
|
}));
|
||||||
|
|
||||||
|
var ex = await Assert.ThrowsAsync<HttpRequestException>(
|
||||||
|
() => Gateway(handler).ResolveInformatieobjecttypeUrlAsync("Diploma"));
|
||||||
|
Assert.Contains("informatieobjecttypen", ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Resolving_an_informatieobjecttype_throws_when_no_omschrijving_matches()
|
public async Task Resolving_an_informatieobjecttype_throws_when_no_omschrijving_matches()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user