A fully functional OAUTH2 / OpenID Connect (OIDC) / SCIM server to be used in your testsuite
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest_iam-0.2.3.tar.gz
.
File metadata
- Download URL: pytest_iam-0.2.3.tar.gz
- Upload date:
- Size: 74.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
ab199b6b26b0e5309fe0193165d1f0daf5f691d0ce4630db27c85c8f349996f5
|
|
MD5 |
77d96678136796ad883154636f1f43dd
|
|
BLAKE2b-256 |
98a35303e9a002ce02f1269c31a65090b9a00c35065a4298f7cfdb3afcc73746
|
Provenance
The following attestation bundles were made for pytest_iam-0.2.3.tar.gz
:
Publisher:
release.yml
on pytest-dev/pytest-iam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_iam-0.2.3.tar.gz
-
Subject digest:
ab199b6b26b0e5309fe0193165d1f0daf5f691d0ce4630db27c85c8f349996f5
- Sigstore transparency entry: 268752609
- Sigstore integration time:
-
Permalink:
pytest-dev/pytest-iam@e7a7a089741f6e800660a3d7bc80d366ac4c15b0
-
Branch / Tag:
refs/tags/0.2.3
- Owner: https://github.com/pytest-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@e7a7a089741f6e800660a3d7bc80d366ac4c15b0
-
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_iam-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: pytest_iam-0.2.3-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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
c4bed97de2e5857e4019d2ac6ef9516a8c69ccc04adf631bd15a0b8b767b65d4
|
|
MD5 |
53d3a2f03b46a35b2498ebc616c51407
|
|
BLAKE2b-256 |
e24968be66189f96ccf1400e83ca22c7c92f950a766bed5fa8de2a89d1399de2
|
Provenance
The following attestation bundles were made for pytest_iam-0.2.3-py3-none-any.whl
:
Publisher:
release.yml
on pytest-dev/pytest-iam
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
pytest_iam-0.2.3-py3-none-any.whl
-
Subject digest:
c4bed97de2e5857e4019d2ac6ef9516a8c69ccc04adf631bd15a0b8b767b65d4
- Sigstore transparency entry: 268752614
- Sigstore integration time:
-
Permalink:
pytest-dev/pytest-iam@e7a7a089741f6e800660a3d7bc80d366ac4c15b0
-
Branch / Tag:
refs/tags/0.2.3
- Owner: https://github.com/pytest-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
release.yml@e7a7a089741f6e800660a3d7bc80d366ac4c15b0
-
Trigger Event:
push
-
Statement type: