fix(auth): check handle

This commit is contained in:
2026-02-11 10:55:26 +08:00
parent e29926a62b
commit ba6e39d60a
9 changed files with 239 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
use iam_service::models::{AuthorizationExprCheckRequest, PermissionExpr};
#[test]
fn deserialize_any_expr() {
let json = r#"{ "expr": { "any": ["cms:article:edit", "cms:article:create"] } }"#;
let parsed: AuthorizationExprCheckRequest = serde_json::from_str(json).unwrap();
match parsed.expr {
PermissionExpr::Any(x) => {
assert_eq!(x.any.len(), 2);
}
_ => panic!("expected any"),
}
}
#[test]
fn deserialize_nested_expr() {
let json =
r#"{ "expr": { "all": ["cms:article:edit", { "any": ["cms:article:create", "cms:article:publish"] }] } }"#;
let parsed: AuthorizationExprCheckRequest = serde_json::from_str(json).unwrap();
match parsed.expr {
PermissionExpr::All(x) => {
assert_eq!(x.all.len(), 2);
}
_ => panic!("expected all"),
}
}