mirror of
https://github.com/openai/codex.git
synced 2026-11-16 14:55:43 +00:00
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
This commit is contained in:
1 parent
7bab4526f9
commit
ad931a45b2
12 files changed
+368
No files matched your search
@@ -0,0 +1,44 @@
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn local_readiness_retains_credential_during_biometric_unavailability() {
|
||||
let status = UserVerificationStatusResponse {
|
||||
credential_id: Some("credential".into()),
|
||||
unavailable_reason: Some(UserVerificationUnavailableReason::BiometricsUnavailable),
|
||||
unavailable_message: Some("Unlock biometrics to continue.".into()),
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_value(&status).unwrap(),
|
||||
json!({
|
||||
"credentialId": "credential",
|
||||
"unavailableReason": "biometricsUnavailable",
|
||||
"unavailableMessage": "Unlock biometrics to continue."
|
||||
})
|
||||
);
|
||||
assert_eq!(
|
||||
serde_json::from_value::<UserVerificationStatusResponse>(
|
||||
serde_json::to_value(&status).unwrap()
|
||||
)
|
||||
.unwrap(),
|
||||
status
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_details_reject_cross_category_reasons_and_native_payloads() {
|
||||
let details = UserVerificationErrorDetails::Cancelled {
|
||||
reason: UserVerificationCancellationReason::UserCancelled,
|
||||
};
|
||||
assert_eq!(
|
||||
serde_json::to_value(details).unwrap(),
|
||||
json!({"type": "cancelled", "reason": "userCancelled"})
|
||||
);
|
||||
for invalid in [
|
||||
json!({"type": "failed", "reason": "userCancelled"}),
|
||||
json!({"type": "unavailable", "reason": "providerUnavailable", "nativeError": {"code": 1}}),
|
||||
] {
|
||||
assert!(serde_json::from_value::<UserVerificationErrorDetails>(invalid).is_err());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user