feat(F.7b): tool access UI + unified keys page (v3.9.0)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -374,37 +374,15 @@ class TestDashboardCookieManagement:
|
||||
|
||||
|
||||
def test_dashboard_connect_page(monkeypatch):
|
||||
"""Test that the /dashboard/connect page renders successfully without 500 errors."""
|
||||
"""Test that /dashboard/connect redirects to /dashboard/keys (F.7b session 2)."""
|
||||
from server import create_multi_endpoint_app
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
import core.dashboard.routes
|
||||
import core.site_api
|
||||
import core.user_keys
|
||||
|
||||
app = create_multi_endpoint_app()
|
||||
client = TestClient(app)
|
||||
|
||||
def mock_req(*args):
|
||||
return {"user_id": "abc", "type": "user"}, None
|
||||
|
||||
monkeypatch.setattr(core.dashboard.routes, "_require_user_session", mock_req)
|
||||
|
||||
async def mock_sites(*args):
|
||||
return [{"alias": "Test", "plugin_type": "dummy"}]
|
||||
|
||||
monkeypatch.setattr(core.site_api, "get_user_sites", mock_sites)
|
||||
|
||||
class MockKeyMgr:
|
||||
async def list_keys(self, *a):
|
||||
return [
|
||||
{"id": "1", "name": "Key", "key_prefix": "prefix", "scopes": "all", "use_count": 0}
|
||||
]
|
||||
|
||||
monkeypatch.setattr(core.user_keys, "get_user_key_manager", lambda: MockKeyMgr())
|
||||
client = TestClient(app, follow_redirects=False)
|
||||
|
||||
resp = client.get("/dashboard/connect")
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert "Test" in resp.text
|
||||
assert "Key" in resp.text
|
||||
# /dashboard/connect now redirects 301 to /dashboard/keys
|
||||
assert resp.status_code == 301
|
||||
assert "/dashboard/keys" in resp.headers["location"]
|
||||
|
||||
Reference in New Issue
Block a user