mirror of
https://github.com/kanidm/kanidm.git
synced 2025-02-23 20:47:01 +01:00
Fix my delusion that ldap filters are parseable. They are not.
This commit is contained in:
parent
cda4868533
commit
0b75e0d537
|
@ -17,7 +17,7 @@ pub enum Filter {
|
||||||
Pres(String),
|
Pres(String),
|
||||||
Or(Vec<Filter>),
|
Or(Vec<Filter>),
|
||||||
And(Vec<Filter>),
|
And(Vec<Filter>),
|
||||||
Not(Vec<Filter>),
|
Not(Box<Filter>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Filter {
|
impl Filter {
|
||||||
|
@ -56,13 +56,27 @@ impl Filter {
|
||||||
e.attribute_pres(attr.as_str())
|
e.attribute_pres(attr.as_str())
|
||||||
}
|
}
|
||||||
Filter::Or(l) => {
|
Filter::Or(l) => {
|
||||||
unimplemented!();
|
l.iter()
|
||||||
|
.fold(false, |acc, f| {
|
||||||
|
if acc {
|
||||||
|
acc
|
||||||
|
} else {
|
||||||
|
f.entry_match_no_index(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Filter::And(_) => {
|
Filter::And(l) => {
|
||||||
unimplemented!();
|
l.iter()
|
||||||
|
.fold(true, |acc, f| {
|
||||||
|
if acc {
|
||||||
|
f.entry_match_no_index(e)
|
||||||
|
} else {
|
||||||
|
acc
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Filter::Not(_) => {
|
Filter::Not(f) => {
|
||||||
unimplemented!();
|
!f.entry_match_no_index(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +267,7 @@ mod tests {
|
||||||
Filter::Eq(String::from("userid"), String::from("alice")),
|
Filter::Eq(String::from("userid"), String::from("alice")),
|
||||||
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
||||||
]);
|
]);
|
||||||
assert!(f_t4a.entry_match_no_index(&e));
|
assert!(!f_t4a.entry_match_no_index(&e));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -275,19 +289,19 @@ mod tests {
|
||||||
Filter::Eq(String::from("userid"), String::from("william")),
|
Filter::Eq(String::from("userid"), String::from("william")),
|
||||||
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
||||||
]);
|
]);
|
||||||
assert!(f_t2a.entry_match_no_index(&e));
|
assert!(!f_t2a.entry_match_no_index(&e));
|
||||||
|
|
||||||
let f_t3a = Filter::And(vec![
|
let f_t3a = Filter::And(vec![
|
||||||
Filter::Eq(String::from("userid"), String::from("alice")),
|
Filter::Eq(String::from("userid"), String::from("alice")),
|
||||||
Filter::Eq(String::from("uidNumber"), String::from("1000")),
|
Filter::Eq(String::from("uidNumber"), String::from("1000")),
|
||||||
]);
|
]);
|
||||||
assert!(f_t3a.entry_match_no_index(&e));
|
assert!(!f_t3a.entry_match_no_index(&e));
|
||||||
|
|
||||||
let f_t4a = Filter::And(vec![
|
let f_t4a = Filter::And(vec![
|
||||||
Filter::Eq(String::from("userid"), String::from("alice")),
|
Filter::Eq(String::from("userid"), String::from("alice")),
|
||||||
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
Filter::Eq(String::from("uidNumber"), String::from("1001")),
|
||||||
]);
|
]);
|
||||||
assert!(f_t4a.entry_match_no_index(&e));
|
assert!(!f_t4a.entry_match_no_index(&e));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue