Resolve all 46 low-severity architecture review findings

This commit is contained in:
Joseph Doherty
2026-09-09 22:56:36 -04:00
parent fef3e7675f
commit 9ee402bbcd
139 changed files with 2621 additions and 1082 deletions
@@ -0,0 +1,27 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Components.Authorization;
using NSubstitute;
using ZB.MOM.WW.ScadaBridge.CentralUI.Services;
using ZB.MOM.WW.ScadaBridge.Security;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Services;
public class AuthorizedManualFailoverTests
{
[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task RevokedAdmin_CannotDispatchCentralOrSite(bool site)
{
var auth = Substitute.For<AuthenticationStateProvider>();
var identity = new ClaimsIdentity([new Claim(JwtTokenService.RoleClaimType, Roles.Administrator)], "test");
auth.GetAuthenticationStateAsync().Returns(new AuthenticationState(new ClaimsPrincipal(identity)));
var backend = Substitute.For<IManualFailoverService>();
var service = new AuthorizedManualFailoverService(auth, backend);
identity.RemoveClaim(identity.FindFirst(JwtTokenService.RoleClaimType)!);
if (site) await Assert.ThrowsAsync<UnauthorizedAccessException>(() => service.FailOverSiteAsync("plant"));
else await Assert.ThrowsAsync<UnauthorizedAccessException>(() => service.FailOverCentralAsync());
await backend.DidNotReceiveWithAnyArgs().FailOverCentralAsync(default!);
await backend.DidNotReceiveWithAnyArgs().FailOverSiteAsync(default!, default!);
}
}