aboutsummaryrefslogtreecommitdiff
path: root/tests/common/fragments.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-20 19:23:44 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-20 19:23:44 +0100
commit9c3f44748051ce15607af3470e5d4d29abaecc37 (patch)
tree4b2212067a731ae0650196ff6c13b7671167d119 /tests/common/fragments.rs
parent9ae5701c7c6d17c72f27f1413ee2fd3d939428a3 (diff)
downloadaerogramme-9c3f44748051ce15607af3470e5d4d29abaecc37.tar.gz
aerogramme-9c3f44748051ce15607af3470e5d4d29abaecc37.zip
Test LIST-STATUS
Diffstat (limited to 'tests/common/fragments.rs')
-rw-r--r--tests/common/fragments.rs30
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];