Fixed JwtAuthorizationAttribute + tests

This commit is contained in:
2025-03-15 17:31:13 +01:00
parent 962de4df9e
commit bd175da738
6 changed files with 208 additions and 53 deletions

View File

@@ -27,14 +27,14 @@ public class JwtService_Tests
try
{
var jwtService = TestUtils.CreateJwtService();
if(jwtService != null)
if (jwtService != null)
{
Assert.IsInstanceOfType(jwtService, typeof(JwtService));
}
else
{
Assert.Fail($"JwtService is null");
}
}
}
catch (Exception ex)
{
@@ -50,7 +50,7 @@ public class JwtService_Tests
{
var jwtService = TestUtils.CreateJwtService();
var testString = "test";
if(jwtService != null)
if (jwtService != null)
{
var jwt = jwtService.GenerateToken(testString);
Assert.IsTrue(jwt != null);
@@ -68,31 +68,6 @@ public class JwtService_Tests
}
}
[TestMethod]
public void ValidateToken_Null()
{
try
{
var jwtService = TestUtils.CreateJwtService();
var testString = "test";
if(jwtService != null)
{
var jwt = jwtService.GenerateToken(testString);
var user = jwtService.ValidateToken($"Bearer {jwt}");
Assert.IsTrue(user == null);
}
else
{
Assert.Fail($"JwtService is null");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Assert.Fail($"An exception was thrown: {ex.Message}");
}
}
}