test(bff): endpoints, JWT auth and public-safe projection (refs #8)
Failing tests for the BFF walking-skeleton endpoints: - POST /self-service/registrations rejects missing/malformed/wrong-key/expired tokens (401) and, with a valid digid token, forwards the bsn to the domain and returns 202 (WebApplicationFactory + a local test signing key, ADR-0010). - GET /openbaar/register serves public-safe rows anonymously (never the bsn) and filters by q. - OpenbaarProjection.PublicView (pure) filters by id and maps to id+status only. Endpoints and PublicView are stubs so the tests compile and fail on their assertions; the green commit implements them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
48
services/bff/Bff.Tests/OpenbaarProjectionTests.cs
Normal file
48
services/bff/Bff.Tests/OpenbaarProjectionTests.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Bff.Api;
|
||||
|
||||
namespace Bff.Tests;
|
||||
|
||||
public class OpenbaarProjectionTests
|
||||
{
|
||||
private static readonly ProjectionEntry[] Sample =
|
||||
[
|
||||
new("abc-111", "INGEDIEND", "123456782", "Jan"),
|
||||
new("def-222", "INGEDIEND", "987654321", "Piet"),
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void Maps_every_row_to_public_safe_fields_when_no_query()
|
||||
{
|
||||
var view = OpenbaarProjection.PublicView(Sample, null);
|
||||
|
||||
Assert.Equal(2, view.Count);
|
||||
Assert.Equal("abc-111", view[0].Id);
|
||||
Assert.Equal("INGEDIEND", view[0].Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Public_view_exposes_only_id_and_status()
|
||||
{
|
||||
// OpenbaarEntry structurally carries only Id + Status — bsn/naam can never leak.
|
||||
var props = typeof(OpenbaarEntry).GetProperties().Select(p => p.Name).ToArray();
|
||||
Assert.Equal(["Id", "Status"], props);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("abc", 1)]
|
||||
[InlineData("ABC", 1)]
|
||||
[InlineData("2", 1)]
|
||||
[InlineData("zzz", 0)]
|
||||
public void Filters_by_id_containing_the_query_case_insensitively(string q, int expected)
|
||||
{
|
||||
var view = OpenbaarProjection.PublicView(Sample, q);
|
||||
|
||||
Assert.Equal(expected, view.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Blank_query_is_treated_as_no_filter()
|
||||
{
|
||||
Assert.Equal(2, OpenbaarProjection.PublicView(Sample, " ").Count);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user