Files
codex/codex-rs/tui/src/app/user_verification_errors_tests.rs
T
riley-oai 95327467c3 Add TUI request bookkeeping for user verification (#43708)
## 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
2026-09-08 05:12:10 +00:00

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);
}
}