Resolve all high-severity architecture review findings
This commit is contained in:
@@ -83,6 +83,51 @@ public class CentralControlAuthInterceptorTests
|
||||
=> interceptor.UnaryServerHandler<string, string>(
|
||||
"request", context, (_, _) => Task.FromResult("ok"));
|
||||
|
||||
[Theory]
|
||||
[InlineData("notification")]
|
||||
[InlineData("reconcile")]
|
||||
[InlineData("health")]
|
||||
[InlineData("heartbeat")]
|
||||
[InlineData("audit")]
|
||||
[InlineData("cached-audit")]
|
||||
[InlineData("cached-operational")]
|
||||
public async Task VerifiedSiteA_CannotSubmitSiteBOwnership(string kind)
|
||||
{
|
||||
var service = new CentralControlGrpcService(
|
||||
NullLogger<CentralControlGrpcService>.Instance,
|
||||
Microsoft.Extensions.Options.Options.Create(new ZB.MOM.WW.ScadaBridge.Communication.CommunicationOptions()));
|
||||
object request = kind switch
|
||||
{
|
||||
"notification" => new NotificationSubmitDto { SourceSiteId = SiteB },
|
||||
"reconcile" => new ReconcileSiteRequestDto { SiteIdentifier = SiteB },
|
||||
"health" => new SiteHealthReportDto { SiteId = SiteB },
|
||||
"heartbeat" => new HeartbeatDto { SiteId = SiteB },
|
||||
"audit" => new AuditEventBatch { Events = { new AuditEventDto { SourceSiteId = SiteA }, new AuditEventDto { SourceSiteId = SiteB } } },
|
||||
_ => new CachedTelemetryBatch { Packets = { new CachedTelemetryPacket {
|
||||
AuditEvent = new AuditEventDto { SourceSiteId = kind == "cached-audit" ? SiteB : SiteA },
|
||||
Operational = new SiteCallOperationalDto { SourceSite = kind == "cached-operational" ? SiteB : SiteA }
|
||||
} } }
|
||||
};
|
||||
var continued = false;
|
||||
var ex = await Assert.ThrowsAsync<RpcException>(() => CreateInterceptor().UnaryServerHandler<object, object>(
|
||||
request, CreateContext(ControlMethod, SiteA, $"Bearer {SiteAKey}"), async (r, context) =>
|
||||
{
|
||||
continued = true;
|
||||
return r switch
|
||||
{
|
||||
NotificationSubmitDto n => await service.SubmitNotification(n, context),
|
||||
ReconcileSiteRequestDto n => await service.ReconcileSite(n, context),
|
||||
SiteHealthReportDto n => await service.ReportSiteHealth(n, context),
|
||||
HeartbeatDto n => await service.Heartbeat(n, context),
|
||||
AuditEventBatch n => await service.IngestAuditEvents(n, context),
|
||||
CachedTelemetryBatch n => await service.IngestCachedTelemetry(n, context),
|
||||
_ => throw new InvalidOperationException()
|
||||
};
|
||||
}));
|
||||
Assert.Equal(StatusCode.PermissionDenied, ex.StatusCode);
|
||||
Assert.False(continued); // no actor dispatch, token mint, or partial batch ingest
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task NonGatedMethod_PassesThrough()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user