Skip to content

[P3] Add unit tests for JwtStrategy.validate() #1154

Description

@cyber-punk112

Description

src/auth/jwt.strategy.ts defines JwtStrategy.validate(payload), which returns { sub: payload.sub, publicKey: payload.publicKey ?? payload.sub } — falling back to sub when publicKey is missing from the token payload. There is no jwt.strategy.spec.ts file anywhere in the repo, so this fallback logic (which several other tests rely on implicitly when signing test JWTs with only sub) has no dedicated unit test.

Deliverables

  • Create src/auth/jwt.strategy.spec.ts
  • Test validate() with a payload containing both sub and publicKey
  • Test validate() with a payload containing only sub, asserting publicKey falls back to it
  • npm run build passes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    MediumauthAuthentication and authorizationbackendNestJS server workgood first issueGood for newcomersphase-2Phase 2 beginner-friendly backlog: cleanup, tests, docs, polish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions