Import upstream v0.16.22, stripped

Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f
Enterprise-only files removed or emptied: 63
Enterprise-only snippets removed: 117 in 50 files
Dangling module declarations removed: 5
Cargo edits turning enterprise off: 14
Verification: clean
Enterprise feature gates left for rebuilt features: 19 in 18 files

Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
2026-09-18 10:21:56 -07:00
commit 7dae9b29fd
1650 changed files with 485521 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*/
use super::{AssertResult, ImapConnection, Type};
use directory::Credentials;
use imap_proto::ResponseType;
use mail_parser::decoders::base64::base64_decode;
pub async fn test(imap: &mut ImapConnection, _imap_check: &mut ImapConnection) {
println!("Running basic tests...");
// Test OAuth Bearer decoding
assert_eq!(
Credentials::Bearer {
token: "vF9dft4qmTc2Nvb3RlckBhbHRhdmlzdGEuY29tCg==".to_string(),
username: Some("[email protected]".to_string()),
},
Credentials::decode_sasl_challenge_oauth(
&base64_decode(
concat!(
"bixhPXVzZXJAZXhhbXBsZS5jb20sAWhv",
"c3Q9c2VydmVyLmV4YW1wbGUuY29tAXBvcnQ9MTQzAWF1dGg9QmVhcmVyI",
"HZGOWRmdDRxbVRjMk52YjNSbGNrQmhiSFJoZG1semRHRXVZMjl0Q2c9PQ",
"EB"
)
.as_bytes(),
)
.unwrap(),
)
.unwrap()
);
// Test CAPABILITY
imap.send("CAPABILITY").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Test NOOP
imap.send("NOOP").await;
imap.assert_read(Type::Tagged, ResponseType::Ok).await;
// Test ID
imap.send("ID").await;
imap.assert_read(Type::Tagged, ResponseType::Ok)
.await
.assert_contains("* ID (\"name\" \"Stalwart\" \"version\" ");
// Login should be disabled
imap.send("LOGIN [email protected] secret").await;
imap.assert_read(Type::Tagged, ResponseType::No).await;
// Try logging in with wrong password
imap.send("AUTHENTICATE PLAIN {24}").await;
imap.assert_read(Type::Continuation, ResponseType::Ok).await;
imap.send_untagged("AGJvYXR5AG1jYm9hdGZhY2U=").await;
imap.assert_read(Type::Tagged, ResponseType::No).await;
}