Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.Security.Tests/DisableLoginGuardTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

37 lines
1.6 KiB
C#

using ZB.MOM.WW.ScadaBridge.Security.Auth;
using Xunit;
namespace ZB.MOM.WW.ScadaBridge.Security.Tests;
public class DisableLoginGuardTests
{
/// <summary>Verifies that disabling login outside development without an acknowledgement throws.</summary>
/// <param name="env">The hosting environment name.</param>
[Theory]
[InlineData("Production")]
[InlineData("Staging")]
[InlineData("")]
public void Validate_DisableLoginOutsideDevelopment_WithoutAck_Throws(string env)
{
var ex = Assert.Throws<InvalidOperationException>(
() => DisableLoginGuard.Validate(disableLogin: true, environmentName: env, allowOutsideDevelopment: false));
Assert.Contains("DisableLogin", ex.Message);
Assert.Contains("Development", ex.Message);
}
/// <summary>Verifies that allowed combinations of environment and acknowledgement do not throw.</summary>
/// <param name="env">The hosting environment name.</param>
/// <param name="ack">Whether the explicit acknowledgement is given.</param>
[Theory]
[InlineData("Development", false)] // dev env: allowed without ack
[InlineData("development", false)] // case-insensitive env name
[InlineData("Production", true)] // explicit second ack key
public void Validate_Allowed_DoesNotThrow(string env, bool ack)
=> DisableLoginGuard.Validate(true, env, ack);
/// <summary>Verifies that validation never throws when the disable-login flag is off.</summary>
[Fact]
public void Validate_FlagOff_NeverThrows()
=> DisableLoginGuard.Validate(false, "Production", false);
}