mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 16:11:10 +00:00
Removes FluentAssertions library from test projects, due to licensing changes
This commit is contained in:
1 parent
c1100e5398
commit
d46bfae4fc
235 files changed
+4468
-4725
No files matched your search
+13
-13
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.Infrastructure.Common.Models.Configuration;
|
||||
using Lumina.Infrastructure.Core.Authentication;
|
||||
@@ -55,19 +54,20 @@ public class JwtTokenGeneratorTests
|
||||
string token = _sut.GenerateToken(userId, username);
|
||||
|
||||
// Assert
|
||||
token.Should().NotBeNullOrEmpty();
|
||||
Assert.NotNull(token);
|
||||
Assert.NotEmpty(token);
|
||||
|
||||
JwtSecurityToken jwtToken = tokenHandler.ReadJwtToken(token);
|
||||
|
||||
// verify token properties
|
||||
jwtToken.Issuer.Should().Be(_jwtSettings.Issuer);
|
||||
jwtToken.Audiences.Should().ContainSingle().Which.Should().Be(_jwtSettings.Audience);
|
||||
jwtToken.ValidTo.Should().Be(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes));
|
||||
Assert.Equal(_jwtSettings.Issuer, jwtToken.Issuer);
|
||||
Assert.Single(jwtToken.Audiences, _jwtSettings.Audience);
|
||||
Assert.Equal(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes), jwtToken.ValidTo);
|
||||
|
||||
// verify claims
|
||||
jwtToken.Claims.Should().Contain(c => c.Type == JwtRegisteredClaimNames.Sub && c.Value == userId);
|
||||
jwtToken.Claims.Should().Contain(c => c.Type == JwtRegisteredClaimNames.UniqueName && c.Value == username);
|
||||
jwtToken.Claims.Should().Contain(c => c.Type == JwtRegisteredClaimNames.Jti && c.Value == userId);
|
||||
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
|
||||
TokenValidationParameters validationParameters = new()
|
||||
@@ -86,8 +86,8 @@ public class JwtTokenGeneratorTests
|
||||
|
||||
ClaimsPrincipal principal = tokenHandler.ValidateToken(token, validationParameters, out SecurityToken validatedToken);
|
||||
|
||||
principal.Should().NotBeNull();
|
||||
validatedToken.Should().NotBeNull();
|
||||
Assert.NotNull(principal);
|
||||
Assert.NotNull(validatedToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -102,7 +102,7 @@ public class JwtTokenGeneratorTests
|
||||
JwtSecurityToken jwtToken = tokenHandler.ReadJwtToken(token);
|
||||
|
||||
// Assert
|
||||
jwtToken.ValidTo.Should().Be(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes));
|
||||
Assert.Equal(_fixedUtcNow.AddMinutes(_jwtSettings.ExpiryMinutes), jwtToken.ValidTo);
|
||||
_ = _mockDateTimeProvider.Received(1).UtcNow;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class JwtTokenGeneratorTests
|
||||
string token2 = _sut.GenerateToken(userId2, username2);
|
||||
|
||||
// Assert
|
||||
token1.Should().NotBe(token2);
|
||||
Assert.NotEqual(token1, token2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -132,6 +132,6 @@ public class JwtTokenGeneratorTests
|
||||
string token2 = _sut.GenerateToken(userId, username);
|
||||
|
||||
// Assert
|
||||
token1.Should().Be(token2);
|
||||
Assert.Equal(token1, token2);
|
||||
}
|
||||
}
|
||||
+12
-13
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoNSubstitute;
|
||||
using FluentAssertions;
|
||||
using Lumina.Infrastructure.Common.Errors;
|
||||
using Lumina.Infrastructure.Common.Models.Configuration;
|
||||
using Lumina.Infrastructure.Common.Validators;
|
||||
@@ -39,8 +38,8 @@ public class QRCodeGeneratorTests
|
||||
string result = _sut.GenerateQrCodeDataUri(username, secret);
|
||||
|
||||
// Assert
|
||||
result.Should().StartWith("data:image/png;base64,");
|
||||
result.Should().Match(uri => IsBase64String(uri.Substring(22))); // Skip "data:image/png;base64,"
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..])); // skip "data:image/png;base64,"
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -54,8 +53,8 @@ public class QRCodeGeneratorTests
|
||||
string result = _sut.GenerateQrCodeDataUri(username, secret);
|
||||
|
||||
// Assert
|
||||
result.Should().StartWith("data:image/png;base64,");
|
||||
result.Should().Match(uri => IsBase64String(uri.Substring(22)));
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -70,7 +69,7 @@ public class QRCodeGeneratorTests
|
||||
string result2 = _sut.GenerateQrCodeDataUri(username2, secret);
|
||||
|
||||
// Assert
|
||||
result1.Should().NotBe(result2);
|
||||
Assert.NotEqual(result1, result2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -84,7 +83,7 @@ public class QRCodeGeneratorTests
|
||||
string result2 = _sut.GenerateQrCodeDataUri(username, secret);
|
||||
|
||||
// Assert
|
||||
result1.Should().Be(result2);
|
||||
Assert.Equal(result1, result2);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -99,8 +98,8 @@ public class QRCodeGeneratorTests
|
||||
string result = _sut.GenerateQrCodeDataUri(invalidUsername!, secret);
|
||||
|
||||
// Assert
|
||||
result.Should().StartWith("data:image/png;base64,");
|
||||
result.Should().Match(uri => IsBase64String(uri.Substring(22)));
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..]));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -117,8 +116,8 @@ public class QRCodeGeneratorTests
|
||||
string result = _sut.GenerateQrCodeDataUri(username, secret);
|
||||
|
||||
// Assert
|
||||
result.Should().StartWith("data:image/png;base64,");
|
||||
result.Should().Match(uri => IsBase64String(uri.Substring(22)));
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..]));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -132,8 +131,8 @@ public class QRCodeGeneratorTests
|
||||
string result = _sut.GenerateQrCodeDataUri(username, shortSecret);
|
||||
|
||||
// Assert
|
||||
result.Should().StartWith("data:image/png;base64,");
|
||||
result.Should().Match(uri => IsBase64String(uri.Substring(22)));
|
||||
Assert.StartsWith("data:image/png;base64,", result);
|
||||
Assert.True(IsBase64String(result[22..]));
|
||||
}
|
||||
|
||||
private static bool IsBase64String(string base64)
|
||||
|
||||
+9
-9
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Infrastructure.Core.Authentication;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -29,7 +28,8 @@ public class TokenGeneratorTests
|
||||
string token = _sut.GenerateToken();
|
||||
|
||||
// Assert
|
||||
token.Should().NotBeNullOrEmpty();
|
||||
Assert.NotNull(token);
|
||||
Assert.NotEmpty(token);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -39,9 +39,9 @@ public class TokenGeneratorTests
|
||||
string token = _sut.GenerateToken();
|
||||
|
||||
// Assert
|
||||
token.Should().NotContain("+", "Token should not contain '+'");
|
||||
token.Should().NotContain("/", "Token should not contain '/'");
|
||||
token.Should().NotContain("=", "Token should not contain '='");
|
||||
Assert.DoesNotContain("+", token);
|
||||
Assert.DoesNotContain("/", token);
|
||||
Assert.DoesNotContain("=", token);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -53,9 +53,9 @@ public class TokenGeneratorTests
|
||||
string token3 = _sut.GenerateToken();
|
||||
|
||||
// Assert
|
||||
token1.Should().NotBe(token2);
|
||||
token1.Should().NotBe(token3);
|
||||
token2.Should().NotBe(token3);
|
||||
Assert.NotEqual(token1, token2);
|
||||
Assert.NotEqual(token1, token3);
|
||||
Assert.NotEqual(token2, token3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -66,6 +66,6 @@ public class TokenGeneratorTests
|
||||
|
||||
// Assert
|
||||
// 32 bytes in Base64 without padding should be 43 characters
|
||||
token.Length.Should().Be(43);
|
||||
Assert.Equal(43, token.Length);
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FluentAssertions;
|
||||
using Lumina.Infrastructure.Core.Authentication;
|
||||
using OtpNet;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
@@ -30,7 +29,7 @@ public class TotpTokenGeneratorTests
|
||||
byte[] secret = _sut.GenerateSecret();
|
||||
|
||||
// Assert
|
||||
secret.Should().NotBeEmpty();
|
||||
Assert.NotEmpty(secret);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -42,9 +41,9 @@ public class TotpTokenGeneratorTests
|
||||
byte[] secret3 = _sut.GenerateSecret();
|
||||
|
||||
// Assert
|
||||
secret1.Should().NotBeEquivalentTo(secret2);
|
||||
secret1.Should().NotBeEquivalentTo(secret3);
|
||||
secret2.Should().NotBeEquivalentTo(secret3);
|
||||
Assert.NotEqual(secret1, secret2);
|
||||
Assert.NotEqual(secret1, secret3);
|
||||
Assert.NotEqual(secret2, secret3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -59,7 +58,7 @@ public class TotpTokenGeneratorTests
|
||||
bool result = _sut.ValidateToken(secret, validToken);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -78,7 +77,7 @@ public class TotpTokenGeneratorTests
|
||||
bool result = _sut.ValidateToken(secret, invalidToken);
|
||||
|
||||
// Assert
|
||||
result.Should().BeFalse();
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -94,7 +93,7 @@ public class TotpTokenGeneratorTests
|
||||
bool result = _sut.ValidateToken(secret2, token);
|
||||
|
||||
// Assert
|
||||
result.Should().BeFalse();
|
||||
Assert.False(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -104,6 +103,6 @@ public class TotpTokenGeneratorTests
|
||||
byte[] secret = _sut.GenerateSecret();
|
||||
|
||||
// Assert
|
||||
secret.Length.Should().Be(20); // Standard TOTP secret length
|
||||
Assert.Equal(20, secret.Length); // standard TOTP secret length
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user