mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
## What changed - Track verification parameters and attempt IDs with cancellation tokens so callers can reject stale results after cancellation, server resolution, or reconnect. - Add `ResolveUserVerification` to send acceptance proofs or cancellation through MCP elicitation responses, omit proofs from session recordings, and remove resolved prompts from thread replay. - Add typed verification error messages with safe fallbacks that omit raw provider diagnostics. ## Testing Add unit coverage for attempt invalidation, duplicate attempt prevention, proof serialization, resolved prompt replay, and safe error messages. GitOrigin-RevId: 3466c9a83fe5f512a861fec062bef10dcd3025c8
58 lines
2.0 KiB
Rust
58 lines
2.0 KiB
Rust
use super::*;
|
|
use codex_app_server_protocol::JSONRPCErrorError;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn user_verification_errors_use_typed_reasons_without_raw_provider_diagnostics() {
|
|
let error = TypedRequestError::Server {
|
|
method: "userVerification/verify".to_string(),
|
|
source: JSONRPCErrorError {
|
|
code: -32603,
|
|
message: "private native provider diagnostics".to_string(),
|
|
data: Some(serde_json::json!({ "type": "unavailable", "reason": "credentialMissing" })),
|
|
},
|
|
};
|
|
assert_eq!(
|
|
verification_error_message(&error),
|
|
"No user-verification credential is available in the local Codex binary."
|
|
);
|
|
let malformed = TypedRequestError::Server {
|
|
method: "userVerification/verify".to_string(),
|
|
source: JSONRPCErrorError {
|
|
code: -32603,
|
|
message: "private native provider diagnostics".to_string(),
|
|
data: Some(
|
|
serde_json::json!({ "type": "unavailable", "reason": "secret native failure" }),
|
|
),
|
|
},
|
|
};
|
|
assert_eq!(
|
|
verification_error_message(&malformed),
|
|
"The local Codex binary could not complete user verification."
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn unavailable_reasons_use_device_and_session_neutral_copy() {
|
|
for (reason, expected) in [
|
|
(
|
|
"biometricsUnavailable",
|
|
"Biometric verification is currently unavailable on this device.",
|
|
),
|
|
(
|
|
"providerUnavailable",
|
|
"User verification is unavailable for this request.",
|
|
),
|
|
] {
|
|
let error = TypedRequestError::Server {
|
|
method: "userVerification/verify".to_string(),
|
|
source: JSONRPCErrorError {
|
|
code: -32603,
|
|
message: "private native provider diagnostics".to_string(),
|
|
data: Some(serde_json::json!({ "type": "unavailable", "reason": reason })),
|
|
},
|
|
};
|
|
assert_eq!(verification_error_message(&error), expected);
|
|
}
|
|
}
|