Skip to content

Commit 985e0dd

Browse files
committed
feat: add test for listing pools with revoked owner
1 parent 8f7e236 commit 985e0dd

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tests/test_enrollment.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Dict, Any
44
import logging
55
from pathlib import Path
6+
import uuid
67

78

89
import pytest
@@ -13,6 +14,12 @@
1314
from cryptography import x509
1415

1516
from rasenmaeher_api.rmsettings import RMSettings
17+
from rasenmaeher_api.db import (
18+
Person,
19+
EnrollmentPool,
20+
EngineWrapper,
21+
)
22+
1623

1724
LOGGER = logging.getLogger(__name__)
1825

@@ -672,3 +679,27 @@ async def test_enroll_with_csr( # pylint: disable=R0915, R0914
672679
LOGGER.debug("DN={} callsign={}".format(dn, callsign))
673680
assert f"CN={callsign}" in dn
674681
# TODO: check extensions
682+
683+
684+
@pytest.mark.asyncio(loop_scope="session")
685+
async def test_enrollmentpools_revoked_creator(ginosession: None, tilauspalvelu_jwt_admin_client: TestClient) -> None:
686+
"""Test that pools list does not die if creator is revoked"""
687+
_ = ginosession
688+
invitecode = str(uuid.uuid4())
689+
person = await Person.create_with_cert("toberevoked")
690+
with EngineWrapper.singleton().get_session() as session:
691+
pool = EnrollmentPool(owner=person.pk, invitecode=invitecode)
692+
session.add(pool)
693+
session.commit()
694+
session.refresh(pool)
695+
await person.revoke("key_compromise")
696+
resp = await tilauspalvelu_jwt_admin_client.get("/api/v1/enrollment/pools")
697+
resp.raise_for_status()
698+
resp_dict = resp.json()
699+
assert "pools" not in resp_dict
700+
found = False
701+
for pool in resp_dict["pools"]:
702+
if pool["invitecode"] == invitecode:
703+
found = True
704+
break
705+
assert found

0 commit comments

Comments
 (0)