test(ui): retain ScadaBridge synthetic consumer validation host

This commit is contained in:
Joseph Doherty
2026-11-13 19:43:32 -05:00
parent e61af09c2e
commit 3c1eada677
22 changed files with 579 additions and 0 deletions
@@ -0,0 +1,86 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Sites;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Instances;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Templates;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Health;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Notification;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit;
using ZB.MOM.WW.ScadaBridge.Commons.Types;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
using ZB.MOM.WW.ScadaBridge.Communication;
using ZB.MOM.WW.ScadaBridge.DeploymentManager;
using ZB.MOM.WW.ScadaBridge.DeploymentManager.PendingUpdates;
using ZB.MOM.WW.ScadaBridge.HealthMonitoring;
using ZB.MOM.WW.ScadaBridge.TemplateEngine.Services;
using ZB.MOM.WW.ScadaBridge.TemplateEngine.Flattening;
// Disposable read-only synthetic projections. Real service constructors are resolved but never
// receive an actor system or a database. Every mutation and external probe remains rejected.
internal static class BatchThreeFixtures
{
public static void Register(IServiceCollection services)
{
var sites = Enumerable.Range(1, 12).Select(i => new Site($"Synthetic facility {i:00} with a deliberately long local display name", $"fixture-{i:00}") { Id = i }).ToArray();
services.AddScoped(_ => ReadOnlyFixtureProxy.WithReads<ISiteRepository>(new Dictionary<string, Func<object?[], object?>>
{
["GetAllSitesAsync"] = _ => Task.FromResult<IReadOnlyList<Site>>(sites),
["GetAllDataConnectionsAsync"] = _ => Task.FromResult<IReadOnlyList<DataConnection>>([])
}));
services.AddScoped(_ => ReadOnlyFixtureProxy.WithReads<ITemplateEngineRepository>(new Dictionary<string, Func<object?[], object?>>
{
["GetAllTemplatesAsync"] = _ => Task.FromResult<IReadOnlyList<Template>>([]),
["GetTemplateStubsAsync"] = _ => Task.FromResult<IReadOnlyList<ZB.MOM.WW.ScadaBridge.Commons.Types.Templates.TemplateStub>>([]),
["GetAreasBySiteIdAsync"] = args => Task.FromResult<IReadOnlyList<Area>>(Enumerable.Range(1, 6).Select(i => new Area($"Synthetic area {i:00} with a long inspection label") { Id = (int)args[0]! * 100 + i, SiteId = (int)args[0]! }).ToArray()),
["GetTopologyInstancesAsync"] = _ => Task.FromResult<IReadOnlyList<Instance>>([])
}));
services.AddScoped<ZB.MOM.WW.ScadaBridge.CentralUI.Auth.SiteScopeService>();
services.AddScoped<AuthorizedManualFailoverService>();
services.AddSingleton<IPendingUpdatesCache>(new EmptyPending());
services.AddSingleton<IKpiSnapshotCache>(new SyntheticKpis());
var now = DateTimeOffset.UtcNow;
SiteHealthReport Report(string id) => new(id, 1, now, new Dictionary<string, ConnectionHealth>(), new Dictionary<string, ZB.MOM.WW.ScadaBridge.Commons.Messages.Health.TagResolutionStatus>(), 0, 0, new Dictionary<string, int>(), 0, 0, 0, 0);
var states = new Dictionary<string, SiteHealthState>
{
["healthy"] = new() { SiteId="healthy", IsOnline=true, LatestReport=Report("healthy"), LastReportReceivedAt=now, LastHeartbeatAt=now },
["offline"] = new() { SiteId="offline", IsOnline=false, LatestReport=Report("offline"), LastReportReceivedAt=now.AddMinutes(-8), LastHeartbeatAt=now.AddMinutes(-8) },
["warning"] = new() { SiteId="warning", IsOnline=true, IsMetricsStale=true, LatestReport=Report("warning"), LastReportReceivedAt=now.AddMinutes(-4), LastHeartbeatAt=now },
["unknown"] = new() { SiteId="unknown", IsOnline=true, LastHeartbeatAt=now }
};
services.AddSingleton(ReadOnlyFixtureProxy.WithReads<ICentralHealthAggregator>(new Dictionary<string, Func<object?[], object?>> { ["GetAllSiteStates"] = _ => states }));
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IKpiHistoryQueryService>());
services.AddSingleton(Options.Create(new HealthMonitoringOptions()));
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IManualFailoverService>());
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IDeploymentManagerRepository>());
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IFlatteningPipeline>());
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IAuditService>());
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IStaleInstanceProbe>());
services.AddSingleton(new CommunicationService(Options.Create(new CommunicationOptions()), NullLogger<CommunicationService>.Instance));
services.AddSingleton(new OperationLockManager());
services.AddSingleton(Options.Create(new DeploymentManagerOptions()));
services.AddSingleton(Options.Create(new CommunicationOptions()));
services.AddSingleton<ILogger<DeploymentService>>(NullLogger<DeploymentService>.Instance);
services.AddScoped<DiffService>(); services.AddScoped<RevisionHashService>();
services.AddSingleton<IDeploymentStatusNotifier>(new DeploymentStatusNotifier(NullLogger<DeploymentStatusNotifier>.Instance));
services.AddScoped<DeploymentService>(); services.AddScoped<AreaService>(); services.AddScoped<InstanceService>();
}
private sealed class EmptyPending : IPendingUpdatesCache
{
public event Action? Invalidated { add { } remove { } }
public Task<PendingUpdatesSnapshot> GetAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new PendingUpdatesSnapshot(DateTimeOffset.UtcNow, []));
}
private sealed class SyntheticKpis : IKpiSnapshotCache
{
public Task<NotificationKpiResponse> GetNotificationKpisAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new NotificationKpiResponse("local", true, null, 2, 0, 0, 4, null));
public Task<PerSiteNotificationKpiResponse> GetPerSiteNotificationKpisAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new PerSiteNotificationKpiResponse("local", true, null, []));
public Task<PerNodeNotificationKpiResponse> GetPerNodeNotificationKpisAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new PerNodeNotificationKpiResponse("local", true, null, []));
public Task<SiteCallKpiResponse> GetSiteCallKpisAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new SiteCallKpiResponse("local", true, null, 0, 0, 0, 2, null, 0));
public Task<PerNodeSiteCallKpiResponse> GetPerNodeSiteCallKpisAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new PerNodeSiteCallKpiResponse("local", true, null, []));
public Task<AuditLogKpiSnapshot> GetAuditKpiSnapshotAsync(bool forceRefresh=false, CancellationToken cancellationToken=default) => Task.FromResult(new AuditLogKpiSnapshot(3, 0, 0, DateTime.UtcNow));
}
}
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<base href="/" />
<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="/lib/bootstrap-icons/bootstrap-icons.css" rel="stylesheet" />
<ThemeHead />
<link href="/ScadaBridgeUiCanary.styles.css" rel="stylesheet" />
<link href="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/css/site.css" rel="stylesheet" />
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="/_framework/blazor.web.js"></script>
<script src="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/theme.js"></script>
<script src="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/dialog.js"></script>
<ThemeScripts />
</body>
</html>
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="light" data-canary="scadabridge">
<head>
<!-- Exact existing ScadaBridge pre-hydration preference script; fixture does not change production. -->
<script>
// Apply the persisted theme to <html> BEFORE first paint so a
// dark-mode user never sees a light flash. Mirrors window.sbTheme.get/apply
// (theme.js) — same key, same rule — but inlined so it runs without waiting
// on the deferred script include. localStorage access is guarded for
// private-browsing modes that throw on read.
(function () {
try {
var m = localStorage.getItem('sb-theme') === 'dark' ? 'dark' : 'light';
document.documentElement.setAttribute('data-bs-theme', m);
} catch (e) { }
})();
</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<base href="/" />
<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<link href="/lib/bootstrap-icons/bootstrap-icons.css" rel="stylesheet" />
<ThemeHead />
<link href="/ScadaBridgeUiCanary.styles.css" rel="stylesheet" />
<link href="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/css/site.css" rel="stylesheet" />
<link href="/canary-adoption.css" rel="stylesheet" />
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<Routes @rendermode="InteractiveServer" />
<script src="/_framework/blazor.web.js"></script>
<script src="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/theme.js"></script>
<script src="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/dialog.js"></script>
<script src="/_content/ZB.MOM.WW.ScadaBridge.CentralUI/js/monaco-init.js"></script>
<script src="/js/treeview-storage.js"></script>
<script src="/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
<ThemeScripts />
</body>
</html>
@@ -0,0 +1,41 @@
@page "/accent"
<PageTitle>Four-family accent component canary</PageTitle>
<h1>Four-family accent component canary</h1>
<p>Fixture-only shared components under the actual CentralUI stylesheet. These four cases use the release-decision table and validate the shared light scheme, not a full sister application.</p>
<nav aria-label="Accent fixture cases">
<a href="/accent?family=default">Default blue</a> ·
<a href="/accent?family=historian">Historian green</a> ·
<a href="/accent?family=btdb">BTDB teal</a> ·
<a href="/accent?family=overview">Overview purple</a> ·
<a href="/">Actual CentralUI component fixture</a>
</nav>
<ThemeShell Product="@Selected.Label" Accent="@Selected.Accent" AccentDeep="@Selected.Deep"
AccentTint="@Selected.Tint" AccentBorder="@Selected.Border" AccentFocus="@Selected.Deep">
<Nav>
<NavRailItem Href="/accent" Text="Selected sample" Match="NavLinkMatch.All" />
</Nav>
<ChildContent>
<h2 id="accent-family-title">@Selected.Label</h2>
<p><a id="canary-family-link" href="#accent-family-title">An actual theme-styled link</a></p>
<div class="canary-action-row">
<TechButton id="canary-family-primary" @onclick="CountClick">Local primary action</TechButton>
<TechButton id="canary-family-ghost" Variant="ButtonVariant.Ghost" @onclick="CountClick">Local ghost action</TechButton>
<TechButton id="canary-family-disabled" disabled="true">Disabled primary action</TechButton>
</div>
<StatusPill State="StatusState.Info">Independent semantic information</StatusPill>
<p id="canary-family-outcome" role="status">Synthetic local clicks: @_clicks</p>
</ChildContent>
</ThemeShell>
@code {
[SupplyParameterFromQuery(Name = "family")] public string? Family { get; set; }
private int _clicks;
private void CountClick() => _clicks++;
private AccentCase Selected => Family?.ToLowerInvariant() switch
{
"historian" => new("Historian green", "#2f855a", "#1c6540", "#edf5f0", "#bddbc9"),
"btdb" => new("BTDB teal", "#1b7f8e", "#125764", "#eaf5f6", "#b7d9dd"),
"overview" => new("Overview purple", "#6d28d9", "#4c1d95", "#f2ecfc", "#d7c5f2"),
_ => new("Default blue", "#2f5fd0", "#1e3f99", "#eef2fc", "#cdd9f7")
};
private sealed record AccentCase(string Label, string Accent, string Deep, string Tint, string Border);
}
@@ -0,0 +1,27 @@
@page "/batch-two"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Audit
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit
@if (Sample == "dashboard") { <h2 class="h6">Local state and UTC verification</h2> } else { <h1>Local state and UTC verification</h1> }
<p>Actual components, synthetic read-only dependencies; no backend queries or write operations. Direct composition is not application authorization verification.</p>
@if (Sample == "dashboard")
{
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Dashboard />
}
else if (Sample == "toast")
{
<ToastNotification @ref="_toast" />
<button class="btn btn-secondary" id="show-toast" @onclick="ShowToast">Show local notifications</button>
}
else
{
<AuditFilterBar OnFilterChanged="Capture" />
<output id="local-filter-result">@_result</output>
}
@code {
[SupplyParameterFromQuery] public string? Sample { get; set; }
private ToastNotification? _toast;
private string _result = "No local filter applied";
private void Capture(AuditLogQueryFilter filter) => _result = $"From={filter.FromUtc:O};To={filter.ToUtc:O};FromKind={filter.FromUtc?.Kind};ToKind={filter.ToUtc?.Kind}";
private void ShowToast() { _toast!.ShowError("Synthetic save feedback", "Local configuration", 60000); _toast.ShowInfo("Synthetic read feedback", "Local audit query", 60000); }
}
@@ -0,0 +1,20 @@
@page "/"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@inject IDialogService Dialogs
<PageTitle>ScadaBridge local component canary</PageTitle>
<h1>ScadaBridge local component canary</h1>
<p>Actual CentralUI MainLayout, DateTimeRangeFilter, LoadingSpinner and DialogHost with synthetic local content. This is not the complete application.</p>
<p><a href="/login">Actual CentralUI login</a> · <a href="/canary-provenance">Fixture provenance</a></p>
<section class="panel rise" id="canary-rise">
<div class="panel-head">Synthetic local filter</div>
<div class="panel-body">
<DateTimeRangeFilter IdPrefix="canary" />
<LoadingSpinner IsLoading="true" Message="Synthetic pending state" />
<p>These controls have no fleet service behind them.</p>
<TechButton @onclick="ShowDialog">Open local confirmation</TechButton>
</div>
</section>
@code {
private async Task ShowDialog() => await Dialogs.ConfirmAsync(
"Local fixture confirmation", "Synthetic dialog. Confirm and Cancel only dismiss this local fixture.");
}
@@ -0,0 +1,61 @@
@page "/"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@inject IDialogService Dialogs
<PageTitle>ScadaBridge local component canary</PageTitle>
<h1>ScadaBridge local component canary</h1>
<p>Actual CentralUI MainLayout, DateTimeRangeFilter, LoadingSpinner and DialogHost with synthetic local content. This is not the complete application.</p>
<p><a href="/login">Actual CentralUI login</a> · <a href="/canary-provenance">Fixture provenance</a></p>
<section class="panel rise" id="canary-rise">
<div class="panel-head">Synthetic local filter</div>
<div class="panel-body">
<DateTimeRangeFilter IdPrefix="canary" />
<LoadingSpinner IsLoading="true" Message="Synthetic pending state" />
<p>These controls have no fleet service behind them.</p>
<TechField Label="Synthetic label" For="canary-field" Hint="Local-only fixture value; no credential or backend."
HintId="canary-field-hint" Error="@_fieldError" ErrorId="canary-field-error">
<input id="canary-field" class="form-control" @bind="_sample" @bind:event="oninput" @bind:after="ValidateSample"
aria-describedby="@FieldDescription" aria-invalid="@(_fieldError is not null ? "true" : "false")" />
</TechField>
<div class="canary-status-row" aria-label="Synthetic status samples">
<StatusPill State="StatusState.Ok">OK sample</StatusPill>
<StatusPill State="StatusState.Warn">Warning sample</StatusPill>
<StatusPill State="StatusState.Bad">Failure sample</StatusPill>
<StatusPill State="StatusState.Idle">Idle sample</StatusPill>
<StatusPill State="StatusState.Info">Information sample</StatusPill>
</div>
<div class="canary-action-row">
<TechButton id="canary-busy-success" Busy="@SuccessBusy" BusyText="Saving local sample…"
disabled="@IsWorking" @onclick="() => WorkAsync(false)">Save local sample</TechButton>
<TechButton id="canary-busy-failure" Variant="ButtonVariant.Secondary" Busy="@FailureBusy" BusyText="Trying local sample…"
disabled="@IsWorking" @onclick="() => WorkAsync(true)">Simulate local failure</TechButton>
<TechButton id="canary-caller-disabled" disabled="true">Caller-disabled local action</TechButton>
<TechButton @onclick="ShowDialog">Open local confirmation</TechButton>
</div>
<div id="canary-outcome" role="status" aria-live="polite">@_outcome</div>
<p>Supported dark tokens come from actual CentralUI site.css under the limited candidate adoption; this host still uses synthetic local data only.</p>
</div>
</section>
@code {
private string _sample = "";
private string? _fieldError = "Synthetic validation error. Enter a label to clear it.";
private string? _workingAction;
private string _outcome = "No local operation has run.";
private bool IsWorking => _workingAction is not null;
private bool SuccessBusy => _workingAction == "success";
private bool FailureBusy => _workingAction == "failure";
private string FieldDescription => _fieldError is null
? "canary-field-hint" : "canary-field-hint canary-field-error";
private void ValidateSample() => _fieldError = string.IsNullOrWhiteSpace(_sample)
? "Synthetic validation error. Enter a label to clear it." : null;
private async Task WorkAsync(bool failure)
{
if (IsWorking) return;
_workingAction = failure ? "failure" : "success";
_outcome = "Local sample pending.";
await Task.Delay(800);
_outcome = failure ? "Local sample failed. Try again." : "Local sample saved.";
_workingAction = null;
}
private async Task ShowDialog() => await Dialogs.ConfirmAsync(
"Local fixture confirmation", "Synthetic dialog. Confirm and Cancel only dismiss this local fixture.");
}
@@ -0,0 +1,44 @@
@page "/form-samples"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Forms
@using ZB.MOM.WW.ScadaBridge.Commons.Types.DataConnections
@if (View is "sms" or "smtp") { <h2 class="h6">Local form association samples</h2> } else { <h1>Local form association samples</h1> }
<p>Actual consumer components with synthetic local values. Empty repository reads only; all repository mutations are rejected. Direct notification component composition is not application authorization verification.</p>
@if (View == "sms")
{
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Notifications.SmsConfiguration />
}
else if (View == "smtp")
{
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Notifications.SmtpConfiguration />
}
else
{
<section id="gateway-samples">
<MxGatewayEndpointEditor Config="_primary" Title="Synthetic primary" IdPrefix="sample-primary" />
<MxGatewayEndpointEditor Config="_backup" Title="Synthetic backup" IdPrefix="sample-backup" />
</section>
<section id="parameter-samples">
<h2>Repeated parameter editors</h2>
<ParameterValueForm ParameterDefinitions="@_schema" />
<ParameterValueForm ParameterDefinitions="@_schema" />
</section>
<section id="tree-samples">
<h2>Transport selection component</h2>
<TreeView TItem="string" Items="_nodes" ChildrenSelector="_ => Array.Empty<string>()" HasChildrenSelector="_ => false"
KeySelector="s => s" SelectionMode="TreeViewSelectionMode.Checkbox">
<NodeContent Context="node"><span>@node</span></NodeContent>
</TreeView>
</section>
<section id="monaco-sample">
<h2>Actual JSON editor</h2>
<MonacoEditor Language="json" AriaLabel="Synthetic local JSON payload" Value="{}" Height="150px" ShowToolbar="false" />
</section>
}
@code {
[SupplyParameterFromQuery] public string? View { get; set; }
private readonly MxGatewayEndpointConfig _primary = new();
private readonly MxGatewayEndpointConfig _backup = new();
private readonly string[] _nodes = ["Plant A configuration", "Plant B configuration"];
private const string _schema = """{"type":"object","properties":{"count":{"type":"integer"},"details":{"type":"object","properties":{"name":{"type":"string"}}}}}""";
}
@@ -0,0 +1,3 @@
@page "/login"
<PageTitle>ScadaBridge actual login component canary</PageTitle>
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Login />
@@ -0,0 +1,4 @@
@page "/operations-canary"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
<p class="notice">Local synthetic observations only. No database, actor system, LDAP or fleet is connected.</p>
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Monitoring.Health />
@@ -0,0 +1,20 @@
@page "/overlays"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Audit
@using ZB.MOM.WW.ScadaBridge.CentralUI.Services
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums
@inject IDialogService Dialogs
<h1>Local overlay verification</h1>
<p>Actual CentralUI dialogs and audit drawer, synthetic read-only data. No fleet services.</p>
<button id="open-confirm" class="btn btn-primary" @onclick="Confirm">Open local confirmation</button>
<button id="open-prompt" class="btn btn-secondary" @onclick="Prompt">Open local prompt</button>
<button id="open-drawer" class="btn btn-secondary" @onclick="() => _drawer = true">Open synthetic audit drawer</button>
<div id="local-result" role="status">@_result</div>
<AuditDrilldownDrawer Event="_event" IsOpen="_drawer" OnClose="() => _drawer = false" />
@code {
private bool _drawer;
private string _result = "No local action";
private readonly AuditEventView _event = new() { EventId = Guid.Parse("11111111-2222-3333-4444-555555555555"), OccurredAtUtc = DateTime.UtcNow, IngestedAtUtc = DateTime.UtcNow, Channel = AuditChannel.ApiOutbound, Kind = AuditKind.ApiCall, Status = AuditStatus.Delivered, SourceSiteId = "local-sample", Actor = "local-fixture", Target = "synthetic" };
private async Task Confirm() => _result = await Dialogs.ConfirmAsync("Local confirmation", "Synthetic confirmation body") ? "Confirmed locally" : "Cancelled locally";
private async Task Prompt() => _result = await Dialogs.PromptAsync("Local prompt", "Local sample value") ?? "Cancelled locally";
}
@@ -0,0 +1,26 @@
@page "/presentation"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Debugging
@using ZB.MOM.WW.ScadaBridge.ScriptAnalysis
<h1>Local flow and table presentation samples</h1>
<p>Actual flow/list/table components, synthetic outcomes and long values only. No live/replay command or backend is called.</p>
<section id="utility-samples">
<span class="text-success">Successful sample</span> · <span class="text-warning">Warning sample</span> ·
<span class="text-danger">Failure sample</span> · <span class="text-info">Information sample</span> ·
<span class="text-muted">Muted sample</span> · <span class="text-secondary">Secondary sample</span>
</section>
<FlowGraphView Graph="_graph" Predicted="_prediction" />
<FlowTraceList Graph="_graph" />
<DataTable TableLabel="Synthetic records" TItem="string" Items="_items" SearchFilter="@((item, search) => item.Contains(search, StringComparison.OrdinalIgnoreCase))">
<HeaderContent><th scope="col">Synthetic identifier</th><th scope="col">Details</th></HeaderContent>
<RowContent Context="item"><tr><th scope="row">@item</th><td><span class="mono text-nowrap">@LongValue</span></td></tr></RowContent>
</DataTable>
@code {
private static readonly string LongValue = "synthetic.identifier." + new string('x', 200);
private readonly string[] _items = ["Plant A", "Plant B"];
private static readonly FlowStep[] Steps = Enum.GetValues<FlowStepOutcome>().Select((outcome, i) => new FlowStep(Guid.NewGuid(), null, null,
FlowStepKind.ApiCall, FlowLane.Site, "Synthetic " + outcome, "Illustrative outcome", DateTimeOffset.UnixEpoch.AddSeconds(i), i * 10, outcome,
null, null, null, "local", null, null, null, null)).ToArray();
private readonly PredictedFlow _prediction = new([new PredictedNode("ghost", FlowStepKind.ScriptRun, FlowLane.Site, "Synthetic predicted-only branch", false, "Not observed in this synthetic run")], []);
private readonly FlowGraph _graph = new(Steps, Steps.Zip(Steps.Skip(1)).Select(pair => new FlowEdge(pair.First.EventId, pair.Second.EventId, false, false)).ToArray(), false, false);
}
@@ -0,0 +1,4 @@
@page "/secrets-canary"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
<p class="notice">Actual delivered Secrets UI in ScadaBridge shell. Synthetic metadata only; value reads, encryption, audit and all writes are rejected.</p>
<ZB.MOM.WW.Secrets.Ui.SecretsPage />
@@ -0,0 +1,4 @@
@page "/topology-canary"
@layout ZB.MOM.WW.ScadaBridge.CentralUI.Components.Layout.MainLayout
<p class="notice">Local synthetic sites and areas only. Load/search/selection can be inspected; deployment and mutation services reject writes.</p>
<ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Deployment.Topology />
@@ -0,0 +1,4 @@
<Router AppAssembly="typeof(App).Assembly">
<Found Context="routeData"><RouteView RouteData="routeData" /></Found>
<NotFound><h1>Canary route not found</h1></NotFound>
</Router>
@@ -0,0 +1,6 @@
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using ZB.MOM.WW.Theme
@using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared
@@ -0,0 +1,61 @@
using System.Security.Claims;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.FileProviders;
using ScadaBridgeUiCanary.Components;
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
using ZB.MOM.WW.Theme;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();
builder.Services.AddAuthorizationCore(options => ZB.MOM.WW.Secrets.Ui.SecretsAuthorization.AddSecretsAuthorization(options));
ZB.MOM.WW.ScadaBridge.Security.AuthorizationPolicies.AddScadaBridgeAuthorization(builder.Services);
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped<AuthenticationStateProvider, LocalAnonymousState>();
builder.Services.AddScoped<IDialogService, DialogService>();
builder.Services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories.INotificationRepository>());
builder.Services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.CentralUI.Services.ISchemaLibraryQueryService>());
builder.Services.AddScoped(_ => ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories.ISiteRepository>());
builder.Services.AddScoped(_ => ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories.ITemplateEngineRepository>());
builder.Services.AddScoped(_ => ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Security.IInboundApiKeyAdmin>("ListAsync"));
builder.Services.AddScoped(_ => ReadOnlyFixtureProxy.EmptyReads<ZB.MOM.WW.ScadaBridge.CentralUI.Services.IAuditLogQueryService>());
BatchThreeFixtures.Register(builder.Services);
SecretsCanaryFixtures.Register(builder.Services);
var app = builder.Build();
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(
builder.Configuration["Canary:ScadaBridgeRoot"] ?? "/Users/dohertj2/Desktop/ScadaBridge",
"src/ZB.MOM.WW.ScadaBridge.Host/wwwroot"))
});
app.UseStaticFiles();
app.UseAntiforgery();
app.MapGet("/canary-provenance", () => new
{
purpose = "Disposable local component canary; not the complete ScadaBridge application",
themeAssembly = typeof(ThemeShell).Assembly.GetName().Version?.ToString(),
centralUiAssembly = typeof(DialogHost).Assembly.GetName().Version?.ToString(),
data = "Synthetic local only; no SQL, Akka, LDAP or fleet services registered",
source = "Authorized ScadaBridge checkout via project reference"
});
app.MapGet("/auth/ping", () => Results.Ok());
app.MapPost("/auth/activity", () => Results.NoContent());
app.MapPost("/auth/login", () => Results.StatusCode(405));
app.MapPost("/auth/logout", () => Results.StatusCode(405));
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
app.Run();
internal sealed class LocalAnonymousState(Microsoft.AspNetCore.Components.NavigationManager navigation) : AuthenticationStateProvider
{
public override Task<AuthenticationState> GetAuthenticationStateAsync()
{
// Fixture-only role selection. No real authentication endpoint or external identity is used.
var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(new Uri(navigation.Uri).Query);
var roles = query.TryGetValue("role", out var value) ? value.ToString().Split(',') : [];
var claims = roles.Select(role => new Claim(ZB.MOM.WW.ScadaBridge.Security.JwtTokenService.RoleClaimType, role)).ToList();
claims.Add(new Claim(ZB.MOM.WW.ScadaBridge.Security.JwtTokenService.UsernameClaimType, "local synthetic identity"));
return Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(claims, roles.Length > 0 ? "LocalFixture" : null))));
}
}
@@ -0,0 +1,46 @@
using System.Reflection;
// Fixture-only empty reads. Every non-Get call is rejected, including writes,
// endpoint verification, certificate trust and notification sending.
public class ReadOnlyFixtureProxy : DispatchProxy
{
private string? _failOnceMethod;
private IReadOnlyDictionary<string, Func<object?[], object?>>? _reads;
public static T WithReads<T>(IReadOnlyDictionary<string, Func<object?[], object?>> reads) where T : class
{
var proxy = Create<T, ReadOnlyFixtureProxy>();
((ReadOnlyFixtureProxy)(object)proxy)._reads = reads;
return proxy;
}
public static T EmptyReads<T>(string? failOnceMethod = null) where T : class
{
var proxy = Create<T, ReadOnlyFixtureProxy>();
((ReadOnlyFixtureProxy)(object)proxy)._failOnceMethod = failOnceMethod;
return proxy;
}
protected override object? Invoke(MethodInfo? method, object?[]? args)
{
if (method is not null && _reads?.TryGetValue(method.Name, out var read) == true)
return read(args ?? []);
if (method is null || (!method.Name.StartsWith("Get", StringComparison.Ordinal) && method.Name != "ListAsync"))
throw new InvalidOperationException("Local fixture rejects non-read operations.");
if (method.Name == _failOnceMethod)
{
_failOnceMethod = null;
throw new InvalidOperationException("Synthetic local read failure; retry is safe.");
}
var result = method.ReturnType;
if (!result.IsGenericType || result.GetGenericTypeDefinition() != typeof(Task<>))
throw new InvalidOperationException("Unsupported fixture read shape.");
var valueType = result.GenericTypeArguments[0];
object? value = valueType.IsValueType ? Activator.CreateInstance(valueType) : null;
if (valueType.IsGenericType)
{
var shape = valueType.GetGenericTypeDefinition();
if (shape == typeof(IReadOnlyList<>) || shape == typeof(IList<>) || shape == typeof(IEnumerable<>))
value = Activator.CreateInstance(typeof(List<>).MakeGenericType(valueType.GenericTypeArguments));
else if (shape == typeof(IReadOnlyDictionary<,>) || shape == typeof(IDictionary<,>))
value = Activator.CreateInstance(typeof(Dictionary<,>).MakeGenericType(valueType.GenericTypeArguments));
}
return typeof(Task).GetMethod(nameof(Task.FromResult))!.MakeGenericMethod(valueType).Invoke(null, new[] { value });
}
}
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ScadaBridgeRoot Condition="'$(ScadaBridgeRoot)' == ''">/Users/dohertj2/Desktop/ScadaBridge</ScadaBridgeRoot>
<CanaryThemeVersion Condition="'$(CanaryThemeVersion)' == ''">1.0.1</CanaryThemeVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="$(ScadaBridgeRoot)/src/ZB.MOM.WW.ScadaBridge.CentralUI/ZB.MOM.WW.ScadaBridge.CentralUI.csproj" />
<PackageReference Include="ZB.MOM.WW.Theme" Version="$(CanaryThemeVersion)" />
</ItemGroup>
</Project>
@@ -0,0 +1,20 @@
using ZB.MOM.WW.Secrets.Abstractions;
using ZB.MOM.WW.Audit;
internal static class SecretsCanaryFixtures
{
public static void Register(IServiceCollection services)
{
IReadOnlyList<SecretMetadata> metadata = new[] { "fixture/alpha", "fixture/" + new string('x', 400) }.Select(name => new SecretMetadata
{
Name = new SecretName(name), Description = "Synthetic local metadata", ContentType = SecretContentType.Text,
KekId = "synthetic-key-id", Revision = 1, CreatedUtc = DateTimeOffset.Parse("2026-11-13T12:00:00Z"), UpdatedUtc = DateTimeOffset.Parse("2026-11-13T12:00:00Z"), UpdatedBy = "synthetic reviewer"
}).ToArray();
services.AddSingleton(ReadOnlyFixtureProxy.WithReads<ISecretStore>(new Dictionary<string, Func<object?[], object?>>
{
["ListAsync"] = _ => Task.FromResult(metadata),
["GetAsync"] = _ => throw new InvalidOperationException("Local metadata canary rejects value reads.")
}));
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<ISecretCipher>());
services.AddSingleton(ReadOnlyFixtureProxy.EmptyReads<IAuditWriter>());
}
}
@@ -0,0 +1,9 @@
/* Fixture layout only. Supported dark tokens now come from the actual CentralUI
site.css under the limited SB-01 candidate adoption; no fixture palette override. */
html[data-canary="scadabridge"] .canary-action-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: .75rem;
margin-block: 1rem;
}