test(grpc-data): H2 review 7 - mapped HistoryRead on a projected node stays BadHistoryOperationUnsupported until H3
With the mapping HistoryRead bit and a local HistoryRead grant, a real SDK HistoryRead on a projected variable is refused (no HistoryRead access-level bit on projected nodes) with no data and no continuation.
This commit is contained in:
+2
-1
@@ -362,7 +362,7 @@ public sealed partial class GrpcDataConfiguredDiscoveryWireTests
|
||||
bool restrictToPlant = false, Action<ProjectedValueUpdate>? onPublished = null, bool mountAtRealmRoot = false,
|
||||
long maxUnaryBytes = 8_000_000, bool allowWrite = false, IGrpcDataAdapterConnectionSource? connectionSource = null,
|
||||
int? staleTimeoutMilliseconds = null, Func<IProjectedNamespacePageSink, IProjectedNamespacePageSink>? renewalSinkFactory = null,
|
||||
Action<LocalCatalogCoordinator>? onCoordinator = null, int? localPermissions = null)
|
||||
Action<LocalCatalogCoordinator>? onCoordinator = null, int? localPermissions = null, bool allowHistory = false)
|
||||
{
|
||||
var ct = TestContext.Current.CancellationToken;
|
||||
var pki = Path.Combine(Path.GetTempPath(), $"composed-projection-{Guid.NewGuid():N}");
|
||||
@@ -400,6 +400,7 @@ public sealed partial class GrpcDataConfiguredDiscoveryWireTests
|
||||
if (mountAtRealmRoot) { mapping.LocalParentKind = "Cluster"; mapping.LocalParentId = "cluster"; }
|
||||
mapping.AllowedOperations |= DataOperations.Read | DataOperations.Metadata;
|
||||
if (allowWrite) { mapping.AllowedOperations |= DataOperations.Write; mapping.WriteThrough = true; }
|
||||
if (allowHistory) mapping.AllowedOperations |= DataOperations.HistoryRead;
|
||||
placements.Stage(attempt, [mapping], [Connection()]);
|
||||
coordinator.Complete(attempt, true).ShouldBeTrue();
|
||||
var manager = started.Server.NodeManager!;
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Client;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.DataConnections;
|
||||
|
||||
public sealed partial class GrpcDataConfiguredDiscoveryWireTests
|
||||
{
|
||||
/// <summary>
|
||||
/// H2 review 7: <c>DataOperationPolicy</c> now maps OPC UA HistoryRead to the mapping's HistoryRead bit, so a mapped
|
||||
/// HistoryRead is AUTHORISABLE before H3 projects history. Pin that a projected node with the mapping bit AND a local
|
||||
/// HistoryRead grant still answers a clean refusal — never data, never a fault — until H3.
|
||||
/// </summary>
|
||||
[Fact(Timeout = 90000)]
|
||||
[Trait("Phase", "H2")]
|
||||
public async Task HistoryRead_on_a_projected_node_stays_a_clean_refusal_until_H3()
|
||||
{
|
||||
using var origin = new LocalDataFixture(servingGeneration: 1);
|
||||
await WithComposedServer(origin, origin.Raw, async (session, _, _, _, _, _, anchor) =>
|
||||
{
|
||||
var client = (SessionClient)session;
|
||||
await BrowseAll(client, anchor, 1);
|
||||
var details = new ReadRawModifiedDetails
|
||||
{
|
||||
StartTime = DateTime.UtcNow.AddHours(-1), EndTime = DateTime.UtcNow, NumValuesPerNode = 10,
|
||||
IsReadModified = false, ReturnBounds = false,
|
||||
};
|
||||
var response = await client.HistoryReadAsync(new RequestHeader(), new ExtensionObject(details), TimestampsToReturn.Both, false,
|
||||
[new HistoryReadValueId { NodeId = anchor }], TestContext.Current.CancellationToken);
|
||||
var result = response.Results.ToArray()!.Single();
|
||||
// Pinned: the projected variable carries no HistoryRead access-level bit, so the SDK refuses before any history code.
|
||||
result.StatusCode.Code.ShouldBe(StatusCodes.BadHistoryOperationUnsupported.Code);
|
||||
(result.HistoryData.IsNull || ExtensionObject.ToEncodeable(result.HistoryData) is not HistoryData { DataValues.Count: > 0 })
|
||||
.ShouldBeTrue("no data is served from a projected node before H3");
|
||||
result.ContinuationPoint.IsEmpty.ShouldBeTrue();
|
||||
}, localPermissions: 15, allowHistory: true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user