diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-20 19:23:44 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-20 19:23:44 +0100 |
commit | 9c3f44748051ce15607af3470e5d4d29abaecc37 (patch) | |
tree | 4b2212067a731ae0650196ff6c13b7671167d119 /tests/behavior.rs | |
parent | 9ae5701c7c6d17c72f27f1413ee2fd3d939428a3 (diff) | |
download | aerogramme-9c3f44748051ce15607af3470e5d4d29abaecc37.tar.gz aerogramme-9c3f44748051ce15607af3470e5d4d29abaecc37.zip |
Test LIST-STATUS
Diffstat (limited to 'tests/behavior.rs')
-rw-r--r-- | tests/behavior.rs | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/tests/behavior.rs b/tests/behavior.rs index 0447d80..7fdd553 100644 --- a/tests/behavior.rs +++ b/tests/behavior.rs @@ -6,13 +6,14 @@ use crate::common::fragments::*; fn main() { rfc3501_imap4rev1_base(); - rfc3691_imapext_unselect(); - rfc5161_imapext_enable(); rfc6851_imapext_move(); - rfc7888_imapext_literal(); rfc4551_imapext_condstore(); rfc2177_imapext_idle(); - rfc4315_imapext_uidplus(); + rfc5161_imapext_enable(); // 1 + rfc3691_imapext_unselect(); // 2 + rfc7888_imapext_literal(); // 3 + rfc4315_imapext_uidplus(); // 4 + rfc5819_imapext_liststatus(); // 5 println!("โ
SUCCESS ๐๐๐ฅณ๐๐ฅน"); } @@ -307,3 +308,50 @@ fn rfc4315_imapext_uidplus() { }) .expect("test fully run"); } + +/// +/// Example +/// +/// ```text +/// 30 list "" "*" RETURN (STATUS (MESSAGES UNSEEN)) +/// * LIST (\Subscribed) "." INBOX +/// * STATUS INBOX (MESSAGES 2 UNSEEN 1) +/// 30 OK LIST completed +/// ``` +fn rfc5819_imapext_liststatus() { + println!("๐งช rfc5819_imapext_liststatus"); + common::aerogramme_provider_daemon_dev(|imap_socket, lmtp_socket| { + // Test setup, check capability, add 2 emails, read 1 + connect(imap_socket).context("server says hello")?; + capability(imap_socket, Extension::ListStatus).context("check server capabilities")?; + login(imap_socket, Account::Alice).context("login test")?; + select(imap_socket, Mailbox::Inbox, SelectMod::None).context("select inbox")?; + lmtp_handshake(lmtp_socket).context("handshake lmtp done")?; + lmtp_deliver_email(lmtp_socket, Email::Basic).context("mail delivered successfully")?; + lmtp_deliver_email(lmtp_socket, Email::Multipart).context("mail delivered successfully")?; + noop_exists(imap_socket, 2).context("noop loop must detect a new email")?; + fetch( + imap_socket, + Selection::FirstId, + FetchKind::Rfc822, + FetchMod::None, + ) + .context("read one message")?; + close(imap_socket).context("close inbox")?; + + // Test return status MESSAGES UNSEEN + let ret = list( + imap_socket, + MbxSelect::All, + ListReturn::StatusMessagesUnseen, + )?; + assert!(ret.contains("* STATUS INBOX (MESSAGES 2 UNSEEN 1)")); + + // Test that without RETURN, no status is sent + let ret = list(imap_socket, MbxSelect::All, ListReturn::None)?; + assert!(!ret.contains("* STATUS")); + + Ok(()) + }) + .expect("test fully run"); +} |