Skip to content

Commit d4ef27e

Browse files
Improve SBAccessPolicy test
1 parent 716359b commit d4ef27e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

diracx-routers/tests/jobs/test_wms_access_policy.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ async def test_sandbox_access_policy_create(sandbox_metadata_db):
265265
##############
266266

267267

268-
async def test_sandbox_access_policy_read(sandbox_metadata_db):
268+
async def test_sandbox_access_policy_read(sandbox_metadata_db, monkeypatch):
269269

270270
admin_user = AuthorizedUserInfo(properties=[JOB_ADMINISTRATOR], **base_payload)
271271
normal_user = AuthorizedUserInfo(properties=[NORMAL_USER], **base_payload)
@@ -299,6 +299,17 @@ async def test_sandbox_access_policy_read(sandbox_metadata_db):
299299
)
300300

301301
# User can act on his own sandbox
302+
async def get_owner_id(*args):
303+
return 1
304+
305+
async def get_sandbox_owner_id(*args):
306+
return 1
307+
308+
monkeypatch.setattr(sandbox_metadata_db, "get_owner_id", get_owner_id)
309+
monkeypatch.setattr(
310+
sandbox_metadata_db, "get_sandbox_owner_id", get_sandbox_owner_id
311+
)
312+
302313
await SandboxAccessPolicy.policy(
303314
SANDBOX_POLICY_NAME,
304315
normal_user,
@@ -309,6 +320,11 @@ async def test_sandbox_access_policy_read(sandbox_metadata_db):
309320
)
310321

311322
# User cannot act on others
323+
async def get_owner_id(*args):
324+
return 2
325+
326+
monkeypatch.setattr(sandbox_metadata_db, "get_owner_id", get_owner_id)
327+
312328
with pytest.raises(HTTPException):
313329
await SandboxAccessPolicy.policy(
314330
SANDBOX_POLICY_NAME,

0 commit comments

Comments
 (0)