mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
tests for dn filter in users and groups
This commit is contained in:
parent
9018e6fa34
commit
0f7f826f72
@ -221,3 +221,48 @@ pub async fn get_groups_list<Backend: BackendHandler>(
|
||||
})
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ldap3_proto::LdapFilter;
|
||||
|
||||
use crate::domain::ldap::group::GroupRequestFilter;
|
||||
use crate::domain::ldap::utils::{parse_distinguished_name, LdapInfo};
|
||||
|
||||
use super::convert_group_filter;
|
||||
|
||||
static BASE_DN_STR: &str = "dc=example,dc=com";
|
||||
|
||||
#[test]
|
||||
fn test_convert_group_filter() {
|
||||
let ldap_info = LdapInfo {
|
||||
base_dn: parse_distinguished_name(BASE_DN_STR).unwrap(),
|
||||
base_dn_str: BASE_DN_STR.to_string(),
|
||||
ignored_user_attributes: vec![],
|
||||
ignored_group_attributes: vec![],
|
||||
};
|
||||
// TODO: test all other match cases
|
||||
let res = convert_group_filter(
|
||||
&ldap_info,
|
||||
&LdapFilter::Equality(
|
||||
"dn".to_string(),
|
||||
"uid=test,ou=groups,dc=example,dc=com".to_string(),
|
||||
),
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(GroupRequestFilter::DisplayName("test".to_string().into()))
|
||||
);
|
||||
let res = convert_group_filter(
|
||||
&ldap_info,
|
||||
&LdapFilter::Equality(
|
||||
"dn".to_string(),
|
||||
"cn=test,ou=groups,dc=example,dc=com".to_string(),
|
||||
),
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(GroupRequestFilter::DisplayName("test".to_string().into()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -232,3 +232,48 @@ pub async fn get_user_list<Backend: BackendHandler>(
|
||||
})
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ldap3_proto::LdapFilter;
|
||||
|
||||
use crate::domain::ldap::user::UserRequestFilter;
|
||||
use crate::domain::ldap::utils::{parse_distinguished_name, LdapInfo};
|
||||
|
||||
use super::convert_user_filter;
|
||||
|
||||
static BASE_DN_STR: &str = "dc=example,dc=com";
|
||||
|
||||
#[test]
|
||||
fn test_convert_user_filter() {
|
||||
let ldap_info = LdapInfo {
|
||||
base_dn: parse_distinguished_name(BASE_DN_STR).unwrap(),
|
||||
base_dn_str: BASE_DN_STR.to_string(),
|
||||
ignored_user_attributes: vec![],
|
||||
ignored_group_attributes: vec![],
|
||||
};
|
||||
// TODO: test all other match cases
|
||||
let res = convert_user_filter(
|
||||
&ldap_info,
|
||||
&LdapFilter::Equality(
|
||||
"dn".to_string(),
|
||||
"uid=test,ou=people,dc=example,dc=com".to_string(),
|
||||
),
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(UserRequestFilter::UserId("test".to_string().into()))
|
||||
);
|
||||
let res = convert_user_filter(
|
||||
&ldap_info,
|
||||
&LdapFilter::Equality(
|
||||
"dn".to_string(),
|
||||
"cn=test,ou=people,dc=example,dc=com".to_string(),
|
||||
),
|
||||
);
|
||||
assert_eq!(
|
||||
res,
|
||||
Ok(UserRequestFilter::UserId("test".to_string().into()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user