add images support

This commit is contained in:
timka123 committed 2026-11-23 18:19:24 +03:00
1 parent 2b3518f873
commit d972f4b314
14 files changed
+2157 -51

No files matched your search

+37
View File
@@ -779,3 +779,40 @@ async def test_config_loading_yaml_and_env_json_and_stdio_restriction(tmp_path):
assert manager2.get_connector("imported") is not None
await manager.close()
await manager2.close()
@pytest.mark.asyncio
async def test_validate_cimd_url_catches_text_plain_and_mismatched_client_id(tmp_path):
async def handle_bad(request: web.Request) -> web.Response:
return web.Response(
text=json.dumps({"client_id": "https://other.example/x.json", "redirect_uris": []}),
content_type="text/plain",
)
async def handle_good(request: web.Request) -> web.Response:
url = str(request.url)
return web.json_response(
{
"client_id": url,
"client_name": "HomeAgent",
"redirect_uris": ["http://127.0.0.1:18765/mcp/oauth/callback"],
}
)
app = web.Application()
app.router.add_get("/bad.json", handle_bad)
app.router.add_get("/good.json", handle_good)
runner, base_url = await _start_aiohttp_app(app)
try:
store = OAuthTokenStore(tmp_path / "tok.json")
auth_mgr = MCPAuthManager(store)
bad_warnings = await auth_mgr.validate_cimd_url(f"{base_url}/bad.json")
assert any("application/json" in w for w in bad_warnings)
assert any("client_id" in w for w in bad_warnings)
assert any("redirect_uris" in w for w in bad_warnings)
good_warnings = await auth_mgr.validate_cimd_url(f"{base_url}/good.json")
assert good_warnings == []
finally:
await runner.cleanup()