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.
This commit is contained in:
@@ -16,6 +16,8 @@ namespace ZB.MOM.WW.ScadaBridge.Host.Tests;
|
||||
|
||||
public class SessionActivityHttpIntegrationTests
|
||||
{
|
||||
/// <summary>Verifies that a passive ping and a role replacement do not renew the cookie, and the session expires when idle.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task PassivePing_RoleReplacementDoesNotRenewCookie_AndIdleExpires()
|
||||
{
|
||||
@@ -31,6 +33,8 @@ public class SessionActivityHttpIntegrationTests
|
||||
Assert.False((await fixture.Circuit!.GetAuthoritativeStateAsync()).User.Identity!.IsAuthenticated);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that antiforgery-protected activity renews both the HTTP session and the existing circuit, and then both expire.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AntiforgeryActivity_RenewsHttpAndExistingCircuit_ThenBothExpire()
|
||||
{
|
||||
@@ -53,6 +57,8 @@ public class SessionActivityHttpIntegrationTests
|
||||
Assert.False((await fixture.Circuit.GetAuthoritativeStateAsync()).User.Identity!.IsAuthenticated);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that missing antiforgery does not renew the session, and expired activity cannot revive it.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task MissingAntiforgeryDoesNotRenew_AndExpiredActivityCannotRevive()
|
||||
{
|
||||
@@ -74,10 +80,14 @@ public class SessionActivityHttpIntegrationTests
|
||||
private readonly WebApplication _app;
|
||||
private HttpClient _client = null!;
|
||||
private readonly Dictionary<string, string> _cookies = [];
|
||||
/// <summary>Gets the fake clock that drives session expiry.</summary>
|
||||
public Clock Clock { get; }
|
||||
/// <summary>Gets the authentication state provider of the circuit created at login, if any.</summary>
|
||||
public CookieAuthenticationStateProvider? Circuit { get; private set; }
|
||||
private Fixture(WebApplication app, Clock clock) { _app = app; Clock = clock; }
|
||||
|
||||
/// <summary>Creates and starts a test server fixture.</summary>
|
||||
/// <returns>The started fixture.</returns>
|
||||
public static async Task<Fixture> CreateAsync()
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder();
|
||||
@@ -108,8 +118,17 @@ public class SessionActivityHttpIntegrationTests
|
||||
fixture._client = app.GetTestClient();
|
||||
return fixture;
|
||||
}
|
||||
/// <summary>Signs in through the test login endpoint.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async Task LoginAsync() { using var response = await SendAsync(HttpMethod.Get, "/test/login"); response.EnsureSuccessStatusCode(); }
|
||||
/// <summary>Fetches an antiforgery request token from the test token endpoint.</summary>
|
||||
/// <returns>The antiforgery request token.</returns>
|
||||
public async Task<string> TokenAsync() { using var response = await SendAsync(HttpMethod.Get, "/test/token"); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsStringAsync(); }
|
||||
/// <summary>Sends a request carrying the stored cookies and an optional antiforgery token.</summary>
|
||||
/// <param name="method">The HTTP method.</param>
|
||||
/// <param name="path">The request path.</param>
|
||||
/// <param name="token">The antiforgery token to send, or null for none.</param>
|
||||
/// <returns>The HTTP response.</returns>
|
||||
public async Task<HttpResponseMessage> SendAsync(HttpMethod method, string path, string? token = null)
|
||||
{
|
||||
using var request = new HttpRequestMessage(method, path);
|
||||
@@ -120,16 +139,26 @@ public class SessionActivityHttpIntegrationTests
|
||||
foreach (var value in values) { var pair = value.Split(';')[0].Split('=', 2); _cookies[pair[0]] = pair[1]; }
|
||||
return response;
|
||||
}
|
||||
/// <summary>Disposes the HTTP client and the web application.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async ValueTask DisposeAsync() { _client.Dispose(); await _app.DisposeAsync(); }
|
||||
}
|
||||
private sealed class Clock : TimeProvider
|
||||
{
|
||||
/// <summary>Gets or sets the current fake time.</summary>
|
||||
public DateTimeOffset Now { get; set; } = new(2026, 9, 9, 12, 0, 0, TimeSpan.Zero);
|
||||
/// <inheritdoc />
|
||||
public override DateTimeOffset GetUtcNow() => Now;
|
||||
/// <summary>Advances the fake clock.</summary>
|
||||
/// <param name="minutes">The number of minutes to advance.</param>
|
||||
public void Advance(int minutes) => Now = Now.AddMinutes(minutes);
|
||||
}
|
||||
private sealed class Mapper : IGroupRoleMapper<string>
|
||||
{
|
||||
/// <summary>Maps every group set to the Deployer role.</summary>
|
||||
/// <param name="groups">The directory groups to map (ignored).</param>
|
||||
/// <param name="ct">The cancellation token.</param>
|
||||
/// <returns>A task yielding a fixed Deployer role mapping.</returns>
|
||||
public Task<GroupRoleMapping<string>> MapAsync(IReadOnlyList<string> groups, CancellationToken ct)
|
||||
=> Task.FromResult(new GroupRoleMapping<string>([Roles.Deployer], new RoleMappingResult([Roles.Deployer], ["1"], false)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user