aboutsummaryrefslogtreecommitdiff
path: root/tests/common/fragments.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2024-01-20 18:24:05 +0000
committerQuentin <quentin@dufour.io>2024-01-20 18:24:05 +0000
commit49ff733a30b721f0cdd981e9af4d8964546fc77f (patch)
tree4b2212067a731ae0650196ff6c13b7671167d119 /tests/common/fragments.rs
parent4849d776b4321b463dfda0112ceb52e3c66fc4dc (diff)
parent9c3f44748051ce15607af3470e5d4d29abaecc37 (diff)
downloadaerogramme-49ff733a30b721f0cdd981e9af4d8964546fc77f.tar.gz
aerogramme-49ff733a30b721f0cdd981e9af4d8964546fc77f.zip
Merge pull request 'Implement `LIST X Y RETURN (STATUS (UIDNEXT ...))`' (#75) from feat/list-status into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/75
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];