<!-- CURSOR_SUMMARY --> > [!NOTE] > **Medium Risk** > Touches authentication/login flow, credentials-file permissions, and subprocess lifecycle behavior across platforms; while mostly defensive, regressions could impact login or process management on Windows/macOS runners. > > **Overview** > Improves Windows/cross-platform reliability across the CLI and MCP server: OAuth login now binds the callback server to `127.0.0.1`, avoids slow loopback reverse-DNS, adds a configurable callback timeout (`--timeout` + env default), and opens URLs via a Windows-friendly `_open_browser` to avoid flashing console windows. > > Centralizes CLI output via a shared `console` that forces UTF-8 on Windows, standardizes UTF-8 file reads/writes throughout, tightens credentials-file permissions on Windows using `icacls`, and adds shared Windows subprocess helpers for **no-window** process creation and graceful termination (used by `deploy`, MCP reload, and usage-tracking worker). > > Updates client configuration UX/robustness (Windows AppData resolution via `platformdirs`, Cursor config path fallbacks + compatibility writes, overwrite warnings, absolute `uv` path for GUI clients, safer path display) and improves `deploy` child-process handling to avoid pipe-buffer deadlocks while giving better debug-aware error messages. > > Expands CI to run tests on Linux/Windows/macOS, adds a no-auth CLI integration workflow, disables usage tracking in toolkits CI, and adds extensive regression tests for Windows signals, subprocess cleanup, UTF-8, and config-path edge cases; bumps `arcade-core` to `4.4.2` and `arcade-mcp-server` to `1.17.2` (with updated dependency pin). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 0fabd8ca1cd647039ba6ddbdf3f7809c330bab9e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
102 lines
3.4 KiB
Python
102 lines
3.4 KiB
Python
from __future__ import annotations
|
|
|
|
import asyncio
|
|
from datetime import datetime
|
|
from io import StringIO
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from arcade_cli.server import _display_deployment_logs, _stream_deployment_logs
|
|
from rich.console import Console
|
|
|
|
|
|
def test_display_deployment_logs_preserves_square_bracket_content() -> None:
|
|
buf = StringIO()
|
|
test_console = Console(file=buf, force_terminal=False)
|
|
|
|
mock_response = MagicMock()
|
|
mock_response.raise_for_status.return_value = None
|
|
mock_response.json.return_value = [
|
|
{"timestamp": "2026-01-15T15:30:00Z", "line": "[INFO] startup [ERROR] details"}
|
|
]
|
|
mock_client = MagicMock()
|
|
mock_client.get.return_value = mock_response
|
|
|
|
import arcade_cli.server as server_mod
|
|
|
|
original_console = server_mod.console
|
|
server_mod.console = test_console
|
|
try:
|
|
with (
|
|
patch("arcade_cli.server.httpx.Client") as mock_httpx_client,
|
|
patch("arcade_cli.server._format_timestamp_to_local", return_value="2026-01-15 10:30:00 EST"),
|
|
):
|
|
mock_httpx_client.return_value.__enter__.return_value = mock_client
|
|
_display_deployment_logs(
|
|
"http://localhost:8123/logs",
|
|
{},
|
|
datetime(2026, 1, 15, 15, 30, 0),
|
|
datetime(2026, 1, 15, 15, 35, 0),
|
|
debug=False,
|
|
)
|
|
finally:
|
|
server_mod.console = original_console
|
|
|
|
output = buf.getvalue()
|
|
assert "[2026-01-15 10:30:00 EST]" in output
|
|
assert "[INFO]" in output
|
|
assert "[ERROR]" in output
|
|
|
|
|
|
def test_stream_deployment_logs_preserves_square_bracket_content() -> None:
|
|
buf = StringIO()
|
|
test_console = Console(file=buf, force_terminal=False)
|
|
|
|
class FakeStreamResponse:
|
|
async def __aenter__(self) -> FakeStreamResponse:
|
|
return self
|
|
|
|
async def __aexit__(self, exc_type, exc, tb) -> None: # type: ignore[no-untyped-def]
|
|
return None
|
|
|
|
def raise_for_status(self) -> None:
|
|
return None
|
|
|
|
async def aiter_lines(self): # type: ignore[no-untyped-def]
|
|
yield 'data: {"Timestamp":"2026-01-15T15:30:00Z","Line":"[ERROR] stream details"}'
|
|
yield "[INFO] plain stream line"
|
|
|
|
class FakeAsyncClient:
|
|
async def __aenter__(self) -> FakeAsyncClient:
|
|
return self
|
|
|
|
async def __aexit__(self, exc_type, exc, tb) -> None: # type: ignore[no-untyped-def]
|
|
return None
|
|
|
|
def stream(self, *args, **kwargs) -> FakeStreamResponse: # type: ignore[no-untyped-def]
|
|
return FakeStreamResponse()
|
|
|
|
import arcade_cli.server as server_mod
|
|
|
|
original_console = server_mod.console
|
|
server_mod.console = test_console
|
|
try:
|
|
with (
|
|
patch("arcade_cli.server.httpx.AsyncClient", return_value=FakeAsyncClient()),
|
|
patch("arcade_cli.server._format_timestamp_to_local", return_value="2026-01-15 10:30:00 EST"),
|
|
):
|
|
asyncio.run(
|
|
_stream_deployment_logs(
|
|
"http://localhost:8123/logs/stream",
|
|
{},
|
|
datetime(2026, 1, 15, 15, 30, 0),
|
|
datetime(2026, 1, 15, 15, 35, 0),
|
|
debug=False,
|
|
)
|
|
)
|
|
finally:
|
|
server_mod.console = original_console
|
|
|
|
output = buf.getvalue()
|
|
assert "[2026-01-15 10:30:00 EST]" in output
|
|
assert "[ERROR]" in output
|
|
assert "[INFO] plain stream line" in output
|