Files
qwenpaw/tests/integration/test_driver_mcp_stdio_flow.py
agent-radar 1a3a4ccde1
Creator App Tests / PR Spam Gate (push) Skipped
Frontend Tests / PR Spam Gate (push) Skipped
NPM Format (website & console) / PR Spam Gate (push) Skipped
Pre-commit Checks / PR Spam Gate (push) Skipped
QwenPaw Creator Plugin Release / check-version (push) Canceled after 0s
QwenPaw Creator Plugin Release / upload-oss (push) Canceled after 0s
Tests / PR Spam Gate (push) Skipped
CodeQL / CodeQL (python) (push) Canceled after 0s
CodeQL / CodeQL (typescript) (push) Canceled after 0s
Creator App Tests / Creator Backend Tests (push) Canceled after 0s
Creator App Tests / Creator UI Build & Tests (push) Canceled after 0s
E2E Smoke Tests / Playwright UI Smoke (push) Canceled after 0s
Frontend Tests / Detect console changes (push) Canceled after 0s
NPM Format (website & console) / website format check (push) Canceled after 0s
NPM Format (website & console) / console format check (push) Canceled after 0s
Pre-commit Checks / Pre-commit (push) Canceled after 0s
QwenPaw Data Plugin Release / check-version (push) Canceled after 0s
Tests / Detect code changes (push) Canceled after 0s
Frontend Tests / Vitest Unit Tests (push) Canceled after 0s
Frontend Tests / Frontend Summary (push) Canceled after 0s
QwenPaw Data Plugin Release / upload-oss (push) Canceled after 0s
Tests / Maintainer Approval (push) Canceled after 0s
Tests / Unit Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Unit Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - macos-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.13 - ubuntu-latest (push) Canceled after 0s
Tests / Contract Tests - py3.11 - windows-latest (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - macos-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - fallback (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.13 - ubuntu-latest - p2 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p0 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p1 (push) Canceled after 0s
Tests / Integrated Tests - py3.11 - windows-latest - p2 (push) Canceled after 0s
Tests / Coverage Report (push) Canceled after 0s
Tests / Test Summary (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:01:50 +08:00

78 lines
2.5 KiB
Python

# -*- coding: utf-8 -*-
from pathlib import Path
import pytest
from qwenpaw.drivers.capabilities import DriverInvocation
from qwenpaw.drivers.contracts import CredentialRef, DriverCard, PolicyRule
from qwenpaw.drivers.credentials.store import AsyncCredentialStore
from qwenpaw.drivers.credentials.types import CredentialRecord
from qwenpaw.drivers.handlers.mcp import MCPDriverHandler
from qwenpaw.drivers.manager import DriverManager
from qwenpaw.drivers.storage import card_path, dump_card
from tests.integration.driver_mcp_fakes import (
FakeStdIOClient,
patch_mcp_runtime_clients,
)
@pytest.mark.asyncio
@pytest.mark.integration
@pytest.mark.p1
async def test_driver_mcp_stdio_env_secret_flow(
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
patch_mcp_runtime_clients(monkeypatch)
store = AsyncCredentialStore(tmp_path / "credentials.yaml")
await store.put(
CredentialRecord(
ref="mcp/stdio_echo",
kind="static",
secrets={"ECHO_SECRET": "secret-value"},
),
)
dump_card(
DriverCard(
name="stdio_echo",
protocol="mcp",
endpoint={
"transport": "stdio",
"command": "python",
"args": ["tests/fixtures/mcp/stdio_echo_server.py"],
"env": {
"public": {"ECHO_PUBLIC_MODE": "test"},
"secret_refs": {"ECHO_SECRET": "ECHO_SECRET"},
},
},
credentials={
"default": CredentialRef("static", "mcp/stdio_echo"),
},
policy=[PolicyRule(subject="*", effect="allow")],
),
card_path(tmp_path / "drivers", "stdio_echo", protocol="mcp"),
)
manager = DriverManager(tmp_path / "drivers", store)
manager.register_handler_type("mcp", MCPDriverHandler)
await manager.build_drivers()
capability = next(
item
for item in await manager.list_capabilities(kind="tool")
if item.name == "get_secret_status"
)
result = await manager.invoke_capability(
DriverInvocation(
capability_id=capability.capability_id,
payload={},
request_context={"session_id": "s1", "user_id": "user:alice"},
),
)
assert result.ok is True
assert result.value == {"has_secret": True}
assert FakeStdIOClient.instances[0].kwargs["env"] == {
"ECHO_PUBLIC_MODE": "test",
"ECHO_SECRET": "secret-value",
}