mirror of
https://github.com/openai/codex.git
synced 2026-05-29 15:30:22 +00:00
test(attestation): trim duplicate unit coverage
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -166,25 +166,14 @@ fn app_server_attestation_provider(
|
||||
AttestationProvider::new(move || {
|
||||
let outgoing = outgoing.clone();
|
||||
let attestation_connection_ids = attestation_connection_ids.clone();
|
||||
Box::pin(request_attestation_header_value(
|
||||
Box::pin(request_attestation_header_value_with_timeout(
|
||||
outgoing,
|
||||
attestation_connection_ids,
|
||||
ATTESTATION_GENERATE_TIMEOUT,
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
async fn request_attestation_header_value(
|
||||
outgoing: Arc<OutgoingMessageSender>,
|
||||
attestation_connection_ids: Arc<Mutex<HashSet<ConnectionId>>>,
|
||||
) -> Option<String> {
|
||||
request_attestation_header_value_with_timeout(
|
||||
outgoing,
|
||||
attestation_connection_ids,
|
||||
ATTESTATION_GENERATE_TIMEOUT,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn request_attestation_header_value_with_timeout(
|
||||
outgoing: Arc<OutgoingMessageSender>,
|
||||
attestation_connection_ids: Arc<Mutex<HashSet<ConnectionId>>>,
|
||||
|
||||
@@ -518,35 +518,6 @@ fn model_client_with_counting_attestation() -> (ModelClient, Arc<AtomicUsize>) {
|
||||
(model_client, attestation_calls)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn responses_generate_fresh_attestation_headers_for_chatgpt_codex() {
|
||||
let provider = api_provider("https://chatgpt.com/backend-api/codex/");
|
||||
let (model_client, attestation_calls) = model_client_with_counting_attestation();
|
||||
let mut first_headers = http::HeaderMap::new();
|
||||
let mut second_headers = http::HeaderMap::new();
|
||||
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut first_headers, &provider)
|
||||
.await;
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut second_headers, &provider)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
first_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-1"),
|
||||
);
|
||||
assert_eq!(
|
||||
second_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-2"),
|
||||
);
|
||||
assert_eq!(attestation_calls.load(Ordering::Relaxed), 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses() {
|
||||
let provider = api_provider("https://chatgpt.com/backend-api/codex/");
|
||||
@@ -567,64 +538,6 @@ async fn websocket_handshake_includes_attestation_for_chatgpt_codex_responses()
|
||||
assert_eq!(attestation_calls.load(Ordering::Relaxed), 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn compact_generate_fresh_attestation_headers_for_chatgpt_codex() {
|
||||
let provider = api_provider("https://chatgpt.com/backend-api/codex/");
|
||||
let (model_client, attestation_calls) = model_client_with_counting_attestation();
|
||||
let mut first_headers = http::HeaderMap::new();
|
||||
let mut second_headers = http::HeaderMap::new();
|
||||
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut first_headers, &provider)
|
||||
.await;
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut second_headers, &provider)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
first_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-1"),
|
||||
);
|
||||
assert_eq!(
|
||||
second_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-2"),
|
||||
);
|
||||
assert_eq!(attestation_calls.load(Ordering::Relaxed), 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn realtime_setup_generate_fresh_attestation_headers_for_chatgpt_codex() {
|
||||
let provider = api_provider("https://chatgpt.com/backend-api/codex/");
|
||||
let (model_client, attestation_calls) = model_client_with_counting_attestation();
|
||||
let mut first_headers = http::HeaderMap::new();
|
||||
let mut second_headers = http::HeaderMap::new();
|
||||
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut first_headers, &provider)
|
||||
.await;
|
||||
model_client
|
||||
.extend_attestation_header_for(&mut second_headers, &provider)
|
||||
.await;
|
||||
|
||||
assert_eq!(
|
||||
first_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-1"),
|
||||
);
|
||||
assert_eq!(
|
||||
second_headers
|
||||
.get(crate::attestation::X_OAI_ATTESTATION_HEADER)
|
||||
.and_then(|value| value.to_str().ok()),
|
||||
Some("v1.header-2"),
|
||||
);
|
||||
assert_eq!(attestation_calls.load(Ordering::Relaxed), 2);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn non_chatgpt_codex_endpoints_omit_attestation_generation() {
|
||||
let provider = api_provider("https://api.openai.com/v1");
|
||||
|
||||
Reference in New Issue
Block a user