Reference#
This page lists the fixtures and the classes of pytest-iam.
Fixtures#
- pytest_iam.iam_server() pytest_iam.Server[source]#
Session fixture that starts the IAM server in a thread, and returns a
Server.
- pytest_iam.iam_configuration() dict[source]#
Session fixture that returns the settings of the IAM server.
Redefine it to change the settings, as described in Configuration.
- pytest_iam.iam_server_port() int[source]#
Session fixture that returns the port of the IAM server.
By default, it is a free port. Redefine it to use a fixed port.
- pytest_iam.iam_restore_login()[source]#
Autouse fixture that logs out the users logged in during each test.
It undoes the
login()calls, and the logins through the forms oftest_client.
Server#
- class pytest_iam.Server[source]#
The IAM server, returned by the
iam_server()fixture.- consent(user: User, client: Client | None = None) Consent | list[Consent] | None[source]#
Record the consent of a user for a client.
With a
Noneclient, the user consents to all the existing clients. Return the consent, the list of consents when several clients exist, orNonewhen no client exists.
- login(user: User) None[source]#
Log a user in on the IAM server, without the login form.
The user is logged out at the end of the test, or when the user logs out on the IAM server. A login made by a module or session scoped fixture lasts until
logout().
- mount(url: str, app: Callable[[dict[str, Any], StartResponse], Iterable[bytes]]) None[source]#
Serve the requests that the IAM server sends to a URL with a WSGI application.
The URL is a scheme, a host and an optional port, such as
http://client.test. The application is unmounted at the end of the test. A mount made by a module or session scoped fixture lasts untilunmount().
- random_group(**kwargs: Any) Group[source]#
Create and save a
Groupwith random values.Keyword arguments set some of the values. Without
members, the only member is a new random user.
- random_token(subject: User | None, client: Client, **kwargs: Any) Token[source]#
Create and save an access
Tokenfor a client.With a
Nonesubject, the token belongs to the client only. The token has the scopes of the client, and lasts 3600 seconds. Keyword arguments set some of the values.
- random_user(**kwargs: Any) User[source]#
Create and save a
Userwith random values.Keyword arguments set some of the values.
- backend: Backend#
The Canaille backend, to save, get and delete models.
- models: ModuleType#
The module of the Canaille models, such as
models.User.
Models#
Server.models gives access to the Canaille models,
documented in Data models: