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:
@@ -28,7 +28,7 @@ using AuditLogPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Audit.Audi
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Pages;
|
||||
|
||||
/// <summary>
|
||||
/// Permission-gating tests for the Audit Log surface (#23 M7-T15 / Bundle G).
|
||||
/// Permission-gating tests for the Audit Log surface (Bundle G).
|
||||
///
|
||||
/// <para>
|
||||
/// Bundle G introduces two new policies:
|
||||
@@ -38,7 +38,7 @@ namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Pages;
|
||||
/// <item><c>AuditExport</c> — additional gate on the Export-CSV button and
|
||||
/// the streaming export endpoint.</item>
|
||||
/// </list>
|
||||
/// Post Task 1.7: <c>AuditExport</c> is satisfied only by the
|
||||
/// After the role consolidation, <c>AuditExport</c> is satisfied only by the
|
||||
/// <c>Administrator</c> role (which absorbed the former <c>Audit</c> role);
|
||||
/// <c>OperationalAudit</c> is additionally satisfied by the <c>Viewer</c> role
|
||||
/// (the home of the former <c>AuditReadOnly</c> role) — Viewer reads but cannot
|
||||
@@ -48,6 +48,7 @@ namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Pages;
|
||||
/// </summary>
|
||||
public class AuditLogPagePermissionTests : BunitContext
|
||||
{
|
||||
/// <summary>Initializes the test context and registers the fake authentication and service stand-ins.</summary>
|
||||
public AuditLogPagePermissionTests()
|
||||
{
|
||||
// The page hosts AuditResultsGrid, whose OnAfterRenderAsync wires the
|
||||
@@ -71,7 +72,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
// a permitted render is exercised end-to-end.
|
||||
Services.AddSingleton(Substitute.For<ISiteRepository>());
|
||||
Services.AddSingleton(Substitute.For<IAuditLogQueryService>());
|
||||
// M6 (K15): the page now injects IKpiHistoryQueryService for the Trends
|
||||
// The page now injects IKpiHistoryQueryService for the Trends
|
||||
// panel — register a stand-in so a permitted render is exercised end-to-end.
|
||||
Services.AddSingleton(Substitute.For<IKpiHistoryQueryService>());
|
||||
}
|
||||
@@ -109,6 +110,8 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
// so we verify the attribute is present + the policy denies a principal
|
||||
// that holds none of the permitting roles.
|
||||
|
||||
/// <summary>Verifies that a user without the OperationalAudit permission is denied by the policy.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task WithoutOperationalAudit_PolicyDenies()
|
||||
{
|
||||
@@ -127,6 +130,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
Assert.False(result.Succeeded);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the Audit Log page carries the OperationalAudit authorize attribute.</summary>
|
||||
[Fact]
|
||||
public void AuditLogPage_HasOperationalAuditAuthorizeAttribute()
|
||||
{
|
||||
@@ -140,6 +144,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
Assert.Contains(attributes, a => a.Policy == AuthorizationPolicies.OperationalAudit);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the Configuration Audit Log page carries the OperationalAudit authorize attribute.</summary>
|
||||
[Fact]
|
||||
public void ConfigurationAuditLogPage_HasOperationalAuditAuthorizeAttribute()
|
||||
{
|
||||
@@ -159,13 +164,14 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
// Test 2 + 3: Export button visibility split.
|
||||
// ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that a user with OperationalAudit but without AuditExport sees the page with the export button hidden.</summary>
|
||||
[Fact]
|
||||
public void WithOperationalAudit_NoAuditExport_PageRenders_ExportButtonHidden()
|
||||
{
|
||||
// The "Administrator" role grants OperationalAudit + AuditExport, so we
|
||||
// test the split by handing the user ONLY the "Viewer" role, which maps
|
||||
// to OperationalAudit (read) but NOT AuditExport — the preserved
|
||||
// half-SoD after the Task 1.7 AuditReadOnly→Viewer collapse
|
||||
// half-SoD after the AuditReadOnly→Viewer collapse
|
||||
// (see AuthorizationPolicies).
|
||||
var cut = RenderAuditLogPage("Viewer");
|
||||
|
||||
@@ -178,6 +184,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a user with both OperationalAudit and AuditExport sees the page with the export button visible.</summary>
|
||||
[Fact]
|
||||
public void WithOperationalAudit_AndAuditExport_PageRenders_ExportButtonVisible()
|
||||
{
|
||||
@@ -190,6 +197,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an Administrator sees the page and the export button.</summary>
|
||||
[Fact]
|
||||
public void AdminUser_SeesPage_AndExportButton()
|
||||
{
|
||||
@@ -208,6 +216,8 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
// Test 4 + 5: Endpoint-level enforcement.
|
||||
// ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that the export endpoint returns 403 for a caller without AuditExport.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AuditExportEndpoint_WithoutAuditExport_Returns403()
|
||||
{
|
||||
@@ -221,6 +231,8 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the export endpoint returns 200 for a caller with AuditExport.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AuditExportEndpoint_WithAuditExport_Returns200()
|
||||
{
|
||||
@@ -232,6 +244,8 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the export endpoint returns 200 for an Administrator alone.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AuditExportEndpoint_AdminAlone_Returns200()
|
||||
{
|
||||
@@ -245,6 +259,8 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the export endpoint returns 403 for a Viewer.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AuditExportEndpoint_Viewer_Returns403()
|
||||
{
|
||||
@@ -313,12 +329,17 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
{
|
||||
public const string SchemeName = "FakeAuth";
|
||||
|
||||
/// <summary>Initializes the handler with the standard authentication handler dependencies.</summary>
|
||||
/// <param name="options">The options monitor for the fake handler.</param>
|
||||
/// <param name="logger">The logger factory.</param>
|
||||
/// <param name="encoder">The URL encoder.</param>
|
||||
public FakeAuthHandler(
|
||||
IOptionsMonitor<FakeAuthHandlerOptions> options,
|
||||
ILoggerFactory logger,
|
||||
UrlEncoder encoder)
|
||||
: base(options, logger, encoder) { }
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
var claims = new List<Claim> { new(ClaimTypes.Name, "test-user") };
|
||||
@@ -335,6 +356,7 @@ public class AuditLogPagePermissionTests : BunitContext
|
||||
|
||||
private sealed class FakeAuthHandlerOptions : AuthenticationSchemeOptions
|
||||
{
|
||||
/// <summary>Gets or sets the roles granted to the fake authenticated user.</summary>
|
||||
public string[] Roles { get; set; } = Array.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user