Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.Tests/Auth/SessionExpiryPolicyTests.cs
T
Joseph Doherty 7b0b9c7365 refactor: rename ScadaLink → ZB.MOM.WW.ScadaBridge (code + projects + namespaces)
Solution + 23 src projects + 26 test projects renamed; folders, csproj,
namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated.
ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated.
SQL roles/logins, LDAP domains, CLI command name, and CLI config dir
(~/.scadalink → ~/.scadabridge) also renamed.

Build green; 5 Host.Tests fail awaiting SQL login rename in next commit.
Pre-existing StaleTagMonitor timing flakes unchanged.

Rename script committed at tools/rename-to-scadabridge.sh.
2026-05-28 09:37:45 -04:00

47 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Authentication;
using ZB.MOM.WW.ScadaBridge.CentralUI.Auth;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Auth;
/// <summary>
/// Regression tests for CentralUI-005. <c>AuthEndpoints</c> previously stamped a
/// fixed <c>expires_at = UtcNow + 30 min</c> claim and a 30-minute absolute cookie
/// <c>ExpiresUtc</c> with no sliding refresh, contradicting the documented
/// "sliding refresh, 30-minute idle timeout" policy. The login handler must now
/// build <see cref="AuthenticationProperties"/> that let the cookie middleware
/// own expiry (sliding window) rather than imposing a contradictory fixed
/// absolute cap.
/// </summary>
public class SessionExpiryPolicyTests
{
[Fact]
public void BuildSignInProperties_DoesNotSetFixedAbsoluteExpiry()
{
var props = AuthEndpoints.BuildSignInProperties();
// A fixed ExpiresUtc would re-introduce the hard 30-minute cap that
// overrides the middleware's sliding window. Expiry must be owned by
// the cookie middleware (ExpireTimeSpan + SlidingExpiration).
Assert.Null(props.ExpiresUtc);
}
[Fact]
public void BuildSignInProperties_IsPersistent()
{
var props = AuthEndpoints.BuildSignInProperties();
Assert.True(props.IsPersistent);
}
[Fact]
public void BuildSignInProperties_AllowsSlidingRefresh()
{
var props = AuthEndpoints.BuildSignInProperties();
// AllowRefresh left null/true lets the cookie middleware slide the
// expiry on activity. A false value would freeze the session to an
// absolute cap — the bug this finding pins.
Assert.NotEqual(false, props.AllowRefresh);
}
}