Files
codex/codex-rs/auth/src/token_data_tests.rs
Ahmed Ibrahim 184fb02a9a Extract codex-auth from codex-core
Co-authored-by: Codex <noreply@openai.com>
2026-03-18 05:11:40 +00:00

21 lines
748 B
Rust

use super::*;
use pretty_assertions::assert_eq;
#[test]
fn parses_id_token_claims() {
let jwt = "eyJhbGciOiJub25lIn0.eyJlbWFpbCI6InVzZXJAZXhhbXBsZS5jb20iLCJodHRwczovL2FwaS5vcGVuYWkuY29tL2F1dGgiOnsiY2hhdGdwdF9wbGFuX3R5cGUiOiJwcm8iLCJjaGF0Z3B0X3VzZXJfaWQiOiJ1c2VyLTEiLCJjaGF0Z3B0X2FjY291bnRfaWQiOiJ3cy0xIn19.c2ln";
let claims = parse_chatgpt_jwt_claims(jwt).expect("jwt should parse");
assert_eq!(
claims,
IdTokenInfo {
email: Some("user@example.com".to_string()),
chatgpt_plan_type: Some(PlanType::Known(KnownPlan::Pro)),
chatgpt_user_id: Some("user-1".to_string()),
chatgpt_account_id: Some("ws-1".to_string()),
raw_jwt: jwt.to_string(),
}
);
}