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));