From 8cf372f48609dc475f58b54fda68e8a70d22748a Mon Sep 17 00:00:00 2001 From: Sagnik Ghosh Date: Sun, 25 Oct 2026 17:18:09 +0530 Subject: [PATCH] Pin the credentials file in integration tests on Windows The upload_hold connect tests write fake credentials under the test home, but the binary resolved its credentials file with dirs::home_dir(), which on Windows uses Known Folders and ignores the HOME/USERPROFILE overrides. The binary saw the developer's real login state (or none), and `autter onboard --connect` started a real device login against app.autter.dev, hanging for ~15 minutes before failing. Honor AUTTER_TEST_CREDENTIALS_PATH in test-support builds, the same way the metrics and notes databases are pinned, and set it in the shared test home environment. The override also bypasses the keyring backend. Production builds are unchanged. Co-Authored-By: Claude Opus 5.5 --- src/auth/credentials.rs | 9 +++++++++ tests/integration/repos/test_repo.rs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/auth/credentials.rs b/src/auth/credentials.rs index feb80f1..9f49873 100644 --- a/src/auth/credentials.rs +++ b/src/auth/credentials.rs @@ -20,6 +20,15 @@ pub struct CredentialStore { impl CredentialStore { /// Create a new credential store, testing keyring availability pub fn new() -> Self { + // Integration tests pin the credentials file, since dirs::home_dir + // ignores HOME and USERPROFILE on Windows. Skips the keyring too. + #[cfg(all(not(test), feature = "test-support"))] + if let Some(path) = std::env::var_os("AUTTER_TEST_CREDENTIALS_PATH") { + return Self { + backend: Box::new(FileBackend::new(PathBuf::from(path))), + }; + } + // In test builds, always use file-based storage to avoid keyring blocking issues #[cfg(test)] { diff --git a/tests/integration/repos/test_repo.rs b/tests/integration/repos/test_repo.rs index 142dbfb..a71fb67 100644 --- a/tests/integration/repos/test_repo.rs +++ b/tests/integration/repos/test_repo.rs @@ -480,10 +480,11 @@ impl DaemonProcess { fn configure_test_home_env(command: &mut Command, test_home: &Path) { command.env("HOME", test_home); // dirs::home_dir uses Windows Known Folders, which ignores HOME and - // USERPROFILE. Pin these databases explicitly in test-support binaries. + // USERPROFILE. Pin these files explicitly in test-support binaries. for (key, filename) in [ ("AUTTER_TEST_METRICS_DB_PATH", "metrics-db"), ("AUTTER_TEST_NOTES_DB_PATH", "notes-db"), + ("AUTTER_TEST_CREDENTIALS_PATH", "credentials"), ] { if !command.get_envs().any(|(name, _)| name == key) { command.env(key, test_home.join(".autter/internal").join(filename));