diracx-testing 0.0.1a15__py3-none-any.whl → 0.0.1a16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- diracx/testing/__init__.py +36 -5
- {diracx_testing-0.0.1a15.dist-info → diracx_testing-0.0.1a16.dist-info}/METADATA +1 -1
- diracx_testing-0.0.1a16.dist-info/RECORD +6 -0
- diracx_testing-0.0.1a15.dist-info/RECORD +0 -6
- {diracx_testing-0.0.1a15.dist-info → diracx_testing-0.0.1a16.dist-info}/WHEEL +0 -0
- {diracx_testing-0.0.1a15.dist-info → diracx_testing-0.0.1a16.dist-info}/top_level.txt +0 -0
diracx/testing/__init__.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
# TODO: this needs a lot of documentation, in particular what will matter for users
|
4
|
+
# are the enabled_dependencies markers
|
3
5
|
import asyncio
|
4
6
|
import contextlib
|
5
7
|
import os
|
@@ -16,8 +18,9 @@ import pytest
|
|
16
18
|
import requests
|
17
19
|
|
18
20
|
if TYPE_CHECKING:
|
19
|
-
from diracx.routers.auth.utils import AuthSettings
|
20
21
|
from diracx.routers.job_manager.sandboxes import SandboxStoreSettings
|
22
|
+
from diracx.routers.utils.users import AuthorizedUserInfo, AuthSettings
|
23
|
+
|
21
24
|
|
22
25
|
# to get a string like this run:
|
23
26
|
# openssl rand -hex 32
|
@@ -77,7 +80,7 @@ def fernet_key() -> str:
|
|
77
80
|
|
78
81
|
@pytest.fixture(scope="session")
|
79
82
|
def test_auth_settings(rsa_private_key_pem, fernet_key) -> AuthSettings:
|
80
|
-
from diracx.routers.
|
83
|
+
from diracx.routers.utils.users import AuthSettings
|
81
84
|
|
82
85
|
yield AuthSettings(
|
83
86
|
token_key=rsa_private_key_pem,
|
@@ -132,6 +135,7 @@ class UnavailableDependency:
|
|
132
135
|
|
133
136
|
|
134
137
|
class ClientFactory:
|
138
|
+
|
135
139
|
def __init__(
|
136
140
|
self,
|
137
141
|
tmp_path_factory,
|
@@ -144,6 +148,21 @@ class ClientFactory:
|
|
144
148
|
from diracx.core.settings import ServiceSettingsBase
|
145
149
|
from diracx.db.sql.utils import BaseSQLDB
|
146
150
|
from diracx.routers import create_app_inner
|
151
|
+
from diracx.routers.access_policies import BaseAccessPolicy
|
152
|
+
|
153
|
+
class AlwaysAllowAccessPolicy(BaseAccessPolicy):
|
154
|
+
"""
|
155
|
+
Dummy access policy
|
156
|
+
"""
|
157
|
+
|
158
|
+
async def policy(
|
159
|
+
policy_name: str, user_info: AuthorizedUserInfo, /, **kwargs
|
160
|
+
):
|
161
|
+
pass
|
162
|
+
|
163
|
+
def enrich_tokens(access_payload: dict, refresh_payload: dict):
|
164
|
+
|
165
|
+
return {"PolicySpecific": "OpenAccessForTest"}, {}
|
147
166
|
|
148
167
|
enabled_systems = {
|
149
168
|
e.name for e in select_from_extension(group="diracx.services")
|
@@ -156,6 +175,12 @@ class ClientFactory:
|
|
156
175
|
|
157
176
|
self.test_auth_settings = test_auth_settings
|
158
177
|
|
178
|
+
all_access_policies = {
|
179
|
+
e.name: [AlwaysAllowAccessPolicy]
|
180
|
+
+ BaseAccessPolicy.available_implementations(e.name)
|
181
|
+
for e in select_from_extension(group="diracx.access_policies")
|
182
|
+
}
|
183
|
+
|
159
184
|
self.app = create_app_inner(
|
160
185
|
enabled_systems=enabled_systems,
|
161
186
|
all_service_settings=[
|
@@ -169,13 +194,15 @@ class ClientFactory:
|
|
169
194
|
config_source=ConfigSource.create_from_url(
|
170
195
|
backend_url=f"git+file://{with_config_repo}"
|
171
196
|
),
|
197
|
+
all_access_policies=all_access_policies,
|
172
198
|
)
|
173
199
|
|
174
200
|
self.all_dependency_overrides = self.app.dependency_overrides.copy()
|
175
201
|
self.app.dependency_overrides = {}
|
176
202
|
for obj in self.all_dependency_overrides:
|
177
203
|
assert issubclass(
|
178
|
-
obj.__self__,
|
204
|
+
obj.__self__,
|
205
|
+
(ServiceSettingsBase, BaseSQLDB, ConfigSource, BaseAccessPolicy),
|
179
206
|
), obj
|
180
207
|
|
181
208
|
self.all_lifetime_functions = self.app.lifetime_functions[:]
|
@@ -190,9 +217,10 @@ class ClientFactory:
|
|
190
217
|
assert (
|
191
218
|
self.app.dependency_overrides == {} and self.app.lifetime_functions == []
|
192
219
|
), "configure cannot be nested"
|
193
|
-
|
194
220
|
for k, v in self.all_dependency_overrides.items():
|
221
|
+
|
195
222
|
class_name = k.__self__.__name__
|
223
|
+
|
196
224
|
if class_name in enabled_dependencies:
|
197
225
|
self.app.dependency_overrides[k] = v
|
198
226
|
else:
|
@@ -317,7 +345,10 @@ class ClientFactory:
|
|
317
345
|
|
318
346
|
@pytest.fixture(scope="session")
|
319
347
|
def session_client_factory(
|
320
|
-
test_auth_settings,
|
348
|
+
test_auth_settings,
|
349
|
+
test_sandbox_settings,
|
350
|
+
with_config_repo,
|
351
|
+
tmp_path_factory,
|
321
352
|
):
|
322
353
|
"""
|
323
354
|
TODO
|
@@ -0,0 +1,6 @@
|
|
1
|
+
diracx/testing/__init__.py,sha256=xsBwJ8Ta1KH7bEBlWNhHK1u2U3KurwbrKcVCMoJXV6E,20129
|
2
|
+
diracx/testing/osdb.py,sha256=-EFZNyEY07Zq7HdQGZxS3H808Y94aaUhmo0x-Y8xo3Q,3592
|
3
|
+
diracx_testing-0.0.1a16.dist-info/METADATA,sha256=Vxwr5eBOFz6liF95u8rVpoNABAv-fR11nxL2YKxB7QM,615
|
4
|
+
diracx_testing-0.0.1a16.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
+
diracx_testing-0.0.1a16.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
|
6
|
+
diracx_testing-0.0.1a16.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
diracx/testing/__init__.py,sha256=1g2BhfkyZAmI9Gbbkmgdm_zHSGbA8AAaBn_u8Ojrvws,19172
|
2
|
-
diracx/testing/osdb.py,sha256=-EFZNyEY07Zq7HdQGZxS3H808Y94aaUhmo0x-Y8xo3Q,3592
|
3
|
-
diracx_testing-0.0.1a15.dist-info/METADATA,sha256=yVeF8wdqv3BjjIQBJdg-PMSJPMGbDfR5e3Wq0AtW0ks,615
|
4
|
-
diracx_testing-0.0.1a15.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
-
diracx_testing-0.0.1a15.dist-info/top_level.txt,sha256=vJx10tdRlBX3rF2Psgk5jlwVGZNcL3m_7iQWwgPXt-U,7
|
6
|
-
diracx_testing-0.0.1a15.dist-info/RECORD,,
|
File without changes
|
File without changes
|