diff --git a/services/bff/Bff.Tests/BffFactory.cs b/services/bff/Bff.Tests/BffFactory.cs index 492ab05..e1b5132 100644 --- a/services/bff/Bff.Tests/BffFactory.cs +++ b/services/bff/Bff.Tests/BffFactory.cs @@ -94,15 +94,15 @@ internal sealed class FakeDomainClient : IDomainClient return Task.FromResult(WithdrawSucceeds); } - public (string RegistrationId, string Bsn)? DocumentsProvidedFor { get; private set; } + public (string RegistrationId, string Bsn, string ContentBase64, string? FileName, string? ContentType)? DocumentsProvidedFor { get; private set; } /// Whether the fake domain reports the provide-documents as done (true → 204) or /// not-found/not-owned (false → 404). Tests set this to exercise the relay. public bool ProvideDocumentsSucceeds { get; set; } = true; - public Task ProvideDocumentsAsync(string registrationId, string bsn, CancellationToken ct = default) + public Task ProvideDocumentsAsync(string registrationId, string bsn, string contentBase64, string? fileName, string? contentType, CancellationToken ct = default) { - DocumentsProvidedFor = (registrationId, bsn); + DocumentsProvidedFor = (registrationId, bsn, contentBase64, fileName, contentType); return Task.FromResult(ProvideDocumentsSucceeds); } diff --git a/services/bff/Bff.Tests/SelfServiceEndpointTests.cs b/services/bff/Bff.Tests/SelfServiceEndpointTests.cs index c8e0ccd..3b23b7b 100644 --- a/services/bff/Bff.Tests/SelfServiceEndpointTests.cs +++ b/services/bff/Bff.Tests/SelfServiceEndpointTests.cs @@ -114,7 +114,17 @@ public class SelfServiceEndpointTests private static HttpRequestMessage ProvideDocuments(string? bearer, string id = "reg-123") { - var request = new HttpRequestMessage(HttpMethod.Post, $"/self-service/registrations/{id}/documents"); + var request = new HttpRequestMessage(HttpMethod.Post, $"/self-service/registrations/{id}/documents") + { + // The portal base64-encodes the file client-side and posts it as JSON (S-10b); the bsn is + // never in the body — it comes from the DigiD token. + Content = JsonContent.Create(new + { + contentBase64 = Convert.ToBase64String([1, 2, 3]), + fileName = "diploma.pdf", + contentType = "application/pdf", + }), + }; if (bearer is not null) request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", bearer); return request; @@ -132,14 +142,19 @@ public class SelfServiceEndpointTests } [Fact] - public async Task Provides_documents_for_the_callers_registration_forwarding_the_id_and_bsn() + public async Task Provides_documents_for_the_callers_registration_forwarding_id_bsn_and_file() { using var factory = new BffFactory(); var response = await factory.CreateClient().SendAsync(ProvideDocuments(TestTokens.Valid("123456782"), "reg-9")); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); - Assert.Equal(("reg-9", "123456782"), factory.Domain.DocumentsProvidedFor); + var provided = factory.Domain.DocumentsProvidedFor; + Assert.NotNull(provided); + Assert.Equal("reg-9", provided!.Value.RegistrationId); + Assert.Equal("123456782", provided.Value.Bsn); + Assert.Equal(Convert.ToBase64String([1, 2, 3]), provided.Value.ContentBase64); + Assert.Equal("diploma.pdf", provided.Value.FileName); } [Fact]