TokenServiceTests¶
Namespace: UnitTests.Services
Unit tests for the TokenService class, verifying JWT token generation, validation, and refresh token functionality.
Inheritance Object → TokenServiceTests
Constructors¶
TokenServiceTests()¶
Methods¶
GenerateAccessToken_ShouldLogInformation()¶
Generates an access token and verifies that it logs the appropriate information.
GenerateAccessToken_WithEmptyClaims_ShouldReturnValidJwtToken()¶
Generates an access token with empty claims and verifies that it returns a valid JWT token.
GenerateAccessToken_WithValidClaims_ShouldReturnValidJwtToken()¶
Tests that GenerateAccessToken with valid claims returns a valid JWT token.
GenerateRefreshToken_ShouldLogInformation()¶
Generates a refresh token and verifies that it logs the appropriate information.
GenerateRefreshToken_ShouldReturnBase64String()¶
Generates a refresh token and verifies that it returns a valid base64 string.
GetPrincipalFromExpiredToken_WithEmptyToken_ShouldThrowArgumentException()¶
Gets the principal from an expired token with an empty string and verifies that it throws an ArgumentException.
GetPrincipalFromExpiredToken_WithInvalidToken_ShouldThrowArgumentException()¶
Gets the principal from an expired token with an invalid token string and verifies that it throws an ArgumentException.
GetPrincipalFromExpiredToken_WithNullToken_ShouldThrowArgumentException()¶
Gets the principal from an expired token with an empty token string and verifies that it throws an ArgumentException.
GetPrincipalFromExpiredToken_WithTokenSignedWithDifferentKey_ShouldThrowSecurityTokenException()¶
Gets the principal from an expired token signed with a different key and verifies that it throws a SecurityTokenException.
public void GetPrincipalFromExpiredToken_WithTokenSignedWithDifferentKey_ShouldThrowSecurityTokenException()
GetPrincipalFromExpiredToken_WithValidToken_ShouldReturnClaimsPrincipal()¶
Gets the principal from an expired token and verifies that it returns a ClaimsPrincipal with the expected claims.
Setup()¶
Sets up test fixtures and initializes mocks before each test execution.