test(sessions): cover OwnerKeyId service-layer forwarding; doc 11-param ctor
Add LastOwnerKeyId capture to FakeSessionManager and assert it equals "operator01" in OpenSession_WithValidRequest_ReturnsSessionDetails, closing the gap where OwnerKeyId threading through the service layer had no test coverage. Add a <remarks> to the 11-param GatewaySession convenience ctor documenting that OwnerKeyId is null there and authenticated call sites must use the 12-param overload.
This commit is contained in:
@@ -30,6 +30,11 @@ public sealed class GatewaySession
|
|||||||
/// <param name="startupTimeout">Timeout for worker process startup.</param>
|
/// <param name="startupTimeout">Timeout for worker process startup.</param>
|
||||||
/// <param name="shutdownTimeout">Timeout for worker process shutdown.</param>
|
/// <param name="shutdownTimeout">Timeout for worker process shutdown.</param>
|
||||||
/// <param name="openedAt">Timestamp when the session opened.</param>
|
/// <param name="openedAt">Timestamp when the session opened.</param>
|
||||||
|
/// <remarks>
|
||||||
|
/// Constructs a session with no owner key (<see cref="OwnerKeyId"/> will be null).
|
||||||
|
/// Authenticated call sites that have a resolved API key identity must use the
|
||||||
|
/// 12-parameter overload and pass the caller's key id explicitly.
|
||||||
|
/// </remarks>
|
||||||
public GatewaySession(
|
public GatewaySession(
|
||||||
string sessionId,
|
string sessionId,
|
||||||
string backendName,
|
string backendName,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public sealed class MxAccessGatewayServiceTests
|
|||||||
Assert.Equal(ProtocolStatusCode.Ok, reply.ProtocolStatus.Code);
|
Assert.Equal(ProtocolStatusCode.Ok, reply.ProtocolStatus.Code);
|
||||||
Assert.Contains("unary-invoke", reply.Capabilities);
|
Assert.Contains("unary-invoke", reply.Capabilities);
|
||||||
Assert.Equal("Operator Key", sessionManager.LastClientIdentity);
|
Assert.Equal("Operator Key", sessionManager.LastClientIdentity);
|
||||||
|
Assert.Equal("operator01", sessionManager.LastOwnerKeyId);
|
||||||
Assert.Equal("operator-session", sessionManager.LastOpenRequest?.ClientSessionName);
|
Assert.Equal("operator-session", sessionManager.LastOpenRequest?.ClientSessionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,6 +509,9 @@ public sealed class MxAccessGatewayServiceTests
|
|||||||
/// <summary>The last client identity passed to OpenSessionAsync.</summary>
|
/// <summary>The last client identity passed to OpenSessionAsync.</summary>
|
||||||
public string? LastClientIdentity { get; private set; }
|
public string? LastClientIdentity { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>The last owner key id passed to OpenSessionAsync.</summary>
|
||||||
|
public string? LastOwnerKeyId { get; private set; }
|
||||||
|
|
||||||
/// <summary>The last session ID passed to ReadEventsAsync.</summary>
|
/// <summary>The last session ID passed to ReadEventsAsync.</summary>
|
||||||
public string? LastReadEventsSessionId { get; private set; }
|
public string? LastReadEventsSessionId { get; private set; }
|
||||||
|
|
||||||
@@ -550,6 +554,7 @@ public sealed class MxAccessGatewayServiceTests
|
|||||||
{
|
{
|
||||||
LastOpenRequest = request;
|
LastOpenRequest = request;
|
||||||
LastClientIdentity = clientIdentity;
|
LastClientIdentity = clientIdentity;
|
||||||
|
LastOwnerKeyId = ownerKeyId;
|
||||||
|
|
||||||
return Task.FromResult(OpenSessionResult ?? CreateSession("session-1", processId: 1234));
|
return Task.FromResult(OpenSessionResult ?? CreateSession("session-1", processId: 1234));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user