fix: Windows cookie diagnostics (#28) and rich output pipe capture (#29)

- Add win32 branch in _diagnose_keychain_issues() with DPAPI/admin/shadowcopy hints
- Add _make_console() helper in formatter.py with force_terminal=False for Windows non-TTY
- Replace all 6 Console() defaults with _make_console()
- Add test for Windows-specific diagnostics
This commit is contained in:
jackwener
2026-03-16 14:27:53 +08:00
parent 07e7f83e6f
commit 74386cebc8
3 changed files with 44 additions and 6 deletions

View File

@@ -349,6 +349,22 @@ def test_diagnose_keychain_issues_ssh_hint(monkeypatch) -> None:
assert "security unlock-keychain" in hint
def test_diagnose_keychain_issues_windows_hint(monkeypatch) -> None:
"""On Windows, hint should mention DPAPI and environment variable workaround."""
monkeypatch.setattr("sys.platform", "win32")
monkeypatch.delenv("SSH_CLIENT", raising=False)
monkeypatch.delenv("SSH_TTY", raising=False)
monkeypatch.delenv("SSH_CONNECTION", raising=False)
diagnostics = ["chrome: Unable to get key for cookie decryption"]
hint = auth._diagnose_keychain_issues(diagnostics)
assert hint is not None
assert "DPAPI" in hint
assert "TWITTER_AUTH_TOKEN" in hint
assert "shadowcopy" in hint
def test_diagnose_keychain_issues_returns_none_for_unrelated_errors() -> None:
"""Should return None when diagnostics don't mention Keychain."""
diagnostics = ["chrome[Default]=no-cookies", "firefox: profile not found"]