aerogramme/tests/rfc3501_imap4rev1_base.rs

34 lines
1.9 KiB
Rust
Raw Normal View History

2024-01-04 10:23:26 +00:00
use anyhow::Context;
2023-12-28 15:37:38 +00:00
2024-01-03 08:47:52 +00:00
mod common;
2024-01-04 10:23:26 +00:00
use crate::common::fragments::*;
2024-01-02 22:42:47 +00:00
2023-12-28 15:37:38 +00:00
fn main() {
2024-01-03 08:47:52 +00:00
common::aerogramme_provider_daemon_dev(|imap_socket, lmtp_socket| {
connect(imap_socket).context("server says hello")?;
2024-01-04 10:23:26 +00:00
capability(imap_socket, Extension::None).context("check server capabilities")?;
login(imap_socket, Account::Alice).context("login test")?;
create_mailbox(imap_socket, Mailbox::Archive).context("created mailbox archive")?;
2024-01-03 08:47:52 +00:00
// UNSUBSCRIBE IS NOT IMPLEMENTED YET
//unsubscribe_mailbox(imap_socket).context("unsubscribe from archive")?;
2024-01-04 10:23:26 +00:00
select(imap_socket, Mailbox::Inbox, None).context("select inbox")?;
2024-01-03 08:47:52 +00:00
check(imap_socket).context("check must run")?;
2024-01-04 10:23:26 +00:00
status_mailbox(imap_socket, Mailbox::Archive).context("status of archive from inbox")?;
2024-01-03 08:47:52 +00:00
lmtp_handshake(lmtp_socket).context("handshake lmtp done")?;
2024-01-04 10:23:26 +00:00
lmtp_deliver_email(lmtp_socket, Email::Multipart).context("mail delivered successfully")?;
2024-01-03 08:47:52 +00:00
noop_exists(imap_socket).context("noop loop must detect a new email")?;
2024-01-04 10:23:26 +00:00
fetch_rfc822(imap_socket, Selection::FirstId, Email::Multipart).context("fetch rfc822 message, should be our first message")?;
copy(imap_socket, Selection::FirstId, Mailbox::Archive).context("copy message to the archive mailbox")?;
append_email(imap_socket, Email::Basic).context("insert email in INBOX")?;
2024-01-03 08:47:52 +00:00
// SEARCH IS NOT IMPLEMENTED YET
//search(imap_socket).expect("search should return something");
2024-01-04 10:23:26 +00:00
add_flags_email(imap_socket, Selection::FirstId, Flag::Deleted)
.context("should add delete flag to the email")?;
2024-01-03 08:47:52 +00:00
expunge(imap_socket).context("expunge emails")?;
2024-01-04 10:23:26 +00:00
rename_mailbox(imap_socket, Mailbox::Archive, Mailbox::Drafts).context("Archive mailbox is renamed Drafts")?;
delete_mailbox(imap_socket, Mailbox::Drafts).context("Drafts mailbox is deleted")?;
2024-01-03 08:47:52 +00:00
Ok(())
2024-01-03 09:28:10 +00:00
})
.expect("test fully run");
2023-12-29 16:16:41 +00:00
}