diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionValidator.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionValidator.cs index 9ba11d5ac..dd0f6da64 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionValidator.cs +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DataConnectionValidator.cs @@ -23,9 +23,10 @@ public static class DataConnectionValidator /// Node-side re-validation of an already-deployed artifact (artifact parse, origin catalog compile). Identical to /// except that operation bits outside /// are IGNORED rather than rejected (X0 tolerant reader): a newer central may author them, and rejecting would take - /// down every data connection/export on the node. The understood subset is still validated (a row must be non-empty; - /// a mapping may not grant an understood operation its connection lacks), and every consumer of the rows masks the - /// rest away, so an unknown bit grants nothing (fail closed). + /// down every data connection/export on the node. The understood subset is still validated (a mapping may not grant + /// an understood operation its connection lacks), and every consumer of the rows masks the rest away, so an unknown bit + /// grants nothing (fail closed). A row must carry SOME bit (zero is still invalid), but it may carry only unknown + /// bits: such a row is kept and grants nothing. /// public static IReadOnlyList ValidateDeployed(DraftSnapshot draft) => Validate(draft, deployed: true); diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/LocalExportCatalog.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/LocalExportCatalog.cs index 4eac8c855..f54e00b1f 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/LocalExportCatalog.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/LocalExportCatalog.cs @@ -182,7 +182,10 @@ public sealed partial class LocalExportCatalog internal DataLimits LimitsFor(string principal, DataLimits limits) { - var rules = _exports.Where(x => string.Equals(x.Principal, principal, StringComparison.OrdinalIgnoreCase)).ToArray(); + // An inert rule (X0: only operation bits this build does not implement) grants nothing, so it cannot lower the + // principal's limits on its other exports either. + var rules = _exports.Where(x => string.Equals(x.Principal, principal, StringComparison.OrdinalIgnoreCase) + && x.Operations != DataOperations.None).ToArray(); return rules.Length == 0 ? limits : limits with { MaxBatchItems = Math.Min(limits.MaxBatchItems, rules.Min(x => x.Batch)), diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataUnknownOperationToleranceTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataUnknownOperationToleranceTests.cs index e7076e1ae..9e8991078 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataUnknownOperationToleranceTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataUnknownOperationToleranceTests.cs @@ -140,6 +140,35 @@ public sealed class GrpcDataUnknownOperationToleranceTests catalog.ExportOperations("other").ShouldBe(DataOperations.None); } + [Fact] + public void An_inert_all_unknown_export_does_not_lower_the_principals_limits_on_its_other_exports() + { + using var fixture = new LocalDataFixture(); + var snapshot = new DraftSnapshot + { + GenerationId = 1, ClusterId = "cluster", + ServerClusters = [new() { ClusterId = "cluster", Name = "Cluster", Enterprise = "Enterprise", Site = "Site", CreatedBy = "test", RedundancyMode = RedundancyMode.None }], + RawFolders = [new() { RawFolderId = "folder", ClusterId = "cluster", Name = "Plant" }], + DataExports = + [ + new() { DataExportId = "live", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Raw, RootKind = "Cluster", + RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.Browse | DataOperations.Read, + MaxBatchItems = 100, MaxPageItems = 100, MaxMonitoredItems = 100, MaxStreams = 10 }, + new() { DataExportId = "future-only", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = "Cluster", + RootEntityId = "cluster", PrincipalId = "peer", AllowedOperations = DataOperations.HistoryRead | (DataOperations)(1 << 30), + MaxBatchItems = 1, MaxPageItems = 1, MaxMonitoredItems = 1, MaxStreams = 1 }, + ], + }; + var catalog = LocalExportCatalog.Compile(snapshot, fixture.Serving, fixture.Activation.CaptureAuthority()); + var limits = new DataLimits(1000, 1000, 1_000_000, 1000, 100, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1)); + var effective = catalog.LimitsFor("peer", limits); + effective.MaxBatchItems.ShouldBe(100); + effective.MaxPageItems.ShouldBe(100); + effective.MaxMonitoredItems.ShouldBe(100); + effective.MaxStreams.ShouldBe(10); + catalog.ExportOperations("peer").ShouldBe(DataOperations.Browse | DataOperations.Read); + } + private static async Task Lease(DataConnectionDeploymentRuntime runtime, string id) { DataConnectionDeploymentLease? lease = null;