Unify gateway styling and preserve identity through recovery
ci / java (push) Failing after 15m11s
ci / nightly-windev (push) Failing after 10m18s
ci / portable (push) Failing after 27m42s
ci / windows-x86 (push) Failing after 22m19s

This commit is contained in:
Joseph Doherty
2026-11-13 20:12:00 -05:00
parent b06921ce85
commit 26a90883fa
76 changed files with 20585 additions and 128 deletions
+26 -10
View File
@@ -71,7 +71,7 @@ using ZB.MOM.WW.MxGateway.Server.Security.Authorization;
internal sealed class ManagingApiKeyService : IDashboardApiKeyManagementService
{
/// <inheritdoc />
public bool CanManage(ClaimsPrincipal user) => true;
public bool CanManage(ClaimsPrincipal user) => user.IsInRole(DashboardRoles.Admin);
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> CreateAsync(
@@ -102,15 +102,16 @@ using ZB.MOM.WW.MxGateway.Server.Security.Authorization;
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
}
internal sealed class StubAuthenticationStateProvider : AuthenticationStateProvider
internal sealed class StubAuthenticationStateProvider(Microsoft.AspNetCore.Components.NavigationManager nav) : AuthenticationStateProvider
{
/// <inheritdoc />
public override Task<AuthenticationState> GetAuthenticationStateAsync() =>
Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "admin-user"), new Claim(ClaimTypes.Role, DashboardRoles.Admin)],
authenticationType: "test",
nameType: ClaimTypes.Name,
roleType: ClaimTypes.Role))));
public override Task<AuthenticationState> GetAuthenticationStateAsync()
{
var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(new Uri(nav.Uri).Query);
string role = query.TryGetValue("principal", out var value) ? value.ToString() : "admin";
var identity = role == "anonymous" ? new ClaimsIdentity() : new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "fixture-user"), new Claim(ClaimTypes.Role, role == "viewer" ? DashboardRoles.Viewer : DashboardRoles.Admin)], "synthetic");
return Task.FromResult(new AuthenticationState(new ClaimsPrincipal(identity)));
}
}
// In-memory Galaxy projection and read-only fake values for the actual BrowsePage.
internal sealed class FixtureGalaxyCache : ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache
@@ -124,7 +125,7 @@ internal sealed class FixtureGalaxyCache : ZB.MOM.WW.GalaxyRepository.IGalaxyHie
pump.Attributes.Add(new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyAttribute { AttributeName = new string('x', 200), FullTagReference = "Pump01." + new string('x', 200), DataTypeName = "Float" });
var sibling = new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject { GobjectId = 3, ParentGobjectId = 1, TagName = "Sibling01", BrowseName = "Sibling01" };
sibling.Attributes.Add(new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyAttribute { AttributeName = "PV", FullTagReference = "Sibling01.PV", DataTypeName = "Float" });
ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject[] rows = [plant, pump, sibling];
ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject[] rows = [plant, pump, sibling, new() { GobjectId=4, ParentGobjectId=2, TagName="PumpChild", BrowseName="PumpChild" }];
Current = ZB.MOM.WW.GalaxyRepository.GalaxyHierarchyCacheEntry.Empty with {
Status = ZB.MOM.WW.GalaxyRepository.GalaxyCacheStatus.Healthy, Sequence = 1,
Objects = rows, Index = ZB.MOM.WW.GalaxyRepository.GalaxyHierarchyIndex.Build(rows), ObjectCount = rows.Length, AttributeCount = 3,
@@ -141,3 +142,18 @@ internal sealed class FixtureLiveData : IDashboardLiveDataService
public Task<DashboardAlarmQueryResult> QueryAlarmsAsync(CancellationToken cancellationToken) =>
Task.FromResult(new DashboardAlarmQueryResult([], null, null));
}
internal sealed class FaultableBrowseService(ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache cache) : IDashboardBrowseService
{
private readonly DashboardBrowseService _real = new(cache);
public bool FailNext { get; set; }
public int Attempts { get; private set; }
public ulong CurrentCacheSequence => _real.CurrentCacheSequence;
public BrowseLevelResult GetRoots(BrowseFilterArgs filter) => _real.GetRoots(filter);
public BrowseLevelResult GetChildren(int id, BrowseFilterArgs filter)
{
Attempts++;
if (FailNext) { FailNext = false; throw new InvalidOperationException("Synthetic hierarchy outage " + new string('x', 600) + " <script>fixture</script>"); }
return _real.GetChildren(id, filter);
}
}