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.2.6

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.2.6
File Size Uploaded
pytest_iam-0.2.6.tar.gz 106.4 kB Details

Built distribution (wheel)

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

Total release size: 112.1 kB

Release files / pytest_iam-0.2.6.tar.gz

Download URL pytest_iam-0.2.6.tar.gz
Size 106.4 kB
Tags Source
SHA-256 checksum
How to use checksums
676134e317b1c4fd9b5bf4da70984b413dd214dab9875e2423572ba9d26e3cb2
BLAKE2b-256 checksum
How to use checksums
8b51bff13cdd7ecda34076aad27a17f331c72095076490d083c9bd55a742d03e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 20, 2026.

Transparency log

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

Download URL pytest_iam-0.2.6-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a378789ae57339bd187d8782f0f2e196e7c9044e406bafd9aaf941c15506171
BLAKE2b-256 checksum
How to use checksums
4a3b5120b8cb85426dc7d3a26545e5b1809a957b0110701aca06be39fe5cffec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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