Path: redb-identity/tests/redb.Identity.Tests/Session/SessionIntegrationTests.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Session/SessionIntegrationTests.cs
----
using AwesomeAssertions;
using redb.Identity.Contracts.Common;
using redb.Identity.Contracts.Routes;
using redb.Identity.Tests.Infrastructure;
using Xunit;
using Xunit.Abstractions;
namespace redb.Identity.Tests.Session;
///
/// Integration tests for session management via direct-vm routes.
/// Uses with full OpenIddict pipeline.
///
[Collection("ProductionBootstrap")]
public class SessionIntegrationTests
{
private readonly ProductionBootstrapFixture _fx;
private readonly ITestOutputHelper _output;
public SessionIntegrationTests(ProductionBootstrapFixture fx, ITestOutputHelper output)
{
_fx = fx;
_output = output;
}
[Fact]
public async Task AuthCode_CreatesSession()
{
// Authenticate to create a session
var authorizeResult = await Authorize();
authorizeResult.Should().ContainKey("code", "Auth should succeed and create a session");
// List sessions for the test user
var userId = await GetTestUserId();
var listExchange = await _fx.RequestWithHeaders(IdentityEndpoints.ManageSessions,
new Dictionary { ["userId"] = userId },
new Dictionary { ["operation"] = "list" });
var sessions = listExchange.Out?.Body.Should().BeAssignableTo>().Subject;
sessions.Should().NotBeEmpty("Authentication should have created a session");
_output.WriteLine($"Found {sessions!.Count()} sessions for user {userId}");
}
[Fact]
public async Task ManageSessions_ListReturnsSessionInfo()
{
// Authenticate first
await Authorize();
var userId = await GetTestUserId();
var listExchange = await _fx.RequestWithHeaders(IdentityEndpoints.ManageSessions,
new Dictionary { ["userId"] = userId },
new Dictionary { ["operation"] = "list" });
var sessions = listExchange.Out?.Body as IEnumerable