mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
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:
1 parent
727aa33318
commit
057f557791
540 files changed
+3888
-3888
No files matched your search
+4
-4
@@ -59,17 +59,17 @@ public class JwtTokenGeneratorTests
|
||||
|
||||
JwtSecurityToken jwtToken = tokenHandler.ReadJwtToken(token);
|
||||
|
||||
// verify token properties
|
||||
// Verify token properties.
|
||||
Assert.Equal(_jwtSettings.Issuer, jwtToken.Issuer);
|
||||
Assert.Single(jwtToken.Audiences, _jwtSettings.Audience);
|
||||
Assert.Equal(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes), jwtToken.ValidTo);
|
||||
|
||||
// verify claims
|
||||
// Verify claims.
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.Sub && c.Value == userId);
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.UniqueName && c.Value == username);
|
||||
Assert.Contains(jwtToken.Claims, c => c.Type == JwtRegisteredClaimNames.Jti && c.Value == userId);
|
||||
|
||||
// verify the token is actually valid
|
||||
// Verify the token is actually valid.
|
||||
TokenValidationParameters validationParameters = new()
|
||||
{
|
||||
ValidateIssuerSigningKey = true,
|
||||
@@ -80,7 +80,7 @@ public class JwtTokenGeneratorTests
|
||||
ValidAudience = _jwtSettings.Audience,
|
||||
ValidateLifetime = true,
|
||||
ClockSkew = TimeSpan.Zero,
|
||||
// override the current time to match our fixed test time
|
||||
// Override the current time to match our fixed test time.
|
||||
LifetimeValidator = (notBefore, expires, token, parameters) => expires > _fixedUtcNow
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class QRCodeGeneratorTests
|
||||
|
||||
// Assert
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..])); // skip "data:image/png;base64,"
|
||||
Assert.True(IsBase64String(result[22..])); // Skip "data:image/png;base64,".
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -112,7 +112,7 @@ public class QRCodeGeneratorTests
|
||||
{
|
||||
// Arrange
|
||||
(string username, _) = QRCodeGeneratorFixture.CreateQrCodeTestData();
|
||||
byte[] shortSecret = [1]; // minimum length for Base32 encoding
|
||||
byte[] shortSecret = [1]; // Minimum length for Base32 encoding.
|
||||
|
||||
// Act
|
||||
string result = _sut.GenerateQrCodeDataUri(username, shortSecret);
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class TokenGeneratorTests
|
||||
string token = _sut.GenerateToken();
|
||||
|
||||
// Assert
|
||||
// 32 bytes in Base64 without padding should be 43 characters
|
||||
// 32 bytes in Base64 without padding should be 43 characters.
|
||||
Assert.Equal(43, token.Length);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -56,10 +56,10 @@ public class TotpTokenGeneratorTests
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
[InlineData("123456")] // Valid format but wrong token
|
||||
[InlineData("abcdef")] // Invalid format
|
||||
[InlineData("12345")] // Too short
|
||||
[InlineData("1234567")] // Too long
|
||||
[InlineData("123456")] // Valid format but wrong token.
|
||||
[InlineData("abcdef")] // Invalid format.
|
||||
[InlineData("12345")] // Too short.
|
||||
[InlineData("1234567")] // Too long.
|
||||
public void ValidateToken_WhenTokenIsInvalid_ShouldReturnFalse(string invalidToken)
|
||||
{
|
||||
// Arrange
|
||||
@@ -95,6 +95,6 @@ public class TotpTokenGeneratorTests
|
||||
byte[] secret = _sut.GenerateSecret();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(20, secret.Length); // standard TOTP secret length
|
||||
Assert.Equal(20, secret.Length); // Standard TOTP secret length.
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user