mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Nesting works
This commit is contained in:
parent
0b75e0d537
commit
cc14125640
|
@ -319,20 +319,43 @@ mod tests {
|
|||
fn test_nested_entry_filter() {
|
||||
let e1: Entry = serde_json::from_str(r#"{
|
||||
"attrs": {
|
||||
"userid": ["william"],
|
||||
"class": ["person"],
|
||||
"uidNumber": ["1000"]
|
||||
}
|
||||
}"#).unwrap();
|
||||
|
||||
let e2: Entry = serde_json::from_str(r#"{
|
||||
"attrs": {
|
||||
"class": ["person"],
|
||||
"uidNumber": ["1001"]
|
||||
}
|
||||
}"#).unwrap();
|
||||
|
||||
let e3: Entry = serde_json::from_str(r#"{
|
||||
"attrs": {
|
||||
"class": ["person"],
|
||||
"uidNumber": ["1002"]
|
||||
}
|
||||
}"#).unwrap();
|
||||
|
||||
let e4: Entry = serde_json::from_str(r#"{
|
||||
"attrs": {
|
||||
"class": ["group"],
|
||||
"uidNumber": ["1000"]
|
||||
}
|
||||
}"#).unwrap();
|
||||
|
||||
let f_t1a = Filter::And(vec![
|
||||
Filter::Eq(String::from("class"), String::from("person")),
|
||||
Filter::And(vec![
|
||||
Filter::Or(vec![
|
||||
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
||||
Filter::Eq(String::from("uidNumber"), String::from("1000")),
|
||||
]),
|
||||
]);
|
||||
|
||||
println!("{:?}", f_t1a);
|
||||
assert!(false);
|
||||
assert!(f_t1a.entry_match_no_index(&e1));
|
||||
assert!(f_t1a.entry_match_no_index(&e2));
|
||||
assert!(!f_t1a.entry_match_no_index(&e3));
|
||||
assert!(!f_t1a.entry_match_no_index(&e4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1021,19 +1021,8 @@ impl SchemaInner {
|
|||
}
|
||||
})
|
||||
}
|
||||
Filter::Not(filters) => {
|
||||
// This should never happen because
|
||||
// optimising should remove them as invalid parts?
|
||||
if filters.len() == 0 {
|
||||
return Err(SchemaError::EmptyFilter);
|
||||
};
|
||||
filters.iter().fold(Ok(()), |acc, filt| {
|
||||
if acc.is_ok() {
|
||||
self.validate_filter(filt)
|
||||
} else {
|
||||
acc
|
||||
}
|
||||
})
|
||||
Filter::Not(filter) => {
|
||||
self.validate_filter(filter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue