Skip to content

feat(testing): add pytest plugin and test issuer #630

Closed

Description

@uniqueg

Problem

Apps copy the same test setup: a network guard, a MongoDB switch and a mock identity provider. They test authentication with verify_audience: false, hand-made tokens or mocked validation, so their tests don't exercise audience, typ, groups or service clients as production does. There is also no documented local identity provider for development.

Proposal

  • Pytest plugin with a network guard and a MongoDB fixture, which apps enable by name.
  • foca.testing.issuer: a pytest fixture and context manager that serves OIDC discovery and JWKS on a local port (stdlib http.server; cryptography and PyJWT are already dependencies).
    • issuer.token(sub=..., aud=..., typ="at+jwt", groups=[...], client_id=...) returns a signed access token.
    • Optional user-info responses.
    • It doesn't depend on a test client, so it works with Flask's now and with foca.testing.Client from 0.22.0, unchanged at 1.0.0-rc1.
  • Docs: a testing page, plus a Compose snippet with a standard mock OIDC server pinned by digest for local development. FOCA ships no identity provider image.
  • FOCA's own auth tests that mock token validation move to the issuer where that makes them simpler.

Acceptance criteria

  • foca.testing.issuer is public, typed, documented and tested (discovery, JWKS, audience, typ, groups, user info).
  • An example test validates a token end to end, without verify_audience: false.
  • 100% coverage.

Activity

  1. added this to the v0.21.0 milestone on Nov 3, 2026
  2. added
    priority: medium
    status: triage
    type: testing
    workload: days
    status: in progress
    on Nov 3, 2026
  3. removed
    status: in progress
    on Nov 4, 2026
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

    priority: mediumstatus: triagetype: testingworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions