diff --git a/src/crud/webhook.py b/src/crud/webhook.py index 1dcc29a8..65b05569 100644 --- a/src/crud/webhook.py +++ b/src/crud/webhook.py @@ -63,7 +63,7 @@ async def get_or_create_webhook_endpoint( async def list_webhook_endpoints( - db: AsyncSession, workspace_name: str + workspace_name: str, ) -> Select[tuple[models.WebhookEndpoint]]: """ List all webhook endpoints, optionally filtered by workspace. @@ -75,9 +75,6 @@ async def list_webhook_endpoints( Returns: List of webhook endpoints """ - # Verify workspace exists - await get_workspace(db, workspace_name) - return select(models.WebhookEndpoint).where( models.WebhookEndpoint.workspace_name == workspace_name ) diff --git a/src/routers/webhooks.py b/src/routers/webhooks.py index c6ae2017..aa3256c1 100644 --- a/src/routers/webhooks.py +++ b/src/routers/webhooks.py @@ -61,7 +61,7 @@ async def list_webhook_endpoints( if not jwt_params.ad and jwt_params.w is not None and jwt_params.w != workspace_id: raise AuthenticationException("Unauthorized access to resource") - stmt = await crud.list_webhook_endpoints(db, workspace_id) + stmt = await crud.list_webhook_endpoints(workspace_id) return await apaginate(db, stmt) diff --git a/src/webhooks/webhook_delivery.py b/src/webhooks/webhook_delivery.py index d9587009..316fdccc 100644 --- a/src/webhooks/webhook_delivery.py +++ b/src/webhooks/webhook_delivery.py @@ -82,7 +82,7 @@ async def _get_webhook_urls(db: AsyncSession, workspace_name: str) -> list[str]: Get all webhook endpoint URLs for a workspace. """ try: - endpoints = await list_webhook_endpoints(db, workspace_name) + endpoints = await list_webhook_endpoints(workspace_name) result = await db.execute(endpoints) return [endpoint.url for endpoint in result.scalars().all()] except Exception: diff --git a/tests/routes/test_webhooks.py b/tests/routes/test_webhooks.py index ed176473..8272dc9f 100644 --- a/tests/routes/test_webhooks.py +++ b/tests/routes/test_webhooks.py @@ -95,13 +95,6 @@ async def test_list_webhook_endpoints_with_data( assert "http://example2.com/webhook" in endpoint_urls -@pytest.mark.asyncio -async def test_list_webhook_endpoints_missing_workspace(client: TestClient): - response = client.get("/v2/workspaces/nonexistent-workspace/webhooks") - assert response.status_code == 404 - assert response.json() == {"detail": "Workspace nonexistent-workspace not found"} - - @pytest.mark.asyncio async def test_delete_webhook_endpoint( client: TestClient, sample_data: tuple[Workspace, Peer]