Download codex-rs/app-server-protocol/src/protocol/v2/user_verification_tests.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 2.46 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/user_verification_tests.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/app-server-protocol/src/protocol/v2/user_verification_tests.rs
-
curl -L -o user_verification_tests.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/user_verification_tests.rs
2.46 kB
| use super::*; | |
| use pretty_assertions::assert_eq; | |
| use serde_json::json; | |
| fn enrollment_response_accepts_older_servers_without_public_metadata() { | |
| for response in [ | |
| json!({"credentialId": "credential"}), | |
| json!({"credentialId": "credential", "algorithm": null, "publicKey": null}), | |
| ] { | |
| assert_eq!( | |
| serde_json::from_value::<UserVerificationEnrollResponse>(response).unwrap(), | |
| UserVerificationEnrollResponse { | |
| credential_id: "credential".into(), | |
| algorithm: None, | |
| public_key: None, | |
| } | |
| ); | |
| } | |
| let response = UserVerificationEnrollResponse { | |
| credential_id: "credential".into(), | |
| algorithm: Some("ecdsaP256Sha256X962".into()), | |
| public_key: Some("public-key".into()), | |
| }; | |
| assert_eq!( | |
| serde_json::from_value::<UserVerificationEnrollResponse>( | |
| serde_json::to_value(&response).unwrap() | |
| ) | |
| .unwrap(), | |
| response | |
| ); | |
| } | |
| 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 | |
| ); | |
| } | |
| 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()); | |
| } | |
| } | |