fix(auth): check handle
This commit is contained in:
27
tests/authorization_expr.rs
Normal file
27
tests/authorization_expr.rs
Normal 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"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user