feat(stability): unify readiness and recovery
CI - Build & Test / Backend (.NET) (push) Successful in 45s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Failing after 1m0s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m49s
CI - Build & Test / Security Check (push) Successful in 7s
CI - Build & Test / Deploy Nexus (push) Has been skipped
CI - Build & Test / Backend (.NET) (push) Successful in 45s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Failing after 1m0s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m49s
CI - Build & Test / Security Check (push) Successful in 7s
CI - Build & Test / Deploy Nexus (push) Has been skipped
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Nexus.Api.Data;
|
||||
using Nexus.Api.DTOs;
|
||||
@@ -209,6 +210,47 @@ public sealed class AuthServiceTests
|
||||
Assert.Equal(originalHash, updated.PasswordHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RefreshToken_SurvivesServiceRestart_WhenDatabasePersists()
|
||||
{
|
||||
var databaseRoot = new InMemoryDatabaseRoot();
|
||||
var databaseName = Guid.NewGuid().ToString();
|
||||
var configuration = new MemoryConfig(new Dictionary<string, string?>
|
||||
{
|
||||
["Jwt:Key"] = "this-is-a-test-key-that-is-at-least-32-bytes-long!",
|
||||
["Jwt:Issuer"] = "nexus-test",
|
||||
["Jwt:Audience"] = "nexus-test-web",
|
||||
});
|
||||
var logger = Microsoft.Extensions.Logging.Abstractions.NullLogger<AuthService>.Instance;
|
||||
|
||||
AuthSession initialSession;
|
||||
await using (var firstDb = new NexusDbContext(
|
||||
new DbContextOptionsBuilder<NexusDbContext>()
|
||||
.UseInMemoryDatabase(databaseName, databaseRoot)
|
||||
.Options))
|
||||
{
|
||||
await SeedUserAsync(firstDb, "restart@example.com", "RestartPassword123!");
|
||||
var firstService = new AuthService(new UserRepository(firstDb), configuration, logger);
|
||||
initialSession = Assert.IsType<AuthSession>(
|
||||
await firstService.LoginAsync(Login("restart@example.com", "RestartPassword123!")));
|
||||
}
|
||||
|
||||
await using var restartedDb = new NexusDbContext(
|
||||
new DbContextOptionsBuilder<NexusDbContext>()
|
||||
.UseInMemoryDatabase(databaseName, databaseRoot)
|
||||
.Options);
|
||||
var restartedService = new AuthService(
|
||||
new UserRepository(restartedDb),
|
||||
configuration,
|
||||
logger);
|
||||
|
||||
var refreshed = await restartedService.RefreshAsync(initialSession.RefreshToken);
|
||||
|
||||
Assert.NotNull(refreshed);
|
||||
Assert.NotEqual(initialSession.RefreshToken, refreshed.RefreshToken);
|
||||
Assert.Equal(initialSession.User.Id, refreshed.User.Id);
|
||||
}
|
||||
|
||||
// ══════════════════════════════════════════════════════════════════
|
||||
// Change Password Tests
|
||||
// ══════════════════════════════════════════════════════════════════
|
||||
|
||||
Reference in New Issue
Block a user