23
23
24
24
25
25
class Server :
26
- """
27
- A proxy object that is returned by the pytest fixture.
28
- """
26
+ """A proxy object that is returned by the pytest fixture."""
29
27
30
28
#: The port on which the local http server listens
31
29
port : int
@@ -50,14 +48,12 @@ def logged_user():
50
48
51
49
@property
52
50
def url (self ) -> str :
53
- """
54
- The URL at which the IAM server is accessible.
55
- """
51
+ """The URL at which the IAM server is accessible."""
56
52
return f"http://localhost:{ self .port } /"
57
53
58
54
def random_user (self , ** kwargs ) -> User :
59
- """
60
- Generates a :class:`~canaille.core.models.User` with random values.
55
+ """Generates a :class:`~canaille.core.models.User` with random values.
56
+
61
57
Any parameter will be used instead of a random value.
62
58
"""
63
59
with self .app .app_context ():
@@ -68,8 +64,8 @@ def random_user(self, **kwargs) -> User:
68
64
return user
69
65
70
66
def random_group (self , ** kwargs ) -> Group :
71
- """
72
- Generates a :class:`~canaille.core.models.Group` with random values.
67
+ """Generates a :class:`~canaille.core.models.Group` with random values.
68
+
73
69
Any parameter will be used instead of a random value.
74
70
"""
75
71
with self .app .app_context ():
@@ -80,8 +76,9 @@ def random_group(self, **kwargs) -> Group:
80
76
return group
81
77
82
78
def random_token (self , subject , client , ** kwargs ) -> Token :
83
- """
84
- Generates a test :class:`~canaille.oidc.basemodels.Token` with random values.
79
+ """Generates a test :class:`~canaille.oidc.basemodels.Token` with
80
+ random values.
81
+
85
82
Any parameter will be used instead of a random value.
86
83
"""
87
84
with self .app .app_context ():
@@ -104,15 +101,14 @@ def random_token(self, subject, client, **kwargs) -> Token:
104
101
return token
105
102
106
103
def login (self , user ):
107
- """
108
- Opens a session for the user in the IAM session.
104
+ """Opens a session for the user in the IAM session.
105
+
109
106
This allows to skip the connection screen.
110
107
"""
111
108
self .logged_user = user
112
109
113
110
def consent (self , user , client = None ) -> Consent | List [Consent ]:
114
- """
115
- Make a user consent to share data with OIDC clients.
111
+ """Make a user consent to share data with OIDC clients.
116
112
117
113
:param client: If :const:`None`, all existing clients are consented.
118
114
"""
@@ -143,9 +139,8 @@ def consent(self, user, client=None) -> Consent | List[Consent]:
143
139
144
140
@pytest .fixture (scope = "session" )
145
141
def iam_configuration () -> Dict [str , Any ]:
146
- """
147
- Fixture for editing the configuration of :meth:`~pytest_iam.iam_server`.
148
- """
142
+ """Fixture for editing the configuration of
143
+ :meth:`~pytest_iam.iam_server`."""
149
144
150
145
private_key , public_key = generate_keypair ()
151
146
return {
@@ -170,9 +165,8 @@ def iam_configuration() -> Dict[str, Any]:
170
165
171
166
@pytest .fixture (scope = "session" )
172
167
def iam_server (iam_configuration ) -> Server :
173
- """
174
- Fixture that creates a Canaille server listening a random port in a thread.
175
- """
168
+ """Fixture that creates a Canaille server listening a random port in a
169
+ thread."""
176
170
177
171
port = portpicker .pick_unused_port ()
178
172
app = create_app (config = iam_configuration )
0 commit comments