elsa-core/test/unit/Elsa.ExternalAuthentication.UnitTests/Foundational/ExternalAuthenticationSessionAdministrationTests.cs
2026-09-13 01:10:32 -07:00

31 lines
1.2 KiB
C#

using Elsa.ExternalAuthentication.Models;
using Elsa.ExternalAuthentication.Stores.InMemory;
namespace Elsa.ExternalAuthentication.UnitTests.Foundational;
public class ExternalAuthenticationSessionAdministrationTests
{
[Fact]
public async Task ListsOnlyRequestedTenantAndSafeStatus()
{
var now = DateTimeOffset.UtcNow;
var clock = new TestSystemClock(now);
var store = new InMemoryExternalAuthenticationSessionStore(clock);
var active = ExternalAuthenticationTestData.CreateSession(now);
await store.SaveAsync(active);
var other = ExternalAuthenticationTestData.CreateSession(now);
other.Id = "session-b";
other.TenantId = "tenant-b";
other.CurrentRefreshTokenHash = "refresh-2";
await store.SaveAsync(other);
await store.RevokeAsync(active.Id, "test", now);
var revoked = await store.FindAsync(new ExternalAuthenticationSessionFilter { TenantId = "tenant-a", Status = "revoked" });
var activeSessions = await store.FindAsync(new ExternalAuthenticationSessionFilter { TenantId = "tenant-a", Status = "active" });
Assert.Single(revoked);
Assert.Empty(activeSessions);
Assert.Equal("session-a", revoked.Single().Id);
}
}