CardDAV: Added 'card is ham' test

This commit is contained in:
mdecimus
2025-09-30 10:54:01 +02:00
parent 93a8265b98
commit d00d3dd013
3 changed files with 75 additions and 9 deletions

View File

@@ -8,11 +8,13 @@ use super::JMAPTest;
use crate::{
directory::internal::TestInternalDirectory,
jmap::{assert_is_empty, mailbox::destroy_all_mailboxes},
webdav::DummyWebDavClient,
};
use email::{
cache::{MessageCacheFetch, email::MessageCacheAccess},
mailbox::{INBOX_ID, JUNK_ID},
};
use groupware::DavResourceName;
use std::{str::FromStr, time::Duration};
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines, ReadHalf, WriteHalf},
@@ -139,6 +141,56 @@ pub async fn test(params: &mut JMAPTest) {
assert_eq!(john_cache.in_mailbox(INBOX_ID).count(), 1);
assert_eq!(john_cache.in_mailbox(JUNK_ID).count(), 1);
// CardDAV spam override
let dav_client =
DummyWebDavClient::new(u32::MAX, "jdoe@example.com", "12345", "jdoe@example.com");
dav_client
.request(
"PUT",
&format!(
"{}/jdoe%40example.com/default/bill.vcf",
DavResourceName::Card.base_path()
),
r#"BEGIN:VCARD
VERSION:4.0
FN:Bill Foobar
EMAIL;TYPE=WORK:dmarc-bill@example.com
UID:urn:uuid:e1ee798b-3d4c-41b0-b217-b9c918e4686f
END:VCARD
"#,
)
.await
.with_status(hyper::StatusCode::CREATED);
lmtp.ingest(
"dmarc-bill@example.com",
&["john.doe@example.com"],
concat!(
"From: dmarc-bill@example.com\r\n",
"To: john.doe@example.com\r\n",
"Subject: Fwd: TPS Report (CardDAV spam override)\r\n",
"X-Spam-Status: Yes, score=13.9\r\n",
"\r\n",
"--- Forwarded Message ---\r\n\r\n ",
"I'm going to need those TPS reports ASAP. ",
"So, if you could do that, that'd be great."
),
)
.await;
let john_cache = server.get_cached_messages(john_id).await.unwrap();
assert_eq!(
server
.get_document_ids(john_id, Collection::Email)
.await
.unwrap()
.unwrap()
.len(),
3
);
assert_eq!(john_cache.in_mailbox(INBOX_ID).count(), 2);
assert_eq!(john_cache.in_mailbox(JUNK_ID).count(), 1);
dav_client.delete_default_containers().await;
// EXPN and VRFY
lmtp.expn("members@example.com", 2)
.await
@@ -166,7 +218,7 @@ pub async fn test(params: &mut JMAPTest) {
)
.await;
for (account_id, num_messages) in [(&account_id_1, 3), (&account_id_2, 1), (&account_id_3, 1)] {
for (account_id, num_messages) in [(&account_id_1, 4), (&account_id_2, 1), (&account_id_3, 1)] {
assert_eq!(
server
.get_document_ids(
@@ -206,7 +258,7 @@ pub async fn test(params: &mut JMAPTest) {
)
.await;
for (account_id, num_messages) in [(&account_id_1, 3), (&account_id_2, 2), (&account_id_3, 2)] {
for (account_id, num_messages) in [(&account_id_1, 4), (&account_id_2, 2), (&account_id_3, 2)] {
assert_eq!(
server
.get_document_ids(
@@ -244,7 +296,7 @@ pub async fn test(params: &mut JMAPTest) {
)
.await;
for (account_id, num_messages) in [(&account_id_1, 4), (&account_id_2, 3), (&account_id_3, 3)] {
for (account_id, num_messages) in [(&account_id_1, 5), (&account_id_2, 3), (&account_id_3, 3)] {
assert_eq!(
server
.get_document_ids(

View File

@@ -88,8 +88,8 @@ async fn jmap_tests() {
.await;
webhooks::test(&mut params).await;
//email_query::test(&mut params, delete).await;
//email_get::test(&mut params).await;
/*email_query::test(&mut params, delete).await;
email_get::test(&mut params).await;
email_set::test(&mut params).await;
email_parse::test(&mut params).await;
email_search_snippet::test(&mut params).await;
@@ -98,7 +98,7 @@ async fn jmap_tests() {
email_copy::test(&mut params).await;
thread_get::test(&mut params).await;
thread_merge::test(&mut params).await;
mailbox::test(&mut params).await;
mailbox::test(&mut params).await;*/
delivery::test(&mut params).await;
auth_acl::test(&mut params).await;
auth_limits::test(&mut params).await;
@@ -979,6 +979,9 @@ WiYrLO4z8/kmkqvA7wGElBok9IqhRANCAAQxZK68FnQtHC0eyh8CA05xRIvxhVHn
'''
signature-algorithm = "ES256"
[spam-filter.bayes.auto-learn]
card-is-ham = false
[session.extensions]
expn = true
vrfy = true