|
|
|
@@ -7,7 +7,6 @@ import logging
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from aegis_gitea_mcp.config import reset_settings
|
|
|
|
|
from aegis_gitea_mcp.logging_utils import (
|
|
|
|
|
JsonLogFormatter,
|
|
|
|
|
log_event,
|
|
|
|
@@ -19,16 +18,6 @@ from aegis_gitea_mcp.tools.read_tools import get_issue_tool
|
|
|
|
|
READ_TOOLS_LOGGER = "aegis_gitea_mcp.tools.read_tools"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
|
def tool_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
|
|
"""Provide minimal settings environment for response limit helpers."""
|
|
|
|
|
reset_settings()
|
|
|
|
|
monkeypatch.setenv("GITEA_URL", "https://gitea.example.com")
|
|
|
|
|
monkeypatch.setenv("GITEA_TOKEN", "test-token")
|
|
|
|
|
monkeypatch.setenv("MCP_API_KEYS", "a" * 64)
|
|
|
|
|
monkeypatch.setenv("ENVIRONMENT", "test")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_sanitize_context_masks_sensitive_keys() -> None:
|
|
|
|
|
"""Sensitive keys are masked case-insensitively; others pass through."""
|
|
|
|
|
cleaned = sanitize_context(
|
|
|
|
@@ -111,7 +100,9 @@ async def test_get_issue_tool_emits_debug_events(caplog: pytest.LogCaptureFixtur
|
|
|
|
|
assert "get_issue.start" in events
|
|
|
|
|
assert "get_issue.payload_shape" in events
|
|
|
|
|
|
|
|
|
|
field_checks = [r.context for r in caplog.records if r.getMessage() == "get_issue.field_check"]
|
|
|
|
|
field_checks = [
|
|
|
|
|
r.context for r in caplog.records if r.getMessage() == "get_issue.field_check"
|
|
|
|
|
]
|
|
|
|
|
assert {"field": "labels", "is_none": True, "value_type": None} in field_checks
|
|
|
|
|
assert {"field": "user", "is_none": True, "value_type": None} in field_checks
|
|
|
|
|
|
|
|
|
|