Files
inbuxa-server/crates/managesieve/src/lib.rs
T
jcoffey-dev 0755fad51e Scale-out storage: IMAP CONDSTORE raises the mark, and the two-node check (ST-7, test 11)
A FETCH with CHANGEDSINCE presents its mod-sequence to the read scope, so
a replica must have that change before it answers, as a JMAP sinceState
already did. replica_cluster_tests covers test 11: with the replica's
replay paused, a write on one node is read back through a second store
with its own marks, sharing through Redis.

Composite stores nest store futures deeply enough to pass rustc's default
query depth once both postgres and redis are compiled in, so the server
crates raise their recursion limit.
2026-09-19 14:59:46 -07:00

149 lines
5.0 KiB
Rust

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
// inbuxa: composite stores (sharded members, read replicas) nest store
// futures deeply enough to pass rustc's default query depth
#![recursion_limit = "512"]
#![warn(clippy::large_futures)]
pub mod core;
pub mod op;
static SERVER_GREETING: &str = concat!(types::brand!(), " ManageSieve at your service.");
#[cfg(test)]
mod tests {
use imap_proto::receiver::{Error, Receiver, Request, State, Token};
use crate::core::Command;
#[test]
fn receiver_parse_managesieve() {
let mut receiver = Receiver::new().with_start_state(State::Command { is_uid: false });
for (frames, expected_requests) in [
(
vec!["Authenticate \"DIGEST-MD5\"\r\n"],
vec![Request {
tag: "".into(),
command: Command::Authenticate,
tokens: vec![Token::Argument(b"DIGEST-MD5".to_vec())],
}],
),
(
vec![
" AUTHENTICATE \"GSSAPI\" {56+}\r\n",
"cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==\r\n",
],
vec![Request {
tag: "".into(),
command: Command::Authenticate,
tokens: vec![
Token::Argument(b"GSSAPI".to_vec()),
Token::Argument(
b"cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==".to_vec(),
),
],
}],
),
(
vec!["Authenticate \"PLAIN\" \"QJIrweAPyo6Q1T9xu\"\r\n"],
vec![Request {
tag: "".into(),
command: Command::Authenticate,
tokens: vec![
Token::Argument(b"PLAIN".to_vec()),
Token::Argument(b"QJIrweAPyo6Q1T9xu".to_vec()),
],
}],
),
(
vec!["StartTls\r\n"],
vec![Request {
tag: "".into(),
command: Command::StartTls,
tokens: vec![],
}],
),
(
vec!["HAVESPACE \"myscript\" 999999\r\n"],
vec![Request {
tag: "".into(),
command: Command::HaveSpace,
tokens: vec![
Token::Argument(b"myscript".to_vec()),
Token::Argument(b"999999".to_vec()),
],
}],
),
(
vec![
"Putscript \"foo\" {31+}\r\n",
"#comment\r\n",
"InvalidSieveCommand\r\n\r\n",
],
vec![Request {
tag: "".into(),
command: Command::PutScript,
tokens: vec![
Token::Argument(b"foo".to_vec()),
Token::Argument(b"#comment\r\nInvalidSieveCommand\r\n".to_vec()),
],
}],
),
(
vec!["Listscripts\r\n"],
vec![Request {
tag: "".into(),
command: Command::ListScripts,
tokens: vec![],
}],
),
(
vec!["Setactive \"baz\"\r\n"],
vec![Request {
tag: "".into(),
command: Command::SetActive,
tokens: vec![Token::Argument(b"baz".to_vec())],
}],
),
(
vec!["Renamescript \"foo\" \"bar\"\r\n"],
vec![Request {
tag: "".into(),
command: Command::RenameScript,
tokens: vec![
Token::Argument(b"foo".to_vec()),
Token::Argument(b"bar".to_vec()),
],
}],
),
(
vec!["NOOP \"STARTTLS-SYNC-42\"\r\n"],
vec![Request {
tag: "".into(),
command: Command::Noop,
tokens: vec![Token::Argument(b"STARTTLS-SYNC-42".to_vec())],
}],
),
] {
let mut requests = Vec::new();
for frame in &frames {
let mut bytes = frame.as_bytes().iter();
loop {
match receiver.parse(&mut bytes) {
Ok(request) => requests.push(request),
Err(Error::NeedsMoreData | Error::NeedsLiteral { .. }) => break,
Err(err) => panic!("{:?} for frames {:#?}", err, frames),
}
}
}
assert_eq!(requests, expected_requests, "{:#?}", frames);
}
}
}