Skip to main content

pytest-iam

pytest-iam is a pytest plugin that starts an OAuth2, OpenID Connect (OIDC) and SCIM server for the tests of an application. The server is a Canaille instance, built on Authlib.

Why pytest-iam

A mock of the identity provider only gives the answers that the test expects. pytest-iam runs a real IAM server instead, so the tests go through the real OAuth2 and OIDC flows: redirections, forms, code exchange and token introspection. SCIM applications send their requests to a real SCIM API. The server runs in a thread of the test process. It needs no container, and it only listens on localhost.

Installation

uv add --dev pytest-iam

The SCIM API needs the scim extra:

uv add --dev "pytest-iam[scim]"

Usage

The iam_server fixture gives access to the IAM server:

  • its URL, to configure the tested application;
  • its SCIM API at /scim/v2, with the scim extra;
  • its models, such as users, groups, clients and tokens, to prepare the tests and check their effects;
  • shortcuts to log users in and record their consent;
  • helpers to create random users, groups and tokens.

The following test logs a user in on a client application. The client fixture registers the application on the IAM server, and the user fixture creates a user, as described in the test data guide. test_client is the test client of the application.

def test_login_shortcuts(iam_server, client, user, test_client):
    iam_server.login(user)
    iam_server.consent(user, client)

    # 1. the protected page redirects to the IAM server
    res = test_client.get("/protected")

    # 2. the IAM server redirects to the application with a code
    res = iam_server.test_client.get(res.location)

    # 3. the application exchanges the code for a token
    res = test_client.get(res.location)

    # 4. the protected page is now accessible
    res = test_client.get(res.location)
    assert res.text == "Hello, user!"

The documentation has guides for client applications, resource servers, signed authorization requests and SCIM applications.

License

pytest-iam is published under the MIT license.

Metadata

Release files for pytest-iam 0.4.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.4.0
File Size Uploaded Provenance Actions
pytest_iam-0.4.0.tar.gz 11.9 kB With provenance Details for pytest_iam-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.7 kB

Release files / pytest_iam-0.4.0.tar.gz

Download URL pytest_iam-0.4.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c29afc03883606d7f7f40a8c68916162ec254b88619ac73da2971b513d6455a1
BLAKE2b-256 checksum
How to use checksums
a289828ded454c9381e927c2c59ea07f105e9c7ee11d81d91c628b3f542bd72c
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 28, 2026.

Transparency log

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

Download URL pytest_iam-0.4.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbb821e55353c6e3cec10b509c9f9be05a212d4434b0c13c4e3fd8b741f108d2
BLAKE2b-256 checksum
How to use checksums
24db684c734c598922402dbbf7f27f5144657a2313205bd7ebcbc646eecd2cef
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 28, 2026.

Transparency log

Security for pytest-iam 0.4.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.4.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 28, 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