ldap_handler: trim spaces in LDAP identifiers

This commit is contained in:
Valentin Tolmer 2022-02-11 08:40:10 +01:00 committed by nitnelave
parent 747e37592d
commit d20bd196bc

View File

@ -37,7 +37,7 @@ where
fn parse_distinguished_name(dn: &str) -> Result<Vec<(String, String)>> { fn parse_distinguished_name(dn: &str) -> Result<Vec<(String, String)>> {
dn.split(',') dn.split(',')
.map(|s| make_dn_pair(s.split('=').map(String::from))) .map(|s| make_dn_pair(s.split('=').map(str::trim).map(String::from)))
.collect() .collect()
} }
@ -908,6 +908,11 @@ mod tests {
parse_distinguished_name("ou=people,dc=example,dc=com").expect("parsing failed"), parse_distinguished_name("ou=people,dc=example,dc=com").expect("parsing failed"),
parsed_dn parsed_dn
); );
assert_eq!(
parse_distinguished_name(" ou = people , dc = example , dc = com ")
.expect("parsing failed"),
parsed_dn
);
} }
#[tokio::test] #[tokio::test]