Directory implementation - all tests passing
This commit is contained in:
@@ -12,7 +12,7 @@ use tokio_rustls::TlsAcceptor;
|
||||
|
||||
const CONFIG: &str = r#"
|
||||
[directory."sql"]
|
||||
protocol = "sql"
|
||||
type = "sql"
|
||||
address = "sqlite::memory:"
|
||||
|
||||
[directory."sql".pool]
|
||||
@@ -42,7 +42,7 @@ type = "type"
|
||||
domains = "SELECT name FROM domains WHERE name = ?"
|
||||
|
||||
[directory."ldap"]
|
||||
protocol = "ldap"
|
||||
type = "ldap"
|
||||
address = "ldap://localhost:3893"
|
||||
base-dn = "dc=example,dc=org"
|
||||
|
||||
@@ -77,7 +77,7 @@ email-alias = "givenName"
|
||||
quota = "diskQuota"
|
||||
|
||||
[directory."imap"]
|
||||
protocol = "imap"
|
||||
type = "imap"
|
||||
address = "127.0.0.1"
|
||||
port = 9198
|
||||
|
||||
@@ -89,7 +89,7 @@ implicit = true
|
||||
allow-invalid-certs = true
|
||||
|
||||
[directory."smtp"]
|
||||
protocol = "lmtp"
|
||||
type = "lmtp"
|
||||
address = "127.0.0.1"
|
||||
port = 9199
|
||||
|
||||
@@ -109,7 +109,7 @@ entries = 500
|
||||
ttl = {positive = '10s', negative = '5s'}
|
||||
|
||||
[directory."local"]
|
||||
protocol = "memory"
|
||||
type = "memory"
|
||||
|
||||
[[directory."local".users]]
|
||||
name = "john"
|
||||
|
||||
@@ -293,16 +293,22 @@ pub async fn set_test_quota(handle: &dyn Directory, login: &str, quota: u32) {
|
||||
}
|
||||
|
||||
pub async fn add_to_group(handle: &dyn Directory, login: &str, group: &str) {
|
||||
let user = handle.principal_by_name(login).await.unwrap().unwrap();
|
||||
let group = handle.principal_by_name(group).await.unwrap().unwrap();
|
||||
|
||||
let uid = user.id;
|
||||
let gid = group.id;
|
||||
assert_ne!(gid, u32::MAX, "{group:?}");
|
||||
|
||||
assert_ne!(uid, gid, "{user:?} {group:?}");
|
||||
assert_ne!(uid, u32::MAX, "{user:?} {group:?}");
|
||||
assert_ne!(gid, u32::MAX, "{user:?} {group:?}");
|
||||
add_to_group_id(handle, login, gid).await;
|
||||
}
|
||||
|
||||
pub async fn add_to_group_id(handle: &dyn Directory, login: &str, gid: u32) {
|
||||
let user = handle.principal_by_name(login).await.unwrap().unwrap();
|
||||
let uid = user.id;
|
||||
assert_ne!(uid, u32::MAX, "{user:?}");
|
||||
assert_ne!(uid, gid, "{user:?}");
|
||||
add_user_id_to_group_id(handle, uid, gid).await;
|
||||
}
|
||||
|
||||
pub async fn add_user_id_to_group_id(handle: &dyn Directory, uid: u32, gid: u32) {
|
||||
handle
|
||||
.query(
|
||||
&format!(
|
||||
@@ -318,7 +324,10 @@ pub async fn add_to_group(handle: &dyn Directory, login: &str, group: &str) {
|
||||
pub async fn remove_from_group(handle: &dyn Directory, uid: u32, gid: u32) {
|
||||
handle
|
||||
.query(
|
||||
&format!("DELETE FROM groups WHERE uid = {} AND gid = {}", uid, gid),
|
||||
&format!(
|
||||
"DELETE FROM group_members WHERE uid = {} AND gid = {}",
|
||||
uid, gid
|
||||
),
|
||||
&[],
|
||||
)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user