diracx-db 0.0.1a42__tar.gz → 0.0.1a44__tar.gz
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_db-0.0.1a42 → diracx_db-0.0.1a44}/PKG-INFO +2 -1
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/pyproject.toml +1 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/os/job_parameters.py +2 -1
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/auth/db.py +2 -4
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/auth/schema.py +0 -1
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/dummy/db.py +1 -2
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/PKG-INFO +2 -1
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/requires.txt +1 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/auth/test_refresh_token.py +10 -21
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/opensearch/test_search.py +3 -1
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/test_dummy_db.py +6 -6
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/README.md +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/setup.cfg +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/__main__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/exceptions.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/os/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/os/utils.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/py.typed +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/auth/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/dummy/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/dummy/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job/db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job_logging/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job_logging/db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/job_logging/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/pilot_agents/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/pilot_agents/db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/pilot_agents/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/sandbox_metadata/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/sandbox_metadata/db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/sandbox_metadata/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/task_queue/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/task_queue/db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/task_queue/schema.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/utils/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/utils/base.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/utils/functions.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx/db/sql/utils/types.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/SOURCES.txt +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/dependency_links.txt +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/entry_points.txt +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/src/diracx_db.egg-info/top_level.txt +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/auth/test_authorization_flow.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/auth/test_device_flow.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/jobs/test_job_db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/jobs/test_job_logging_db.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/jobs/test_sandbox_metadata.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/opensearch/test_connection.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/opensearch/test_index_template.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/pilot_agents/__init__.py +0 -0
- {diracx_db-0.0.1a42 → diracx_db-0.0.1a44}/tests/pilot_agents/test_pilot_agents_db.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: diracx-db
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.1a44
|
4
4
|
Summary: TODO
|
5
5
|
License: GPL-3.0-only
|
6
6
|
Classifier: Intended Audience :: Science/Research
|
@@ -14,5 +14,6 @@ Requires-Dist: diracx-core
|
|
14
14
|
Requires-Dist: opensearch-py[async]
|
15
15
|
Requires-Dist: pydantic>=2.10
|
16
16
|
Requires-Dist: sqlalchemy[aiomysql,aiosqlite]>=2
|
17
|
+
Requires-Dist: uuid-utils
|
17
18
|
Provides-Extra: testing
|
18
19
|
Requires-Dist: diracx-testing; extra == "testing"
|
@@ -25,7 +25,8 @@ class JobParametersDB(BaseOSDB):
|
|
25
25
|
|
26
26
|
def index_name(self, vo, doc_id: int) -> str:
|
27
27
|
split = int(int(doc_id) // 1e6)
|
28
|
-
|
28
|
+
# The index name must be lowercase or opensearchpy will throw.
|
29
|
+
return f"{self.index_prefix}_{vo.lower()}_{split}m"
|
29
30
|
|
30
31
|
def upsert(self, vo, doc_id, document):
|
31
32
|
document = {
|
@@ -1,10 +1,10 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import secrets
|
4
|
-
from uuid import UUID, uuid4
|
5
4
|
|
6
5
|
from sqlalchemy import insert, select, update
|
7
6
|
from sqlalchemy.exc import IntegrityError, NoResultFound
|
7
|
+
from uuid_utils import UUID, uuid7
|
8
8
|
|
9
9
|
from diracx.core.exceptions import (
|
10
10
|
AuthorizationError,
|
@@ -126,7 +126,7 @@ class AuthDB(BaseSQLDB):
|
|
126
126
|
code_challenge_method: str,
|
127
127
|
redirect_uri: str,
|
128
128
|
) -> str:
|
129
|
-
uuid = str(
|
129
|
+
uuid = str(uuid7())
|
130
130
|
|
131
131
|
stmt = insert(AuthorizationFlows).values(
|
132
132
|
uuid=uuid,
|
@@ -199,7 +199,6 @@ class AuthDB(BaseSQLDB):
|
|
199
199
|
self,
|
200
200
|
jti: UUID,
|
201
201
|
subject: str,
|
202
|
-
preferred_username: str,
|
203
202
|
scope: str,
|
204
203
|
) -> None:
|
205
204
|
"""Insert a refresh token in the DB as well as user attributes
|
@@ -209,7 +208,6 @@ class AuthDB(BaseSQLDB):
|
|
209
208
|
stmt = insert(RefreshTokens).values(
|
210
209
|
jti=str(jti),
|
211
210
|
sub=subject,
|
212
|
-
preferred_username=preferred_username,
|
213
211
|
scope=scope,
|
214
212
|
)
|
215
213
|
await self.conn.execute(stmt)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: diracx-db
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.1a44
|
4
4
|
Summary: TODO
|
5
5
|
License: GPL-3.0-only
|
6
6
|
Classifier: Intended Audience :: Science/Research
|
@@ -14,5 +14,6 @@ Requires-Dist: diracx-core
|
|
14
14
|
Requires-Dist: opensearch-py[async]
|
15
15
|
Requires-Dist: pydantic>=2.10
|
16
16
|
Requires-Dist: sqlalchemy[aiomysql,aiosqlite]>=2
|
17
|
+
Requires-Dist: uuid-utils
|
17
18
|
Provides-Extra: testing
|
18
19
|
Requires-Dist: diracx-testing; extra == "testing"
|
@@ -1,8 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
-
from uuid import UUID, uuid4
|
4
|
-
|
5
3
|
import pytest
|
4
|
+
from uuid_utils import UUID, uuid7
|
6
5
|
|
7
6
|
from diracx.db.sql.auth.db import AuthDB
|
8
7
|
from diracx.db.sql.auth.schema import RefreshTokenStatus
|
@@ -20,22 +19,20 @@ async def auth_db(tmp_path):
|
|
20
19
|
async def test_insert(auth_db: AuthDB):
|
21
20
|
"""Insert two refresh tokens in the DB and check that they don't share the same JWT ID."""
|
22
21
|
# Insert a first refresh token
|
23
|
-
jti1 =
|
22
|
+
jti1 = uuid7()
|
24
23
|
async with auth_db as auth_db:
|
25
24
|
await auth_db.insert_refresh_token(
|
26
25
|
jti1,
|
27
26
|
"subject",
|
28
|
-
"username",
|
29
27
|
"vo:lhcb property:NormalUser",
|
30
28
|
)
|
31
29
|
|
32
30
|
# Insert a second refresh token
|
33
|
-
jti2 =
|
31
|
+
jti2 = uuid7()
|
34
32
|
async with auth_db as auth_db:
|
35
33
|
await auth_db.insert_refresh_token(
|
36
34
|
jti2,
|
37
35
|
"subject",
|
38
|
-
"username",
|
39
36
|
"vo:lhcb property:NormalUser",
|
40
37
|
)
|
41
38
|
|
@@ -48,17 +45,15 @@ async def test_get(auth_db: AuthDB):
|
|
48
45
|
# Refresh token details we want to insert
|
49
46
|
refresh_token_details = {
|
50
47
|
"sub": "12345",
|
51
|
-
"preferred_username": "John Doe",
|
52
48
|
"scope": "vo:lhcb property:NormalUser",
|
53
49
|
}
|
54
50
|
|
55
51
|
# Insert refresh token details
|
56
|
-
jti =
|
52
|
+
jti = uuid7()
|
57
53
|
async with auth_db as auth_db:
|
58
54
|
await auth_db.insert_refresh_token(
|
59
55
|
jti,
|
60
56
|
refresh_token_details["sub"],
|
61
|
-
refresh_token_details["preferred_username"],
|
62
57
|
refresh_token_details["scope"],
|
63
58
|
)
|
64
59
|
creation_time = (await auth_db.get_refresh_token(jti))["CreationTime"]
|
@@ -66,7 +61,6 @@ async def test_get(auth_db: AuthDB):
|
|
66
61
|
# Enrich the dict with the generated refresh token attributes
|
67
62
|
expected_refresh_token = {
|
68
63
|
"Sub": refresh_token_details["sub"],
|
69
|
-
"PreferredUsername": refresh_token_details["preferred_username"],
|
70
64
|
"Scope": refresh_token_details["scope"],
|
71
65
|
"JTI": jti,
|
72
66
|
"Status": RefreshTokenStatus.CREATED,
|
@@ -78,7 +72,7 @@ async def test_get(auth_db: AuthDB):
|
|
78
72
|
result = await auth_db.get_refresh_token(jti)
|
79
73
|
|
80
74
|
# Make sure they are identical
|
81
|
-
result["JTI"] = UUID(result["JTI"]
|
75
|
+
result["JTI"] = UUID(result["JTI"])
|
82
76
|
assert result == expected_refresh_token
|
83
77
|
|
84
78
|
|
@@ -97,9 +91,8 @@ async def test_get_user_refresh_tokens(auth_db: AuthDB):
|
|
97
91
|
async with auth_db as auth_db:
|
98
92
|
for sub in subjects:
|
99
93
|
await auth_db.insert_refresh_token(
|
100
|
-
|
94
|
+
uuid7(),
|
101
95
|
sub,
|
102
|
-
"username",
|
103
96
|
"scope",
|
104
97
|
)
|
105
98
|
|
@@ -123,11 +116,10 @@ async def test_revoke(auth_db: AuthDB):
|
|
123
116
|
"""Insert a refresh token in the DB, revoke it, and make sure it appears as REVOKED in the db."""
|
124
117
|
# Insert a refresh token details
|
125
118
|
async with auth_db as auth_db:
|
126
|
-
jti =
|
119
|
+
jti = uuid7()
|
127
120
|
await auth_db.insert_refresh_token(
|
128
121
|
jti,
|
129
122
|
"subject",
|
130
|
-
"username",
|
131
123
|
"scope",
|
132
124
|
)
|
133
125
|
|
@@ -155,9 +147,8 @@ async def test_revoke_user_refresh_tokens(auth_db: AuthDB):
|
|
155
147
|
async with auth_db as auth_db:
|
156
148
|
for sub in subjects:
|
157
149
|
await auth_db.insert_refresh_token(
|
158
|
-
|
150
|
+
uuid7(),
|
159
151
|
sub,
|
160
|
-
"username",
|
161
152
|
"scope",
|
162
153
|
)
|
163
154
|
|
@@ -198,11 +189,10 @@ async def test_revoke_and_get_user_refresh_tokens(auth_db: AuthDB):
|
|
198
189
|
jtis = []
|
199
190
|
async with auth_db as auth_db:
|
200
191
|
for _ in range(nb_tokens):
|
201
|
-
jti =
|
192
|
+
jti = uuid7()
|
202
193
|
await auth_db.insert_refresh_token(
|
203
194
|
jti,
|
204
195
|
sub,
|
205
|
-
"username",
|
206
196
|
"scope",
|
207
197
|
)
|
208
198
|
jtis.append(jti)
|
@@ -248,9 +238,8 @@ async def test_get_refresh_tokens(auth_db: AuthDB):
|
|
248
238
|
async with auth_db as auth_db:
|
249
239
|
for sub in subjects:
|
250
240
|
await auth_db.insert_refresh_token(
|
251
|
-
|
241
|
+
uuid7(),
|
252
242
|
sub,
|
253
|
-
"username",
|
254
243
|
"scope",
|
255
244
|
)
|
256
245
|
|
@@ -105,7 +105,9 @@ async def prefilled_db(request):
|
|
105
105
|
impl = request.param
|
106
106
|
async with resolve_fixtures_hack(request, impl) as dummy_opensearch_db:
|
107
107
|
await dummy_opensearch_db.upsert("dummyvo", 798811211, DOC1)
|
108
|
-
|
108
|
+
# the following line tests if the index name is made properly lowercase in case
|
109
|
+
# the VO has capital letters e.g. "diracAdmin"
|
110
|
+
await dummy_opensearch_db.upsert("dummyVO", 998811211, DOC2)
|
109
111
|
await dummy_opensearch_db.upsert("dummyvo", 798811212, DOC3)
|
110
112
|
|
111
113
|
# Force a refresh to make sure the documents are available
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import asyncio
|
4
|
-
from uuid import uuid4
|
5
4
|
|
6
5
|
import pytest
|
6
|
+
from uuid_utils import uuid7
|
7
7
|
|
8
8
|
from diracx.core.exceptions import InvalidQueryError
|
9
9
|
from diracx.db.sql.dummy.db import DummyDB
|
@@ -38,7 +38,7 @@ async def test_insert_and_summary(dummy_db: DummyDB):
|
|
38
38
|
|
39
39
|
# Add cars, belonging to the same guy
|
40
40
|
result = await asyncio.gather(
|
41
|
-
*(dummy_db.insert_car(
|
41
|
+
*(dummy_db.insert_car(uuid7(), f"model_{i}", owner_id) for i in range(10))
|
42
42
|
)
|
43
43
|
assert result
|
44
44
|
|
@@ -100,7 +100,7 @@ async def test_successful_transaction(dummy_db):
|
|
100
100
|
owner_id = await dummy_db.insert_owner(name="Magnum")
|
101
101
|
assert owner_id
|
102
102
|
result = await asyncio.gather(
|
103
|
-
*(dummy_db.insert_car(
|
103
|
+
*(dummy_db.insert_car(uuid7(), f"model_{i}", owner_id) for i in range(10))
|
104
104
|
)
|
105
105
|
assert result
|
106
106
|
|
@@ -142,7 +142,7 @@ async def test_failed_transaction(dummy_db):
|
|
142
142
|
assert owner_id
|
143
143
|
result = await asyncio.gather(
|
144
144
|
*(
|
145
|
-
dummy_db.insert_car(
|
145
|
+
dummy_db.insert_car(uuid7(), f"model_{i}", owner_id)
|
146
146
|
for i in range(10)
|
147
147
|
)
|
148
148
|
)
|
@@ -211,7 +211,7 @@ async def test_successful_with_exception_transaction(dummy_db):
|
|
211
211
|
assert owner_id
|
212
212
|
result = await asyncio.gather(
|
213
213
|
*(
|
214
|
-
dummy_db.insert_car(
|
214
|
+
dummy_db.insert_car(uuid7(), f"model_{i}", owner_id)
|
215
215
|
for i in range(10)
|
216
216
|
)
|
217
217
|
)
|
@@ -248,7 +248,7 @@ async def test_successful_with_exception_transaction(dummy_db):
|
|
248
248
|
assert owner_id
|
249
249
|
result = await asyncio.gather(
|
250
250
|
*(
|
251
|
-
dummy_db.insert_car(
|
251
|
+
dummy_db.insert_car(uuid7(), f"model_{i}", owner_id)
|
252
252
|
for i in range(10)
|
253
253
|
)
|
254
254
|
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|