Skip to main content

pytest-iam

pytest-iam spawns a lightweight OAuth2 / OpenID Server (OIDC) / SCIM in a thread to be used in your test suite. The machinery involves Canaille and Authlib.

Installation

uv add pytest-iam

Usage

pytest-iam provides tools to test your application authentication mechanism against a OAuth2/OIDC server, with SCIM support:

  • It launches a Canaille instance on a random port;
  • It provides a iam_server fixture that comes with several features:
    • the URL of the IAM server to configure your application
    • IAM models (Users, groups, clients, tokens etc.) to prepare your tests and check the side effects. More details on the reference
    • utilities to log-in users and give their consent to your application
    • utilities to generate random users and groups

To run a full authentication process for a client application in your test, you can write something like this:

def test_authentication(iam_server, test_client):
    # create a random user on the IAM server
    user = iam_server.random_user()

    # log the user in and make it consent all the clients
    iam_server.login(user)
    iam_server.consent(user)

    # 1. attempt to access a protected page, returns a redirection to the IAM
    res = test_client.get("/protected")

    # 2. authorization code request
    res = iam_server.test_client.get(res.location)

    # 3. load your application authorization endpoint
    res = test_client.get(res.location)

    # 4. now you have access to the protected page
    res = test_client.get("/protected")

    assert "Hello, world!" in res.text

Check the client application or resource server tutorials for more usecases.

Metadata

Release files for pytest-iam 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-iam 0.3.0
File Size Uploaded Provenance Actions
pytest_iam-0.3.0.tar.gz 10.0 kB With provenance Details for pytest_iam-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-iam 0.3.0
File Interpreter ABI Platform Actions
pytest_iam-0.3.0-py3-none-any.whl Python 3 none any Details for pytest_iam-0.3.0-py3-none-any.whl

Total release size: 16.6 kB

Release files / pytest_iam-0.3.0.tar.gz

Download URL pytest_iam-0.3.0.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c45c8cf7f521a1e6a8daf6c14a6d80beecfa0fd2d593574e144aa0362aabb7b4
BLAKE2b-256 checksum
How to use checksums
d3097a73c9479fb5b098cd6501aa6b5b8defa9972b6463a7f02f728358948586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / pytest_iam-0.3.0-py3-none-any.whl

Download URL pytest_iam-0.3.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41f47a1050db2a222fa6d0b83cfa29db649080c51cf6ee7d7e5ac8d5d07fcb94
BLAKE2b-256 checksum
How to use checksums
305b67bdb6c6dd8ee1a28049015c0db1eb1db76b19c4010ccb0850dcfb0d4811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for pytest-iam 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_iam-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page