diff options
Diffstat (limited to 'tests/common/fragments.rs')
-rw-r--r-- | tests/common/fragments.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/common/fragments.rs b/tests/common/fragments.rs index 147c8f0..a10d4e0 100644 --- a/tests/common/fragments.rs +++ b/tests/common/fragments.rs @@ -38,6 +38,7 @@ pub enum Extension { LiteralPlus, Idle, UidPlus, + ListStatus, } pub enum Enable { @@ -107,6 +108,15 @@ pub enum StatusKind { HighestModSeq, } +pub enum MbxSelect { + All, +} + +pub enum ListReturn { + None, + StatusMessagesUnseen, +} + pub fn capability(imap: &mut TcpStream, ext: Extension) -> Result<()> { imap.write(&b"5 capability\r\n"[..])?; @@ -118,6 +128,7 @@ pub fn capability(imap: &mut TcpStream, ext: Extension) -> Result<()> { Extension::LiteralPlus => Some("LITERAL+"), Extension::Idle => Some("IDLE"), Extension::UidPlus => Some("UIDPLUS"), + Extension::ListStatus => Some("LIST-STATUS"), }; let mut buffer: [u8; 6000] = [0; 6000]; @@ -169,6 +180,25 @@ pub fn create_mailbox(imap: &mut TcpStream, mbx: Mailbox) -> Result<()> { Ok(()) } +pub fn list(imap: &mut TcpStream, select: MbxSelect, mod_return: ListReturn) -> Result<String> { + let mut buffer: [u8; 6000] = [0; 6000]; + + let select_str = match select { + MbxSelect::All => "%", + }; + + let mod_return_str = match mod_return { + ListReturn::None => "", + ListReturn::StatusMessagesUnseen => " RETURN (STATUS (MESSAGES UNSEEN))", + }; + + imap.write(format!("19 LIST \"\" \"{}\"{}\r\n", select_str, mod_return_str).as_bytes())?; + + let read = read_lines(imap, &mut buffer, Some(&b"19 OK"[..]))?; + let srv_msg = std::str::from_utf8(read)?; + Ok(srv_msg.to_string()) +} + pub fn select(imap: &mut TcpStream, mbx: Mailbox, modifier: SelectMod) -> Result<String> { let mut buffer: [u8; 6000] = [0; 6000]; |