From dabf4f499511265a18a2d23d0844479032e86764 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Fri, 24 Jul 2026 15:34:34 +0200 Subject: [PATCH] =?UTF-8?q?test(acl):=20mutable=20default-fill=20store=20?= =?UTF-8?q?=E2=80=94=20update=20replaces=20current=20(refs=20#131)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Acl.Application/DefaultFillSettings.cs | 10 +++++++ .../acl/Acl.Application/IDefaultFillStore.cs | 14 +++++++++ .../InMemoryDefaultFillStore.cs | 19 ++++++++++++ .../acl/Acl.Tests/DefaultFillStoreTests.cs | 29 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 services/acl/Acl.Application/DefaultFillSettings.cs create mode 100644 services/acl/Acl.Application/IDefaultFillStore.cs create mode 100644 services/acl/Acl.Application/InMemoryDefaultFillStore.cs create mode 100644 services/acl/Acl.Tests/DefaultFillStoreTests.cs diff --git a/services/acl/Acl.Application/DefaultFillSettings.cs b/services/acl/Acl.Application/DefaultFillSettings.cs new file mode 100644 index 0000000..2978c4e --- /dev/null +++ b/services/acl/Acl.Application/DefaultFillSettings.cs @@ -0,0 +1,10 @@ +namespace Acl.Application; + +/// The ZGW default-fill values a beheerder can edit at runtime (S-15b) — the mandatory fields +/// the ACL stamps on every zaak (ADR-0003). The S-27 catalog-resolution keys (zaaktype identificatie, +/// informatieobjecttype omschrijving) stay static config: editing them would desync the resolved-URL +/// cache, and they're catalogus wiring rather than "default fill". +public sealed record DefaultFillSettings( + string Bronorganisatie, + string VerantwoordelijkeOrganisatie, + string Vertrouwelijkheidaanduiding); diff --git a/services/acl/Acl.Application/IDefaultFillStore.cs b/services/acl/Acl.Application/IDefaultFillStore.cs new file mode 100644 index 0000000..d434dec --- /dev/null +++ b/services/acl/Acl.Application/IDefaultFillStore.cs @@ -0,0 +1,14 @@ +namespace Acl.Application; + +/// Holds the ACL's current default-fill values, editable at runtime through the beheer portal +/// (S-15b). Seeded from config at startup. +/// +/// ponytail: in-memory only — an edit is lost on restart, when it reverts to the configured env +/// (ADR-0026). Adequate for the reference demo; back it with a DB if durable, audited config is needed. +/// +public interface IDefaultFillStore +{ + DefaultFillSettings Current { get; } + + void Update(DefaultFillSettings settings); +} diff --git a/services/acl/Acl.Application/InMemoryDefaultFillStore.cs b/services/acl/Acl.Application/InMemoryDefaultFillStore.cs new file mode 100644 index 0000000..de4ede6 --- /dev/null +++ b/services/acl/Acl.Application/InMemoryDefaultFillStore.cs @@ -0,0 +1,19 @@ +namespace Acl.Application; + +/// In-memory (ADR-0026), seeded from config. Thread-safe: the +/// hosted worker reads per zaak while the beheer endpoint may update it. +public sealed class InMemoryDefaultFillStore(DefaultFillSettings seed) : IDefaultFillStore +{ + private readonly object _gate = new(); + private DefaultFillSettings _current = seed; + + public DefaultFillSettings Current + { + get { lock (_gate) return _current; } + } + + public void Update(DefaultFillSettings settings) + { + // ponytail: red stub — real assignment lands in the green commit. + } +} diff --git a/services/acl/Acl.Tests/DefaultFillStoreTests.cs b/services/acl/Acl.Tests/DefaultFillStoreTests.cs new file mode 100644 index 0000000..596aefc --- /dev/null +++ b/services/acl/Acl.Tests/DefaultFillStoreTests.cs @@ -0,0 +1,29 @@ +using Acl.Application; + +namespace Acl.Tests; + +public class DefaultFillStoreTests +{ + private static DefaultFillSettings Seed() => new("517439943", "517439943", "openbaar"); + + [Fact] + public void Seeds_from_the_supplied_settings() + { + var store = new InMemoryDefaultFillStore(Seed()); + + Assert.Equal("517439943", store.Current.Bronorganisatie); + Assert.Equal("openbaar", store.Current.Vertrouwelijkheidaanduiding); + } + + [Fact] + public void Updating_replaces_the_current_settings() + { + var store = new InMemoryDefaultFillStore(Seed()); + + store.Update(new DefaultFillSettings("999999999", "888888888", "vertrouwelijk")); + + Assert.Equal("999999999", store.Current.Bronorganisatie); + Assert.Equal("888888888", store.Current.VerantwoordelijkeOrganisatie); + Assert.Equal("vertrouwelijk", store.Current.Vertrouwelijkheidaanduiding); + } +}