Synced from monorepo
Synced from monorepo Changes: - Workspace server: report `/ready` as failed with dwell on hub connect failure - Refresh OIDC token for the Grok agent in the shell - ACP terminal output recorder - Cross-platform provider auth commands in the shell - Default `/resume` to Grok sessions with a hint for hidden external sessions - Resume sessions by title with `--resume` - Limit app-builder archive size - Data-driven tag labels for slash commands - Doctor fixes for tmux - Custom provider gateways and subprocess environment policy in the shell - `/tutorial` — opt-in onboarding tour of Grok Build - Soft and required CLI version checks in the shell - Privacy banner env overrides survive live settings updates - Add remote flag to override the image-edit model - Return profile fields from auth info even when the access token is expired - Add edit control on queued prompt rows - Keep fail-closed policy when clearing orphans with no team - Setting to disable the Ctrl+Space/F8 voice shortcut - Pass `--raw` to pw-record so Linux dictation works on older PipeWire - Validate git URLs when adding marketplace entries - Stop shipping stale tool-doc parameter and tool names - Re-point dashboard attach after `/fork` only when the parent was attached - Surface Grok Computer media-generation results as file-path chunks - Clear web background-task tray on kill and keep the task description - Show privacy upsell banner in agent view until acted on - Add tools-server client callback surface - Protect persistent global hook sources Source-Revision: 95d84f443eddcbed6cbfd6eed22e2eafe6b3939d
This commit is contained in:
parent
a5727c5960
commit
69f0ba880a
286 changed files with 22939 additions and 9624 deletions
|
|
@ -0,0 +1,64 @@
|
|||
//! Checks that provider `query_params` and `env_http_headers` reach the
|
||||
//! outgoing request.
|
||||
|
||||
mod support;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use axum::Router;
|
||||
use axum::http::{HeaderMap, Uri};
|
||||
use axum::routing::post;
|
||||
use tokio::net::TcpListener;
|
||||
use xai_grok_sampler::SamplingClient;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn request_carries_query_params_and_env_http_headers() {
|
||||
// A unique name avoids clashing with other tests that read the process
|
||||
// environment; the surrounding whitespace exercises value trimming.
|
||||
let env_var = "XAI_SAMPLER_TEST_TENANT_TOKEN";
|
||||
unsafe { std::env::set_var(env_var, " tenant-secret\n") };
|
||||
|
||||
let captured: Arc<Mutex<Option<(String, HeaderMap)>>> = Arc::new(Mutex::new(None));
|
||||
let sink = Arc::clone(&captured);
|
||||
let app = Router::new().route(
|
||||
"/v1/chat/completions",
|
||||
post(move |uri: Uri, headers: HeaderMap| {
|
||||
let sink = Arc::clone(&sink);
|
||||
async move {
|
||||
*sink.lock().unwrap() =
|
||||
Some((uri.query().unwrap_or_default().to_string(), headers));
|
||||
"{}"
|
||||
}
|
||||
}),
|
||||
);
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
tokio::spawn(async move {
|
||||
let _ = axum::serve(listener, app).await;
|
||||
});
|
||||
|
||||
// The base URL already carries `api-version`; a configured value must
|
||||
// replace it (not duplicate), keep unrelated keys, and percent-encode.
|
||||
let base_url = format!("http://{addr}/v1?api-version=old&keep=1");
|
||||
let mut cfg = support::test_config(&base_url, "test-key");
|
||||
cfg.query_params
|
||||
.insert("api-version".into(), "2026-07-22".into());
|
||||
cfg.query_params.insert("tenant".into(), "a b".into());
|
||||
cfg.env_http_headers
|
||||
.insert("x-tenant-token".into(), env_var.into());
|
||||
|
||||
let client = SamplingClient::new(cfg).expect("client builds");
|
||||
support::send_one(&client).await;
|
||||
unsafe { std::env::remove_var(env_var) };
|
||||
|
||||
let (query, headers) = captured.lock().unwrap().take().expect("request captured");
|
||||
assert_eq!(query.matches("api-version=").count(), 1, "query: {query}");
|
||||
assert!(query.contains("api-version=2026-07-22"), "query: {query}");
|
||||
assert!(!query.contains("api-version=old"), "query: {query}");
|
||||
assert!(query.contains("keep=1"), "query: {query}");
|
||||
assert!(
|
||||
query.contains("tenant=a%20b") || query.contains("tenant=a+b"),
|
||||
"query: {query}"
|
||||
);
|
||||
assert_eq!(headers.get("x-tenant-token").unwrap(), "tenant-secret");
|
||||
}
|
||||
|
|
@ -79,6 +79,8 @@ fn test_config(base_url: String, model: &str) -> SamplerConfig {
|
|||
api_backend: ApiBackend::ChatCompletions,
|
||||
auth_scheme: Default::default(),
|
||||
extra_headers: IndexMap::new(),
|
||||
query_params: IndexMap::new(),
|
||||
env_http_headers: IndexMap::new(),
|
||||
context_window: 128_000,
|
||||
force_http1: false,
|
||||
// Keep retries minimal so tests don't take forever.
|
||||
|
|
|
|||
Loading…
Reference in a new issue