Fixed LDAP lookups from SMTP rules

This commit is contained in:
mdecimus
2023-07-24 09:16:20 +02:00
parent ee9d85a318
commit e8df912b27
6 changed files with 30 additions and 7 deletions

View File

@@ -39,7 +39,17 @@ async fn ldap_directory() {
.unwrap();*/
// Obtain directory handle
let handle = parse_config().directories.remove("ldap").unwrap();
let mut config = parse_config();
let lookups = config.lookups;
let handle = config.directories.remove("ldap").unwrap();
// Text lookup
assert!(lookups
.get("ldap/domains")
.unwrap()
.contains("example.org")
.await
.unwrap());
// Test authentication
assert_eq!(

View File

@@ -62,9 +62,6 @@ email = "address"
quota = "quota"
type = "type"
[directory."sql".lookup]
domains = "SELECT name FROM domains WHERE name = ?"
[directory."ldap"]
type = "ldap"
address = "ldap://localhost:3893"

View File

@@ -31,13 +31,15 @@ async fn sql_directory() {
// Enable logging
/*tracing::subscriber::set_global_default(
tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::DEBUG)
.with_max_level(tracing::Level::TRACE)
.finish(),
)
.unwrap();*/
// Obtain directory handle
let handle = parse_config().directories.remove("sql").unwrap();
let mut config = parse_config();
let lookups = config.lookups;
let handle = config.directories.remove("sql").unwrap();
// Create tables
create_test_directory(handle.as_ref()).await;
@@ -80,6 +82,14 @@ async fn sql_directory() {
link_test_address(handle.as_ref(), "robert", "robert@catchall.org", "primary").await;
link_test_address(handle.as_ref(), "robert", "@catchall.org", "alias").await;
// Text lookup
assert!(lookups
.get("sql/domains")
.unwrap()
.contains("example.org")
.await
.unwrap());
// Test authentication
assert_eq!(
handle