mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
Fixes mcp elicitation test that fails for me when run locally (#8020)
This commit is contained in:
1 parent
3ee5c40261
commit
d9554c8191
4 files changed
+25
-4
No files matched your search
Generated
-1
@@ -1395,7 +1395,6 @@ dependencies = [
|
|||||||
"tokio-util",
|
"tokio-util",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"which",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ use crate::token_data::parse_id_token;
|
|||||||
use crate::util::try_parse_error_message;
|
use crate::util::try_parse_error_message;
|
||||||
use codex_client::CodexHttpClient;
|
use codex_client::CodexHttpClient;
|
||||||
use codex_protocol::account::PlanType as AccountPlanType;
|
use codex_protocol::account::PlanType as AccountPlanType;
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|||||||
@@ -61,4 +61,3 @@ exec_server_test_support = { workspace = true }
|
|||||||
maplit = { workspace = true }
|
maplit = { workspace = true }
|
||||||
pretty_assertions = { workspace = true }
|
pretty_assertions = { workspace = true }
|
||||||
tempfile = { workspace = true }
|
tempfile = { workspace = true }
|
||||||
which = { workspace = true }
|
|
||||||
@@ -24,6 +24,7 @@ use serde_json::json;
|
|||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
use std::os::unix::fs::symlink;
|
use std::os::unix::fs::symlink;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
/// Verify that when using a read-only sandbox and an execpolicy that prompts,
|
/// Verify that when using a read-only sandbox and an execpolicy that prompts,
|
||||||
/// the proper elicitation is sent. Upon auto-approving the elicitation, the
|
/// the proper elicitation is sent. Upon auto-approving the elicitation, the
|
||||||
@@ -53,11 +54,11 @@ prefix_rule(
|
|||||||
|
|
||||||
// Create an MCP client that approves expected elicitation messages.
|
// Create an MCP client that approves expected elicitation messages.
|
||||||
let project_root = TempDir::new()?;
|
let project_root = TempDir::new()?;
|
||||||
let git = which::which("git")?;
|
|
||||||
let project_root_path = project_root.path().canonicalize().unwrap();
|
let project_root_path = project_root.path().canonicalize().unwrap();
|
||||||
|
let git_path = resolve_git_path().await?;
|
||||||
let expected_elicitation_message = format!(
|
let expected_elicitation_message = format!(
|
||||||
"Allow agent to run `{} init .` in `{}`?",
|
"Allow agent to run `{} init .` in `{}`?",
|
||||||
git.display(),
|
git_path,
|
||||||
project_root_path.display()
|
project_root_path.display()
|
||||||
);
|
);
|
||||||
let elicitation_requests: Arc<Mutex<Vec<CreateElicitationRequestParam>>> = Default::default();
|
let elicitation_requests: Arc<Mutex<Vec<CreateElicitationRequestParam>>> = Default::default();
|
||||||
@@ -175,3 +176,23 @@ fn ensure_codex_cli() -> Result<PathBuf> {
|
|||||||
|
|
||||||
Ok(codex_cli)
|
Ok(codex_cli)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn resolve_git_path() -> Result<String> {
|
||||||
|
let git = Command::new("bash")
|
||||||
|
.arg("-lc")
|
||||||
|
.arg("command -v git")
|
||||||
|
.output()
|
||||||
|
.await
|
||||||
|
.context("failed to resolve git via login shell")?;
|
||||||
|
ensure!(
|
||||||
|
git.status.success(),
|
||||||
|
"failed to resolve git via login shell: {}",
|
||||||
|
String::from_utf8_lossy(&git.stderr)
|
||||||
|
);
|
||||||
|
let git_path = String::from_utf8(git.stdout)
|
||||||
|
.context("git path was not valid utf8")?
|
||||||
|
.trim()
|
||||||
|
.to_string();
|
||||||
|
ensure!(!git_path.is_empty(), "git path should not be empty");
|
||||||
|
Ok(git_path)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user