mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
add tests for ldap compare
This commit is contained in:
parent
9b130947db
commit
f1781b198d
@ -2203,6 +2203,36 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_compare() {
|
||||||
|
let mut mock = MockTestBackendHandler::new();
|
||||||
|
mock.expect_create_user()
|
||||||
|
.with(eq(CreateUserRequest {
|
||||||
|
user_id: UserId::new("bob"),
|
||||||
|
email: "".to_owned(),
|
||||||
|
display_name: Some("Bob".to_string()),
|
||||||
|
..Default::default()
|
||||||
|
}))
|
||||||
|
.times(1)
|
||||||
|
.return_once(|_| Ok(()));
|
||||||
|
let ldap_handler = setup_bound_admin_handler(mock).await;
|
||||||
|
let dn = "uid=bob,ou=people,dc=example,dc=com".to_owned();
|
||||||
|
let request = LdapCompareRequest {
|
||||||
|
dn,
|
||||||
|
atype: "cn".to_owned(),
|
||||||
|
val: b"Bob".to_vec(),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
ldap_handler.do_compare(request).await,
|
||||||
|
Ok(vec![LdapOp::CompareResult(LdapResultOp {
|
||||||
|
code: LdapResultCode::CompareTrue,
|
||||||
|
matcheddn: dn,
|
||||||
|
message: "".to_string(),
|
||||||
|
referral: vec![],
|
||||||
|
})])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_create_user_wrong_ou() {
|
async fn test_create_user_wrong_ou() {
|
||||||
let ldap_handler = setup_bound_admin_handler(MockTestBackendHandler::new()).await;
|
let ldap_handler = setup_bound_admin_handler(MockTestBackendHandler::new()).await;
|
||||||
|
Loading…
Reference in New Issue
Block a user