Backend: .NET 10 Clean Architecture + LiteCqrs.Net + EF Core/PostgreSQL + Identity/JWT. Frontend: React 19 + Vite + TanStack Query/Router + Tailwind v4 with a retro CRT theme. Docker/compose deployment mirroring PnvPanel's conventions, scoped down to the current base feature set.
37 lines
912 B
C#
37 lines
912 B
C#
using TeleWave.Domain.Auth;
|
|
using Xunit;
|
|
|
|
namespace TeleWave.Domain.Tests.Auth;
|
|
|
|
public class RefreshTokenTests
|
|
{
|
|
[Fact]
|
|
public void Issue_CreatesActiveToken()
|
|
{
|
|
var token = RefreshToken.Issue(Guid.NewGuid(), "hash", DateTimeOffset.UtcNow.AddDays(1));
|
|
|
|
Assert.True(token.IsActive);
|
|
Assert.Null(token.RevokedAt);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsActive_WhenExpired_ReturnsFalse()
|
|
{
|
|
var token = RefreshToken.Issue(Guid.NewGuid(), "hash", DateTimeOffset.UtcNow.AddDays(-1));
|
|
|
|
Assert.False(token.IsActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void Revoke_MarksTokenInactive()
|
|
{
|
|
var token = RefreshToken.Issue(Guid.NewGuid(), "hash", DateTimeOffset.UtcNow.AddDays(1));
|
|
|
|
token.Revoke("new-hash");
|
|
|
|
Assert.False(token.IsActive);
|
|
Assert.NotNull(token.RevokedAt);
|
|
Assert.Equal("new-hash", token.ReplacedByTokenHash);
|
|
}
|
|
}
|