Skip to main content

jwt_test.go

jwt_test.go - Overview

This file contains unit tests for the JWT (JSON Web Token) functionalities defined in the authtypes package. It tests token generation, claim retrieval, and bearer token parsing.

Detailed Documentation

TestGetAccessJwt

  • Purpose: Tests the generation of an access JWT.
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestGetRefreshJwt

  • Purpose: Tests the generation of a refresh JWT.
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestGetJwtClaims

  • Purpose: Tests retrieving claims from a valid JWT.
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestGetJwtClaimsInvalidToken

  • Purpose: Tests retrieving claims from an invalid JWT (malformed token).
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestGetJwtClaimsExpiredToken

  • Purpose: Tests retrieving claims from an expired JWT.
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestGetJwtClaimsInvalidSignature

  • Purpose: Tests retrieving claims from a JWT with an invalid signature (tampered token).
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

TestParseBearerAuth

  • Purpose: Tests the parseBearerAuth function, which extracts the token from a "Bearer" authentication header.
  • Parameters:
    • t (*testing.T): Testing object for running the test.
  • Returns: None

Code Examples

None

Clarity and Accuracy

The documentation is based on the code provided.

Include in Getting Started: NO