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:
@@ -7,7 +7,7 @@ using ZB.MOM.WW.ScadaBridge.Security;
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Auth;
|
||||
|
||||
/// <summary>
|
||||
/// Regression tests for CentralUI-002. Site-scoped Deployment permissions are
|
||||
/// Regression tests for site-scoped permissions. Site-scoped Deployment permissions are
|
||||
/// written as <c>SiteId</c> claims at login but were never read — Deployment
|
||||
/// pages listed and acted on every site. <see cref="SiteScopeService"/> is the
|
||||
/// shared helper that reads those claims; these tests pin its behaviour.
|
||||
@@ -17,7 +17,10 @@ public class SiteScopeServiceTests
|
||||
private sealed class StubAuthStateProvider : AuthenticationStateProvider
|
||||
{
|
||||
private readonly ClaimsPrincipal _user;
|
||||
/// <summary>Initializes a new instance of the <c>StubAuthStateProvider</c> class.</summary>
|
||||
/// <param name="user">The user.</param>
|
||||
public StubAuthStateProvider(ClaimsPrincipal user) => _user = user;
|
||||
/// <inheritdoc />
|
||||
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
=> Task.FromResult(new AuthenticationState(_user));
|
||||
}
|
||||
@@ -34,6 +37,8 @@ public class SiteScopeServiceTests
|
||||
private static List<Site> Sites(params int[] ids)
|
||||
=> ids.Select(id => new Site($"Site{id}", $"SITE-{id}") { Id = id }).ToList();
|
||||
|
||||
/// <summary>Verifies that a deployer with no site claims is treated as system-wide.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task DeploymentUserWithNoSiteClaims_IsSystemWide()
|
||||
{
|
||||
@@ -43,6 +48,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Empty(await svc.PermittedSiteIdsAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that filtering sites for a system-wide user returns every site.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SystemWideUser_FilterSites_ReturnsAllSites()
|
||||
{
|
||||
@@ -53,6 +60,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Equal(new[] { 1, 2, 3 }, filtered.Select(s => s.Id));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that filtering sites for a scoped user returns only the permitted sites.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ScopedUser_FilterSites_ReturnsOnlyPermittedSites()
|
||||
{
|
||||
@@ -64,6 +73,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Equal(new[] { 1, 3 }, filtered.Select(s => s.Id).OrderBy(x => x));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a scoped user is allowed access only to the sites they were granted.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ScopedUser_IsSiteAllowed_OnlyForGrantedSites()
|
||||
{
|
||||
@@ -73,6 +84,8 @@ public class SiteScopeServiceTests
|
||||
Assert.False(await svc.IsSiteAllowedAsync(6));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a scoped user is not system-wide and reports its permitted site ids.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ScopedUser_IsNotSystemWide_AndReportsItsPermittedIds()
|
||||
{
|
||||
@@ -82,6 +95,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Equal(new[] { 7, 9 }, (await svc.PermittedSiteIdsAsync()).OrderBy(x => x));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a system-wide user is allowed access to any site.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task SystemWideUser_IsSiteAllowed_ForAnySite()
|
||||
{
|
||||
@@ -99,6 +114,8 @@ public class SiteScopeServiceTests
|
||||
// could act fleet-wide through the CLI/HTTP surface while the UI hid the same
|
||||
// sites. The UI was the side that disagreed with the documented rule.
|
||||
|
||||
/// <summary>Verifies that an administrator carrying site claims is still system-wide.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AdministratorWithSiteClaims_IsSystemWide()
|
||||
{
|
||||
@@ -107,6 +124,8 @@ public class SiteScopeServiceTests
|
||||
Assert.True(await svc.IsSystemWideAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that filtering sites for an administrator with site claims returns every site.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AdministratorWithSiteClaims_FilterSites_ReturnsAllSites()
|
||||
{
|
||||
@@ -117,6 +136,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Equal(new[] { 1, 2, 3 }, filtered.Select(s => s.Id));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an administrator with site claims is allowed access to sites outside those claims.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AdministratorWithSiteClaims_IsSiteAllowed_ForSitesOutsideTheClaims()
|
||||
{
|
||||
@@ -125,6 +146,8 @@ public class SiteScopeServiceTests
|
||||
Assert.True(await svc.IsSiteAllowedAsync(2));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an administrator with site claims reports no permitted site ids.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task AdministratorWithSiteClaims_ReportsNoPermittedIds()
|
||||
{
|
||||
@@ -136,6 +159,9 @@ public class SiteScopeServiceTests
|
||||
Assert.Empty(await svc.PermittedSiteIdsAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the administrator role match ignores case.</summary>
|
||||
/// <param name="role">The role.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Theory]
|
||||
[InlineData("administrator")]
|
||||
[InlineData("ADMINISTRATOR")]
|
||||
@@ -150,6 +176,8 @@ public class SiteScopeServiceTests
|
||||
Assert.True(await svc.IsSystemWideAsync());
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a designer with site claims remains scoped to those sites.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task DesignerWithSiteClaims_IsStillScoped()
|
||||
{
|
||||
@@ -172,6 +200,8 @@ public class SiteScopeServiceTests
|
||||
private static ClaimsPrincipal Principal(params Claim[] claims)
|
||||
=> new(new ClaimsIdentity(claims, authenticationType: "TestCookie"));
|
||||
|
||||
/// <summary>Verifies that resolving an administrator yields a system-wide scope with an empty site set.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
public void Resolve_Administrator_IsSystemWideWithAnEmptySet()
|
||||
{
|
||||
@@ -184,6 +214,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Empty(sites);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that resolving a principal with site claims yields the scoped site set.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
public void Resolve_SiteClaims_YieldTheScopedSet()
|
||||
{
|
||||
@@ -194,6 +226,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Equal([1, 3], sites.OrderBy(id => id));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that resolving a principal with no site claims yields a system-wide scope.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
public void Resolve_NoSiteClaims_IsSystemWide()
|
||||
{
|
||||
@@ -203,6 +237,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Empty(sites);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that resolving an unauthenticated principal yields a scope with no permitted sites.</summary>
|
||||
/// <returns>The result.</returns>
|
||||
[Fact]
|
||||
public void Resolve_UnauthenticatedPrincipal_IsScopedToNothing()
|
||||
{
|
||||
@@ -213,6 +249,8 @@ public class SiteScopeServiceTests
|
||||
Assert.Empty(sites);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the synchronous resolve produces the same result as the async path.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task Resolve_AgreesWithTheAsyncPath()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user