|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +from pathlib import Path |
| 6 | +from unittest.mock import AsyncMock, patch |
| 7 | + |
5 | 8 | import pytest |
6 | 9 |
|
| 10 | +from tests.support.app import octop_client, write_octop_config |
| 11 | +from tests.support.auth import auth_header, bootstrap_admin |
7 | 12 | from tests.support.http import ws_chat_turn |
8 | 13 |
|
9 | 14 |
|
@@ -165,6 +170,26 @@ async def test_auth_info(env): |
165 | 170 | assert data["auth_hint"] |
166 | 171 |
|
167 | 172 |
|
| 173 | +async def test_oauth_start_public_http_notion_error_is_actionable(tmp_octop_home: Path): |
| 174 | + write_octop_config(tmp_octop_home) |
| 175 | + async with octop_client(tmp_octop_home) as (c, _srv): |
| 176 | + await bootstrap_admin(c, tmp_octop_home) |
| 177 | + auth = await auth_header(c) |
| 178 | + mocked_start = AsyncMock() |
| 179 | + with patch("octop.api.routers.connectors.start_oauth", mocked_start): |
| 180 | + r = await c.post( |
| 181 | + "/api/connectors/oauth/notion/start", |
| 182 | + headers={**auth, "host": "58.87.70.170"}, |
| 183 | + json={"redirect_after": "/connectors"}, |
| 184 | + ) |
| 185 | + assert r.status_code == 400 |
| 186 | + body = r.json() |
| 187 | + assert body["error"]["code"] == "CONNECTOR_OAUTH_HTTPS_REQUIRED" |
| 188 | + assert "Notion" in body["error"]["message"] |
| 189 | + assert "HTTPS" in body["error"]["message"] |
| 190 | + mocked_start.assert_not_awaited() |
| 191 | + |
| 192 | + |
168 | 193 | async def test_patch_instance_status(env): |
169 | 194 | c, _, auth, _ = env |
170 | 195 | r = await c.post( |
|
0 commit comments