Improved tracing (part 3)

This commit is contained in:
mdecimus
2024-07-26 19:44:01 +02:00
parent 52cb48353e
commit 1e76792d03
100 changed files with 2892 additions and 2153 deletions

View File

@@ -134,37 +134,37 @@ async fn ldap_directory() {
// Ids by email
compare_sorted(
core.email_to_ids(&handle, "jane@example.org")
core.email_to_ids(&handle, "jane@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["jane"]).await,
);
compare_sorted(
core.email_to_ids(&handle, "jane+alias@example.org")
core.email_to_ids(&handle, "jane+alias@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["jane"]).await,
);
compare_sorted(
core.email_to_ids(&handle, "info@example.org")
core.email_to_ids(&handle, "info@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["bill", "jane", "john"]).await,
);
compare_sorted(
core.email_to_ids(&handle, "info+alias@example.org")
core.email_to_ids(&handle, "info+alias@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["bill", "jane", "john"]).await,
);
compare_sorted(
core.email_to_ids(&handle, "unknown@example.org")
core.email_to_ids(&handle, "unknown@example.org", 0)
.await
.unwrap(),
Vec::<u32>::new(),
);
assert_eq!(
core.email_to_ids(&handle, "anything@catchall.org")
core.email_to_ids(&handle, "anything@catchall.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["robert"]).await
@@ -175,41 +175,47 @@ async fn ldap_directory() {
assert!(!handle.is_local_domain("other.org").await.unwrap());
// RCPT TO
assert!(core.rcpt(&handle, "jane@example.org").await.unwrap());
assert!(core.rcpt(&handle, "info@example.org").await.unwrap());
assert!(core.rcpt(&handle, "jane+alias@example.org").await.unwrap());
assert!(core.rcpt(&handle, "info+alias@example.org").await.unwrap());
assert!(core.rcpt(&handle, "jane@example.org", 0).await.unwrap());
assert!(core.rcpt(&handle, "info@example.org", 0).await.unwrap());
assert!(core
.rcpt(&handle, "random_user@catchall.org")
.rcpt(&handle, "jane+alias@example.org", 0)
.await
.unwrap());
assert!(!core.rcpt(&handle, "invalid@example.org").await.unwrap());
assert!(core
.rcpt(&handle, "info+alias@example.org", 0)
.await
.unwrap());
assert!(core
.rcpt(&handle, "random_user@catchall.org", 0)
.await
.unwrap());
assert!(!core.rcpt(&handle, "invalid@example.org", 0).await.unwrap());
// VRFY
compare_sorted(
core.vrfy(&handle, "jane").await.unwrap(),
core.vrfy(&handle, "jane", 0).await.unwrap(),
vec!["jane@example.org".to_string()],
);
compare_sorted(
core.vrfy(&handle, "john").await.unwrap(),
core.vrfy(&handle, "john", 0).await.unwrap(),
vec!["john@example.org".to_string()],
);
compare_sorted(
core.vrfy(&handle, "jane+alias@example").await.unwrap(),
core.vrfy(&handle, "jane+alias@example", 0).await.unwrap(),
vec!["jane@example.org".to_string()],
);
compare_sorted(
core.vrfy(&handle, "info").await.unwrap(),
core.vrfy(&handle, "info", 0).await.unwrap(),
Vec::<String>::new(),
);
compare_sorted(
core.vrfy(&handle, "invalid").await.unwrap(),
core.vrfy(&handle, "invalid", 0).await.unwrap(),
Vec::<String>::new(),
);
// EXPN
compare_sorted(
core.expn(&handle, "info@example.org").await.unwrap(),
core.expn(&handle, "info@example.org", 0).await.unwrap(),
vec![
"bill@example.org".to_string(),
"jane@example.org".to_string(),
@@ -217,7 +223,7 @@ async fn ldap_directory() {
],
);
compare_sorted(
core.expn(&handle, "john@example.org").await.unwrap(),
core.expn(&handle, "john@example.org", 0).await.unwrap(),
Vec::<String>::new(),
);
}

View File

@@ -621,13 +621,13 @@ async fn address_mappings() {
let subaddressing = AddressMapping::parse(&mut config, (test, "subaddressing"));
assert_eq!(
subaddressing.to_subaddress(&core, ADDR).await,
subaddressing.to_subaddress(&core, ADDR, 0).await,
config.value_require((test, "expected-sub")).unwrap(),
"failed subaddress for {test:?}"
);
assert_eq!(
subaddressing.to_subaddress(&core, ADDR_NO_MATCH).await,
subaddressing.to_subaddress(&core, ADDR_NO_MATCH, 0).await,
config
.value_require((test, "expected-sub-nomatch"))
.unwrap(),
@@ -635,7 +635,7 @@ async fn address_mappings() {
);
assert_eq!(
catch_all.to_catch_all(&core, ADDR).await,
catch_all.to_catch_all(&core, ADDR, 0).await,
config
.property_require::<Option<String>>((test, "expected-catch"))
.unwrap()

View File

@@ -78,14 +78,14 @@ async fn lmtp_directory() {
for (item, expected) in &tests {
let result: LookupResult = match item {
Item::IsAccount(v) => core.rcpt(&handle, v).await.unwrap().into(),
Item::IsAccount(v) => core.rcpt(&handle, v, 0).await.unwrap().into(),
Item::Authenticate(v) => handle
.query(QueryBy::Credentials(v), true)
.await
.unwrap()
.is_some()
.into(),
Item::Verify(v) => match core.vrfy(&handle, v).await {
Item::Verify(v) => match core.vrfy(&handle, v, 0).await {
Ok(v) => v.into(),
Err(e) => {
if e.matches(trc::EventType::Store(trc::StoreEvent::NotSupported)) {
@@ -95,7 +95,7 @@ async fn lmtp_directory() {
}
}
},
Item::Expand(v) => match core.expn(&handle, v).await {
Item::Expand(v) => match core.expn(&handle, v, 0).await {
Ok(v) => v.into(),
Err(e) => {
if e.matches(trc::EventType::Store(trc::StoreEvent::NotSupported)) {
@@ -122,14 +122,14 @@ async fn lmtp_directory() {
requests.push((
tokio::spawn(async move {
let result: LookupResult = match &item {
Item::IsAccount(v) => core.rcpt(&handle, v).await.unwrap().into(),
Item::IsAccount(v) => core.rcpt(&handle, v, 0).await.unwrap().into(),
Item::Authenticate(v) => handle
.query(QueryBy::Credentials(v), true)
.await
.unwrap()
.is_some()
.into(),
Item::Verify(v) => match core.vrfy(&handle, v).await {
Item::Verify(v) => match core.vrfy(&handle, v, 0).await {
Ok(v) => v.into(),
Err(e) => {
if e.matches(trc::EventType::Store(trc::StoreEvent::NotSupported)) {
@@ -139,7 +139,7 @@ async fn lmtp_directory() {
}
}
},
Item::Expand(v) => match core.expn(&handle, v).await {
Item::Expand(v) => match core.expn(&handle, v, 0).await {
Ok(v) => v.into(),
Err(e) => {
if e.matches(trc::EventType::Store(trc::StoreEvent::NotSupported)) {
@@ -182,7 +182,7 @@ async fn lmtp_directory() {
requests.push((
tokio::spawn(async move {
let result: LookupResult = match &item {
Item::IsAccount(v) => core.rcpt(&handle, v).await.unwrap().into(),
Item::IsAccount(v) => core.rcpt(&handle, v, 0).await.unwrap().into(),
_ => unreachable!(),
};

View File

@@ -200,37 +200,37 @@ async fn sql_directory() {
// Ids by email
assert_eq!(
core.email_to_ids(&handle, "jane@example.org")
core.email_to_ids(&handle, "jane@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["jane"]).await
);
assert_eq!(
core.email_to_ids(&handle, "info@example.org")
core.email_to_ids(&handle, "info@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["bill", "jane", "john"]).await
);
assert_eq!(
core.email_to_ids(&handle, "jane+alias@example.org")
core.email_to_ids(&handle, "jane+alias@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["jane"]).await
);
assert_eq!(
core.email_to_ids(&handle, "info+alias@example.org")
core.email_to_ids(&handle, "info+alias@example.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["bill", "jane", "john"]).await
);
assert_eq!(
core.email_to_ids(&handle, "unknown@example.org")
core.email_to_ids(&handle, "unknown@example.org", 0)
.await
.unwrap(),
Vec::<u32>::new()
);
assert_eq!(
core.email_to_ids(&handle, "anything@catchall.org")
core.email_to_ids(&handle, "anything@catchall.org", 0)
.await
.unwrap(),
map_account_ids(base_store, vec!["robert"]).await
@@ -241,41 +241,47 @@ async fn sql_directory() {
assert!(!handle.is_local_domain("other.org").await.unwrap());
// RCPT TO
assert!(core.rcpt(&handle, "jane@example.org").await.unwrap());
assert!(core.rcpt(&handle, "info@example.org").await.unwrap());
assert!(core.rcpt(&handle, "jane+alias@example.org").await.unwrap());
assert!(core.rcpt(&handle, "info+alias@example.org").await.unwrap());
assert!(core.rcpt(&handle, "jane@example.org", 0).await.unwrap());
assert!(core.rcpt(&handle, "info@example.org", 0).await.unwrap());
assert!(core
.rcpt(&handle, "random_user@catchall.org")
.rcpt(&handle, "jane+alias@example.org", 0)
.await
.unwrap());
assert!(!core.rcpt(&handle, "invalid@example.org").await.unwrap());
assert!(core
.rcpt(&handle, "info+alias@example.org", 0)
.await
.unwrap());
assert!(core
.rcpt(&handle, "random_user@catchall.org", 0)
.await
.unwrap());
assert!(!core.rcpt(&handle, "invalid@example.org", 0).await.unwrap());
// VRFY
assert_eq!(
core.vrfy(&handle, "jane").await.unwrap(),
core.vrfy(&handle, "jane", 0).await.unwrap(),
vec!["jane@example.org".to_string()]
);
assert_eq!(
core.vrfy(&handle, "john").await.unwrap(),
core.vrfy(&handle, "john", 0).await.unwrap(),
vec!["john@example.org".to_string()]
);
assert_eq!(
core.vrfy(&handle, "jane+alias@example").await.unwrap(),
core.vrfy(&handle, "jane+alias@example", 0).await.unwrap(),
vec!["jane@example.org".to_string()]
);
assert_eq!(
core.vrfy(&handle, "info").await.unwrap(),
core.vrfy(&handle, "info", 0).await.unwrap(),
Vec::<String>::new()
);
assert_eq!(
core.vrfy(&handle, "invalid").await.unwrap(),
core.vrfy(&handle, "invalid", 0).await.unwrap(),
Vec::<String>::new()
);
// EXPN
assert_eq!(
core.expn(&handle, "info@example.org").await.unwrap(),
core.expn(&handle, "info@example.org", 0).await.unwrap(),
vec![
"bill@example.org".to_string(),
"jane@example.org".to_string(),
@@ -283,7 +289,7 @@ async fn sql_directory() {
]
);
assert_eq!(
core.expn(&handle, "john@example.org").await.unwrap(),
core.expn(&handle, "john@example.org", 0).await.unwrap(),
Vec::<String>::new()
);
}