test(acl): mutable default-fill store — update replaces current (refs #131)
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Acl.Application;
|
||||||
|
|
||||||
|
/// <summary>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".</summary>
|
||||||
|
public sealed record DefaultFillSettings(
|
||||||
|
string Bronorganisatie,
|
||||||
|
string VerantwoordelijkeOrganisatie,
|
||||||
|
string Vertrouwelijkheidaanduiding);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace Acl.Application;
|
||||||
|
|
||||||
|
/// <summary>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.
|
||||||
|
/// </summary>
|
||||||
|
public interface IDefaultFillStore
|
||||||
|
{
|
||||||
|
DefaultFillSettings Current { get; }
|
||||||
|
|
||||||
|
void Update(DefaultFillSettings settings);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace Acl.Application;
|
||||||
|
|
||||||
|
/// <summary>In-memory <see cref="IDefaultFillStore"/> (ADR-0026), seeded from config. Thread-safe: the
|
||||||
|
/// hosted worker reads <see cref="Current"/> per zaak while the beheer endpoint may update it.</summary>
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user