Enforce tenant policy on public scheduling links
This commit is contained in:
@@ -29,6 +29,7 @@ class SchedulingManifestTests(unittest.TestCase):
|
||||
self.assertIn("addresses.people_search", manifest.optional_capabilities)
|
||||
self.assertIn("evaluation", manifest.optional_dependencies)
|
||||
self.assertIsNotNone(manifest.route_factory)
|
||||
self.assertIsNotNone(manifest.public_tenant_resolver)
|
||||
self.assertIsNotNone(manifest.migration_spec)
|
||||
self.assertIsNotNone(manifest.frontend)
|
||||
self.assertEqual(
|
||||
|
||||
@@ -33,7 +33,12 @@ from govoplan_scheduling.backend.db.models import (
|
||||
SchedulingParticipant,
|
||||
SchedulingRequest,
|
||||
)
|
||||
from govoplan_scheduling.backend.manifest import ADMIN_SCOPE, RESPOND_SCOPE, WRITE_SCOPE
|
||||
from govoplan_scheduling.backend.manifest import (
|
||||
ADMIN_SCOPE,
|
||||
RESPOND_SCOPE,
|
||||
WRITE_SCOPE,
|
||||
get_manifest as get_scheduling_manifest,
|
||||
)
|
||||
from govoplan_scheduling.backend.router import (
|
||||
api_get_my_scheduling_availability,
|
||||
api_submit_scheduling_availability,
|
||||
@@ -78,6 +83,7 @@ class SchedulingResponseEditingTests(unittest.TestCase):
|
||||
registry.register(get_poll_manifest())
|
||||
registry.configure_capability_context(ModuleContext(registry=registry, settings=object()))
|
||||
configure_runtime(registry=registry)
|
||||
self.registry = registry
|
||||
self.engine = create_engine("sqlite:///:memory:")
|
||||
Base.metadata.create_all(
|
||||
self.engine,
|
||||
@@ -512,6 +518,26 @@ class SchedulingResponseEditingTests(unittest.TestCase):
|
||||
)
|
||||
self.assertEqual(tokens, {})
|
||||
token = self._issue_copy(public_request, public_request.participants[0])
|
||||
resolver = get_scheduling_manifest().public_tenant_resolver
|
||||
self.assertIsNotNone(resolver)
|
||||
public_http_request = SimpleNamespace(
|
||||
app=SimpleNamespace(
|
||||
state=SimpleNamespace(govoplan_registry=self.registry)
|
||||
),
|
||||
path_params={
|
||||
"request_id": public_request.id,
|
||||
"token": token,
|
||||
},
|
||||
url=SimpleNamespace(
|
||||
path=(
|
||||
f"/api/v1/scheduling/public/{public_request.id}/{token}"
|
||||
)
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
"tenant-1",
|
||||
resolver(public_http_request, self.session),
|
||||
)
|
||||
invitation = self.session.query(PollInvitation).filter(
|
||||
PollInvitation.id == public_request.participants[0].poll_invitation_id
|
||||
).one()
|
||||
|
||||
Reference in New Issue
Block a user