Compare commits

..

No commits in common. "append_test" and "main" have entirely different histories.

4 changed files with 7 additions and 69 deletions

View file

@ -1,41 +1,21 @@
use miette::{IntoDiagnostic, Result};
use imap_codec::types::command::CommandBody;
use tracing::info;
use boitalettres::proto::{Request, Response};
use boitalettres::server::accept::addr::{AddrIncoming, AddrStream};
use boitalettres::server::Server;
async fn handle_req(req: Request) -> Result<Response> {
async fn handle_req(_req: Request) -> Result<Response> {
use imap_codec::types::response::{Capability, Data as ImapData};
use boitalettres::proto::res::{body::Data, Status};
info!("Handling request: {:?}", req);
let capabilities = vec![Capability::Imap4Rev1, Capability::Idle];
let body: Vec<Data> = vec![
Status::ok("Yeah")?.into(),
ImapData::Capability(capabilities).into(),
];
match req.command.body {
CommandBody::Noop => Ok(Response::ok("NOOP done")?),
CommandBody::Capability => {
let capabilities = vec![Capability::Imap4Rev1, Capability::Idle];
let body: Vec<Data> = vec![
Status::ok("Yeah")?.into(),
ImapData::Capability(capabilities).into(),
];
Ok(Response::ok("CAPABILITY done")?.with_body(body))
}
CommandBody::Login { .. } => Ok(Response::ok("Faking successfull LOGIN")?),
CommandBody::Append { .. } => Ok(Response::ok("Faking successfull APPEND")?),
CommandBody::Logout { .. } => {
let body: Vec<Data> = vec![Status::bye("Logging out")?.into()];
Ok(Response::ok("LOGOUT completed")?
.with_body(body)
.close(true))
}
_ => Ok(Response::no("unavailable command")?),
}
Ok(Response::ok("Done")?.with_body(body))
}
#[tokio::main]

18
scripts/test_imap.py Executable file → Normal file
View file

@ -2,24 +2,6 @@
from imaplib import IMAP4
conn = IMAP4('127.0.0.1', port=4567)
print("Connected")
conn.noop()
print("NOOP done")
conn.login("lx", "plop")
print("Logged in")
print("Testing APPEND (this uses continuation style)")
conn.append("INBOX", [], None,
b"""From: alex@adnab.me
To: lx@deuxfleurs.fr
Subject: Hello, world!
Test
.
""")
print("Append done")
conn.logout()
print("Logged out")

View file

@ -1,23 +0,0 @@
#!/bin/sh
# APPEND example from RFC9051
nc localhost 4567 <<EOF
A CAPABILITY
B LOGIN lx plop
C APPEND saved-messages (\\Seen) {297+}
Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@example.com>
Subject: afternoon meeting
To: mooch@example.com
Message-Id: <B27397-0100000@example.com>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Hello Joe, do you think we can meet at 3:30 tomorrow?
D NOOP
E LOGOUT
EOF
echo "^ expected output: responses to A B C D and E, last one is E OK LOGOUT completed"

View file

@ -1 +0,0 @@