Gitea에 동적 클라이언트 등록이 없어 MCP 클라이언트가 URL만으로 OAuth 연결을 못 하는 문제를 이 브리지가 인가 서버 역할을 대신해 해결한다. G3X의 plane-mcp-oauth-bridge(upstream_oauth 모드)에서 가져와 Gitea 전용으로 정리했다: Plane PAT 연결 페이지·워크스페이스 헤더·bridge_mode 분기를 없앴다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
os.environ.setdefault("TOKEN_ENCRYPTION_KEY", "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
|
|
os.environ.setdefault("PUBLIC_BASE_URL", "http://testserver")
|
|
os.environ.setdefault("OIDC_CLIENT_ID", "test-oidc-client")
|
|
os.environ.setdefault("OIDC_CLIENT_SECRET", "test-oidc-secret")
|
|
os.environ.setdefault("ALLOWED_MCP_CLIENTS", "cursor|http://localhost:8787/callback")
|
|
|
|
|
|
@pytest.fixture
|
|
def client(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("DATA_DIR", str(tmp_path))
|
|
from app.config import get_settings
|
|
|
|
get_settings.cache_clear()
|
|
import app.main as main
|
|
|
|
main._db = None
|
|
with TestClient(main.app) as test_client:
|
|
yield test_client
|
|
|
|
|
|
@pytest.fixture
|
|
def database(tmp_path, monkeypatch):
|
|
monkeypatch.setenv("DATA_DIR", str(tmp_path))
|
|
from app.config import get_settings
|
|
|
|
get_settings.cache_clear()
|
|
import app.main as main
|
|
|
|
main._db = None
|
|
return main.db()
|