Files
lmxopcua/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataProjectedHistoryRefusalTests.cs
T
Joseph Doherty 7e22601ee7 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.
2026-11-23 22:11:28 -05:00

40 lines
2.1 KiB
C#

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);
}
}