Formats code comments as sentences in the tests.

Capitalizes the first word and adds the terminal period in the unit, integration and security tests. The AAA markers stay bare, the TODO bodies stay lowercase, and no assertion, payload, expected status code or test signature changes.
This commit is contained in:
BinaryAlley committed 2026-11-16 18:17:29 +02:00
1 parent 727aa33318
commit 057f557791
540 files changed
+3888 -3888

No files matched your search

@@ -104,8 +104,8 @@ public class ChangePasswordEndpointTests : IClassFixture<LuminaApiFactory>, IDis
}
[Theory]
[InlineData("'; DROP TABLE Users--")] // destructive injection
[InlineData("' OR '1'='1")] // boolean-based injection
[InlineData("'; DROP TABLE Users--")] // Destructive injection.
[InlineData("' OR '1'='1")] // Boolean-based injection.
public async Task ChangePassword_WithSQLInjectionInUsername_ShouldNotCorruptOrDeleteData(string maliciousUsername)
{
// Arrange
@@ -81,12 +81,12 @@ public class LoginEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
JwtSecurityTokenHandler handler = new();
JwtSecurityToken token = handler.ReadJwtToken(result!.Token);
string expValue = token.Claims.First(c => c.Type == "exp").Value; // get token claims
string expValue = token.Claims.First(c => c.Type == "exp").Value; // Get token claims.
DateTimeOffset tokenExpiration = DateTimeOffset.FromUnixTimeSeconds(long.Parse(expValue));
DateTimeOffset expectedExpiration = beforeRequest.AddMinutes(15);
// Verify token duration (should be 15 minutes from request time - expiration value is set in tests setup class).
TimeSpan allowedVariance = TimeSpan.FromSeconds(30); // allow for processing time
TimeSpan allowedVariance = TimeSpan.FromSeconds(30); // Allow for processing time.
TimeSpan actualDifference = tokenExpiration - beforeRequest;
TimeSpan expectedDifference = TimeSpan.FromMinutes(15);
@@ -178,11 +178,11 @@ public class LoginEndpointTests : IClassFixture<LuminaApiFactory>, IDisposable
}
[Theory]
[InlineData("' OR '1'='1")] // basic SQL injection
[InlineData("admin'--")] // comment injection
[InlineData("' UNION SELECT * FROM Users--")] // union injection
[InlineData("'; DROP TABLE Users--")] // destructive injection
[InlineData("' WAITFOR DELAY '0:0:10'--")] // time-based injection
[InlineData("' OR '1'='1")] // Basic SQL injection.
[InlineData("admin'--")] // Comment injection.
[InlineData("' UNION SELECT * FROM Users--")] // Union injection.
[InlineData("'; DROP TABLE Users--")] // Destructive injection.
[InlineData("' WAITFOR DELAY '0:0:10'--")] // Time-based injection.
public async Task Login_WithSQLInjectionAttempt_ShouldRemainSecure(string maliciousUsername)
{
// Arrange
@@ -88,8 +88,8 @@ public class RecoverPasswordEndpointTests : IClassFixture<LuminaApiFactory>, IDi
}
[Theory]
[InlineData("'; DROP TABLE Users--")] // destructive injection
[InlineData("' OR '1'='1")] // boolean-based injection
[InlineData("'; DROP TABLE Users--")] // Destructive injection.
[InlineData("' OR '1'='1")] // Boolean-based injection.
public async Task RecoverPassword_WithSQLInjectionInUsername_ShouldNotCorruptOrDeleteData(string maliciousUsername)
{
// Arrange
@@ -106,11 +106,11 @@ public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposabl
}
[Theory]
[InlineData("' OR '1'='1")] // basic SQL injection
[InlineData("admin'--")] // comment injection
[InlineData("' UNION SELECT * FROM Users--")] // union injection
[InlineData("'; DROP TABLE Users--")] // destructive injection
[InlineData("' WAITFOR DELAY '0:0:10'--")] // time-based injection
[InlineData("' OR '1'='1")] // Basic SQL injection.
[InlineData("admin'--")] // Comment injection.
[InlineData("' UNION SELECT * FROM Users--")] // Union injection.
[InlineData("'; DROP TABLE Users--")] // Destructive injection.
[InlineData("' WAITFOR DELAY '0:0:10'--")] // Time-based injection.
public async Task Register_WithSQLInjectionAttempt_ShouldRemainSecure(string maliciousUsername)
{
// Arrange
@@ -135,10 +135,10 @@ public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposabl
}
[Theory]
[InlineData("password123")] // common password
[InlineData("123456789")] // numeric only
[InlineData("abcdefgh")] // lowercase only
[InlineData("short")] // too short
[InlineData("password123")] // Common password.
[InlineData("123456789")] // Numeric only.
[InlineData("abcdefgh")] // Lowercase only.
[InlineData("short")] // Too short.
public async Task Register_WithWeakPassword_ShouldBeDenied(string weakPassword)
{
// Arrange
@@ -156,12 +156,12 @@ public class RegisterEndpointTests : IClassFixture<LuminaApiFactory>, IDisposabl
// Assert
Assert.Equal(HttpStatusCode.UnprocessableEntity, response.StatusCode);
Assert.DoesNotContain(weakPassword, content); // shouldn't leak the actual password
Assert.DoesNotContain(weakPassword, content); // Shouldn't leak the actual password.
}
[Theory]
[InlineData("TestPass123!")] // valid password
[InlineData("Ab1!defghijklmnopqrstuvwxyz")] // long password
[InlineData("TestPass123!")] // Valid password.
[InlineData("Ab1!defghijklmnopqrstuvwxyz")] // Long password.
public async Task Register_WithValidPassword_ShouldAcceptPassword(string password)
{
// Arrange
@@ -144,8 +144,8 @@ public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture<LuminaApi
}
[Theory]
[InlineData("'; DROP TABLE UserRoles; --")] // destructive injection
[InlineData("' OR '1'='1")] // boolean-based injection
[InlineData("'; DROP TABLE UserRoles; --")] // Destructive injection.
[InlineData("' OR '1'='1")] // Boolean-based injection.
public async Task UpdateUserRoleAndPermissions_WithInjectionInUserIdRouteSegment_ShouldNotLeakOrExecuteSql(string maliciousUserId)
{
// Arrange
@@ -161,10 +161,10 @@ public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture<LuminaApi
HttpResponseMessage response = await client.PutAsJsonAsync($"/api/v1/auth/users/{Uri.EscapeDataString(maliciousUserId)}/role-and-permissions", request);
// Assert
// note: the {userId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler
// note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding failure into a
// 500 response instead of 400/422 (pre-existing production bug, not fixed here), and that body leaks the binding exception details
// note: what matters is that the injection never reaches the database, so no SQL engine error (SqliteException) may surface
// Note: the {userId} route parameter is Guid-typed, so the malicious value fails model binding before it reaches the handler.
// Note: observed status is 500 because FastEndpoints, combined with DontCatchExceptions(), turns the binding failure into a
// 500 response instead of 400/422 (pre-existing production bug, not fixed here), and that body leaks the binding exception details.
// Note: what matters is that the injection never reaches the database, so no SQL engine error (SqliteException) may surface.
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
string content = await response.Content.ReadAsStringAsync();
Assert.DoesNotContain("SqliteException", content, StringComparison.OrdinalIgnoreCase);
@@ -174,12 +174,12 @@ public class UpdateUserRoleAndPermissionsEndpointTests : IClassFixture<LuminaApi
}
[Theory]
[InlineData("'; DROP TABLE UserPermissions; --")] // destructive injection
[InlineData("' OR '1'='1")] // boolean-based injection
[InlineData("'; DROP TABLE UserPermissions; --")] // Destructive injection.
[InlineData("' OR '1'='1")] // Boolean-based injection.
public async Task UpdateUserRoleAndPermissions_WithInjectionInPermissionsBody_ShouldNotLeakOrExecuteSql(string maliciousPermissionId)
{
// Arrange
// authenticate as an admin and seed the target user, so a well-formed body would reach the handler and be authorized
// Authenticate as an admin and seed the target user, so a well-formed body would reach the handler and be authorized.
HttpClient client = _apiFactory.CreateClient();
_adminUserId = await _apiFactory.CreateAndAuthenticateAdminUserAsync(client);
UserEntity targetUser = await SeedTargetUserAsync();
@@ -73,8 +73,8 @@ public class UpdatePlaybackStateEndpointTests : IClassFixture<LuminaApiFactory>,
}
[Theory]
[InlineData(double.MaxValue)] // far above the maximum
[InlineData(double.MinValue)] // far below the minimum
[InlineData(double.MaxValue)] // Far above the maximum.
[InlineData(double.MinValue)] // Far below the minimum.
public async Task UpdatePlaybackState_WhenVolumeIsAtADoubleExtreme_ShouldReturnValidationErrorWithoutLeakingInternals(double volume)
{
// Arrange
@@ -139,9 +139,9 @@ public class UpdatePlaybackStateEndpointTests : IClassFixture<LuminaApiFactory>,
}
[Theory(Skip = "Production bug: a JSON payload whose volume is a string makes the FastEndpoints binder throw a System.Text.Json.JsonException, which escapes because UpdatePlaybackStateEndpoint calls DontCatchExceptions(), so the API responds with 500 instead of 400 or 422. The body is the generic ProblemDetails and leaks no internals. The test stays skipped until the endpoint maps binding failures to a client error.")]
[InlineData("'; DROP TABLE UserSettings; --")] // SQL injection
[InlineData("$(rm -rf /)")] // command injection
[InlineData("../../etc/passwd")] // path traversal
[InlineData("'; DROP TABLE UserSettings; --")] // SQL injection.
[InlineData("$(rm -rf /)")] // Command injection.
[InlineData("../../etc/passwd")] // Path traversal.
public async Task UpdatePlaybackState_WhenAStringIsSentInTheVolumeField_ShouldReturnAClientErrorWithoutLeakingInternalDetails(string maliciousValue)
{
// Arrange
@@ -126,8 +126,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(int.MaxValue)] // far above the maximum
[InlineData(int.MinValue)] // far below the minimum
[InlineData(int.MaxValue)] // Far above the maximum.
[InlineData(int.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterSegmentCountIsAtAnIntExtreme_ShouldReturnValidationErrorWithoutCrashing(int vuMeterSegmentCount)
{
// Arrange
@@ -145,8 +145,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(int.MaxValue)] // far above the maximum
[InlineData(int.MinValue)] // far below the minimum
[InlineData(int.MaxValue)] // Far above the maximum.
[InlineData(int.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterSegmentGapIsAtAnIntExtreme_ShouldReturnValidationErrorWithoutCrashing(int vuMeterSegmentGap)
{
// Arrange
@@ -164,8 +164,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(double.MaxValue)] // far above the maximum
[InlineData(double.MinValue)] // far below the minimum
[InlineData(double.MaxValue)] // Far above the maximum.
[InlineData(double.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterMediumThresholdIsAtADoubleExtreme_ShouldReturnValidationErrorWithoutCrashing(double vuMeterMediumThreshold)
{
// Arrange
@@ -185,8 +185,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(double.MaxValue)] // far above the maximum
[InlineData(double.MinValue)] // far below the minimum
[InlineData(double.MaxValue)] // Far above the maximum.
[InlineData(double.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterHighThresholdIsAtADoubleExtreme_ShouldReturnValidationErrorWithoutCrashing(double vuMeterHighThreshold)
{
// Arrange
@@ -206,8 +206,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(int.MaxValue)] // far above the maximum
[InlineData(int.MinValue)] // far below the minimum
[InlineData(int.MaxValue)] // Far above the maximum.
[InlineData(int.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterPeakHoldDurationIsAtAnIntExtreme_ShouldReturnValidationErrorWithoutCrashing(int vuMeterPeakHoldDurationInMilliseconds)
{
// Arrange
@@ -226,8 +226,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(double.MaxValue)] // far above the maximum
[InlineData(double.MinValue)] // far below the minimum
[InlineData(double.MaxValue)] // Far above the maximum.
[InlineData(double.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterReleasePerSecondIsAtADoubleExtreme_ShouldReturnValidationErrorWithoutCrashing(double vuMeterReleasePerSecond)
{
// Arrange
@@ -245,8 +245,8 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory]
[InlineData(double.MaxValue)] // far above the maximum
[InlineData(double.MinValue)] // far below the minimum
[InlineData(double.MaxValue)] // Far above the maximum.
[InlineData(double.MinValue)] // Far below the minimum.
public async Task UpdateUserSettings_WhenVuMeterPeakReleasePerSecondIsAtADoubleExtreme_ShouldReturnValidationErrorWithoutCrashing(double vuMeterPeakReleasePerSecond)
{
// Arrange
@@ -281,9 +281,9 @@ public class UpdateUserSettingsEndpointTests : IClassFixture<LuminaApiFactory>
}
[Theory(Skip = "Production bug: a JSON payload whose VuMeterOrientation is not a valid enumeration value makes the FastEndpoints binder throw a System.Text.Json.JsonException, which escapes because UpdateUserSettingsEndpoint calls DontCatchExceptions(), so the API responds with 500 instead of 400 or 422. The body is the generic ProblemDetails and leaks no internals. The test stays skipped until the endpoint maps binding failures to a client error.")]
[InlineData("'; DROP TABLE UserSettings; --")] // SQL injection
[InlineData("$(rm -rf /)")] // command injection
[InlineData("{{7*7}}")] // template injection
[InlineData("'; DROP TABLE UserSettings; --")] // SQL injection.
[InlineData("$(rm -rf /)")] // Command injection.
[InlineData("{{7*7}}")] // Template injection.
public async Task UpdateUserSettings_WhenVuMeterOrientationIsAMaliciousString_ShouldReturnClientErrorWithoutLeakingInternals(string maliciousOrientation)
{
// Arrange