Skip to content

Engineer Unit Test Coverage for Cron Route Authentication Middleware #1087

Description

@temma02

Description

apps/backend/src/lib/api/cron-auth.ts has no co-located test file, despite gating every /api/cron/* route from unauthenticated invocation. Its shared-secret comparison logic is currently unverified by automated tests, which is a meaningful gap for an authentication boundary.

Requirements and Context

  • Cover the valid-secret-header success path.
  • Cover the missing-header and wrong-secret rejection paths, asserting the correct HTTP status.
  • If the implementation uses a timing-safe comparison, assert it does (equal-length wrong secrets should still be rejected).

Suggested Execution

Branch: test/cron-auth-middleware-coverage

Implement Changes

  • Create apps/backend/src/lib/api/cron-auth.test.ts.
  • Cover the valid, missing, and incorrect secret cases described above using a mocked NextRequest.

Test and Commit

Run npm run test --workspace=@craft/backend -- cron-auth and confirm the new suite passes.

Example Commit Message

test(backend): add unit coverage for cron route authentication middleware

Co-authored-by: <your-name>

Guidelines

  • Branch off main, keep PRs focused on one issue
  • All new code must include unit or integration tests
  • Ensure npm run lint and the relevant npm run test workspace pass before review
  • Link this issue in your PR description
  • Request review from at least one maintainer before merging

Activity

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related issuessecuritySecurity related issuestestingTesting related issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions