Files
codex/codex-rs/app-server/tests/suite/v2/user_verification.rs
T
riley-oai ad931a45b2 Add experimental user verification API contracts (#43265)
## What changed

Add `userVerification/status`, `userVerification/enroll`, `userVerification/delete`, and `userVerification/verify` behind the `experimentalApi` capability. Define request, response, proof, and typed error contracts, export their schemas, and document the API.

All four methods currently return `unavailable` with reason `providerUnavailable`; native verification operations are not implemented by this change.

## Testing

Add tests for experimental opt-in, typed provider unavailability, readiness serialization, and rejection of mismatched error reasons and native diagnostic payloads.

GitOrigin-RevId: a858ab41523c5acec7dbf3cfa7fcab693ac44a8c
2026-09-06 18:39:32 +00:00

77 lines
2.4 KiB
Rust

use anyhow::Result;
use app_test_support::DEFAULT_CLIENT_NAME;
use app_test_support::TestAppServer;
use codex_app_server_protocol::ClientInfo;
use codex_app_server_protocol::InitializeCapabilities;
use codex_app_server_protocol::JSONRPCErrorError;
use codex_app_server_protocol::RequestId;
use pretty_assertions::assert_eq;
use serde_json::json;
#[tokio::test]
async fn user_verification_methods_require_experimental_opt_in() -> Result<()> {
let mut app_server = TestAppServer::builder().build().await?;
app_server
.initialize_with_capabilities(
ClientInfo {
name: DEFAULT_CLIENT_NAME.into(),
title: None,
version: "0.1.0".into(),
},
Some(InitializeCapabilities {
experimental_api: false,
..Default::default()
}),
)
.await?;
for (method, params) in [
("userVerification/status", json!({})),
("userVerification/enroll", json!({})),
("userVerification/delete", json!({})),
(
"userVerification/verify",
json!({"challenge": "AQ", "title": "Approve", "description": ""}),
),
] {
let id = app_server.send_raw_request(method, Some(params)).await?;
let response = app_server
.read_stream_until_error_message(RequestId::Integer(id))
.await?;
assert_eq!(
response.error,
JSONRPCErrorError {
code: -32600,
message: format!("{method} requires experimentalApi capability"),
data: None,
}
);
}
Ok(())
}
#[tokio::test]
async fn user_verification_without_provider_returns_typed_unavailability() -> Result<()> {
let mut app_server = TestAppServer::builder().build_initialized().await?;
let id = app_server
.send_raw_request(
"userVerification/verify",
Some(json!({
"challenge": "AQ", "title": "Approve", "description": ""
})),
)
.await?;
let response = app_server
.read_stream_until_error_message(RequestId::Integer(id))
.await?;
assert_eq!(
response.error,
JSONRPCErrorError {
code: -32603,
message: "User verification is not available in this build.".into(),
data: Some(json!({"type": "unavailable", "reason": "providerUnavailable"})),
}
);
Ok(())
}