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 --group dev

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_iam-0.2.1.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_iam-0.2.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file pytest_iam-0.2.1.tar.gz.

File metadata

  • Download URL: pytest_iam-0.2.1.tar.gz
  • Upload date:
  • Size: 73.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_iam-0.2.1.tar.gz
Algorithm Hash digest
SHA256 be8adb40398178ee1096c4a7cdfe5f5f69b1ce6d018feee4617fd73d9a6b62c2
MD5 5a19072703ecb6e2760fccc6d00bcd7f
BLAKE2b-256 053c07374bb47c4931509d1a4b1f5e9165008ac18ef1dc82325f994f90fffe81

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_iam-0.2.1.tar.gz:

Publisher: release.yml on pytest-dev/pytest-iam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_iam-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_iam-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_iam-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bfd246ef40171d435989c01d6c25f31253e2fffacb1f784b248aed651bc944a6
MD5 4993885b6932d382ebb397ae40cbb131
BLAKE2b-256 aec665fd14969e2a2cb0380773cf9eb2ae13807ba6ba2c05a94256ca8f6b890f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_iam-0.2.1-py3-none-any.whl:

Publisher: release.yml on pytest-dev/pytest-iam

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 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