test(bff): relay a refused diploma as 422 with its reason, a down scanner as 503 (refs #192)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
not
2026-10-02 09:53:23 +02:00
co-authored by Claude Opus 5.5
parent d2c035679b
commit 77de63bf8b
5 changed files with 74 additions and 13 deletions
@@ -1,6 +1,7 @@
using System.Net;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;
using Bff.Api;
namespace Bff.Tests;
@@ -162,13 +163,39 @@ public class SelfServiceEndpointTests
public async Task Relays_not_found_providing_documents_for_an_unknown_or_not_owned_registration()
{
using var factory = new BffFactory();
factory.Domain.ProvideDocumentsSucceeds = false;
factory.Domain.ProvideDocumentsResult = ProvideDocumentsResult.NotFound;
var response = await factory.CreateClient().SendAsync(ProvideDocuments(TestTokens.Valid("123456782")));
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
// S-29 (#192): the domain's refusal reaches the portal — 422 with the reason it words for the citizen.
[Theory]
[InlineData(ProvideDocumentsResult.NotAPdf, "not-a-pdf")]
[InlineData(ProvideDocumentsResult.Infected, "infected")]
public async Task Relays_a_refused_document_as_unprocessable_with_its_reason(ProvideDocumentsResult result, string reason)
{
using var factory = new BffFactory();
factory.Domain.ProvideDocumentsResult = result;
var response = await factory.CreateClient().SendAsync(ProvideDocuments(TestTokens.Valid("123456782")));
Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
Assert.Equal(reason, (await response.Content.ReadFromJsonAsync<JsonElement>()).GetProperty("reason").GetString());
}
[Fact]
public async Task Relays_an_unavailable_scanner_as_service_unavailable()
{
using var factory = new BffFactory();
factory.Domain.ProvideDocumentsResult = ProvideDocumentsResult.ScannerUnavailable;
var response = await factory.CreateClient().SendAsync(ProvideDocuments(TestTokens.Valid("123456782")));
Assert.Equal(HttpStatusCode.ServiceUnavailable, response.StatusCode);
}
private static HttpRequestMessage Current(string? bearer)
{
var request = new HttpRequestMessage(HttpMethod.Get, "/self-service/registrations");