Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ mod tests {

#[tokio::test]
async fn mark_and_clear_needs_auth_round_trip() {
// `mark_needs_auth` / `clear_needs_auth` write the on-disk
// needs-auth cache, which is keyed off `ORGII_HOME`.
let _sandbox = test_helpers::test_env::sandbox();
let mgr = McpManager::new();
assert!(!mgr.is_needs_auth("srv").await);
mgr.mark_needs_auth("srv", &http("https://x.test")).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ pub(crate) fn cache_path() -> Option<PathBuf> {
return Some(PathBuf::from(dir).join("mcp-needs-auth-cache.json"));
}
}
dirs::home_dir().map(|home| home.join(".orgii").join("mcp-needs-auth-cache.json"))
// Unit tests must never fall through to the developer's real home: the
// cache is process-global state keyed off `ORGII_HOME`, so an unsandboxed
// test both writes to `~/.orgii` and races whichever sandboxed test is
// holding `test_env::lock_home()` at that moment. Fail loudly instead.
#[cfg(test)]
{
panic!(
"needs-auth cache resolved without ORGII_HOME — the calling test must hold a \
`test_helpers::test_env::sandbox()` guard"
);
}
#[cfg(not(test))]
{
dirs::home_dir().map(|home| home.join(".orgii").join("mcp-needs-auth-cache.json"))
}
}

/// Global write lock — serializes the read-modify-write so concurrent
Expand Down
Loading