test(grpc-data): A2b — pre-authorization bound to its own context (role-less local session denied); mutation-checked
This commit is contained in:
+10
-2
@@ -24,6 +24,7 @@ public sealed class ConditionMethodNodeManagerTests : IDisposable
|
||||
private const uint BadEventIdUnknown = 0x809A0000u;
|
||||
|
||||
private static CancellationToken Ct => TestContext.Current.CancellationToken;
|
||||
private OtOpcUaSdkServer? _server;
|
||||
private readonly string _pkiRoot = Path.Combine(Path.GetTempPath(), $"otopcua-a2b-{Guid.NewGuid():N}");
|
||||
|
||||
private static AlarmConditionSnapshot State(bool active, bool acked, string message = "hi") => new(
|
||||
@@ -209,7 +210,8 @@ public sealed class ConditionMethodNodeManagerTests : IDisposable
|
||||
[Fact]
|
||||
public async Task The_pre_authorization_never_leaks_to_a_local_session_call()
|
||||
{
|
||||
// A local client's call still goes through the session gate: an identity with no AlarmAck role is denied.
|
||||
// A local client's call still goes through the session gate: an authenticated identity with no AlarmAck role
|
||||
// (and no ACL) is denied — the remote pre-authorization is bound to its own internal context type only.
|
||||
var (host, nm, _) = await BootAsync();
|
||||
Materialise(nm);
|
||||
var routed = new List<NativeAlarmAck>();
|
||||
@@ -217,7 +219,12 @@ public sealed class ConditionMethodNodeManagerTests : IDisposable
|
||||
nm.WriteAlarmCondition(Native, State(true, false), DateTime.UtcNow, AddressSpaceRealm.Raw);
|
||||
var alarm = nm.TryGetAlarmCondition(Native, AddressSpaceRealm.Raw)!;
|
||||
|
||||
var result = alarm.Acknowledge!.OnCall!(nm.SystemContext, alarm.Acknowledge, alarm.NodeId, alarm.EventId!.Value, new LocalizedText("x"));
|
||||
var session = new Opc.Ua.Server.ServerSystemContext(_server!.CurrentInstance)
|
||||
{
|
||||
UserIdentity = new ZB.MOM.WW.OtOpcUa.OpcUaServer.Security.RoleCarryingUserIdentity(
|
||||
new UserNameIdentityToken { UserName = "apikey" }, [], principal: "peer-svc", apiKeyId: "0a1b2c3d4e5f6071"),
|
||||
};
|
||||
var result = alarm.Acknowledge!.OnCall!(session, alarm.Acknowledge, alarm.NodeId, alarm.EventId!.Value, new LocalizedText("x"));
|
||||
|
||||
ServiceResult.IsBad(result).ShouldBeTrue();
|
||||
routed.ShouldBeEmpty();
|
||||
@@ -262,6 +269,7 @@ public sealed class ConditionMethodNodeManagerTests : IDisposable
|
||||
Microsoft.Extensions.Logging.Abstractions.NullLogger<OpcUaApplicationHost>.Instance),
|
||||
() => new OtOpcUaSdkServer(), Ct);
|
||||
var nm = started.Server.NodeManager!;
|
||||
_server = started.Server;
|
||||
var sink = new RecordingConditionSink();
|
||||
nm.ConditionStateSink = sink;
|
||||
return (started.Host, nm, sink);
|
||||
|
||||
Reference in New Issue
Block a user