using Opc.Ua; using Opc.Ua.Client; using Shouldly; using Xunit; namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.DataConnections; public sealed partial class GrpcDataConfiguredDiscoveryWireTests { /// /// H2 review 7: DataOperationPolicy 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. /// [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); } }