fix(auth): iam check

This commit is contained in:
2026-02-11 10:56:04 +08:00
parent 583fd521a2
commit 909d9a6da2
18 changed files with 646 additions and 202 deletions

View File

@@ -0,0 +1,40 @@
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct AppResponse<T> {
code: i32,
message: String,
data: Option<T>,
}
#[derive(Debug, Deserialize)]
struct RefreshResponseData {
access_token: String,
refresh_token: String,
token_type: Option<String>,
expires_in: usize,
}
#[test]
fn can_decode_iam_refresh_response_snake_case() {
let json = r#"
{
"code": 0,
"message": "ok",
"data": {
"access_token": "a",
"refresh_token": "r",
"token_type": "Bearer",
"expires_in": 7200
}
}
"#;
let parsed: AppResponse<RefreshResponseData> = serde_json::from_str(json).unwrap();
let data = parsed.data.unwrap();
assert_eq!(data.access_token, "a");
assert_eq!(data.refresh_token, "r");
assert_eq!(data.token_type.as_deref(), Some("Bearer"));
assert_eq!(data.expires_in, 7200);
}