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.
120 lines
3.5 KiB
Rust
120 lines
3.5 KiB
Rust
/*
|
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
|
*/
|
|
|
|
use crate::{
|
|
smtp::session::{TestSession, VerifyResponse},
|
|
utils::server::TestServerBuilder,
|
|
};
|
|
use registry::{
|
|
schema::structs::{Expression, ExpressionMatch, MailingList, MtaExtensions},
|
|
types::{list::List, map::Map},
|
|
};
|
|
|
|
#[tokio::test]
|
|
async fn vrfy_expn() {
|
|
let mut test = TestServerBuilder::new("smtp_vrfy_test")
|
|
.await
|
|
.with_http_listener(19006)
|
|
.await
|
|
.disable_services()
|
|
.build()
|
|
.await;
|
|
|
|
// Create test users
|
|
let admin = test.account("admin");
|
|
for (name, secret, description, aliases) in [
|
|
("[email protected]", "12345 + extra safety", "John Doe", &[]),
|
|
("[email protected]", "abcde + extra safety", "Jane Smith", &[]),
|
|
(
|
|
"[email protected]",
|
|
"p4ssw0rd + extra safety",
|
|
"Bill Foobar",
|
|
&[],
|
|
),
|
|
] {
|
|
admin
|
|
.create_user_account(name, secret, description, aliases, vec![])
|
|
.await;
|
|
}
|
|
let domain_id = admin.find_or_create_domain("foobar.org").await;
|
|
admin
|
|
.registry_create_object(MailingList {
|
|
domain_id,
|
|
name: "sales".into(),
|
|
recipients: Map::new(vec![
|
|
"[email protected]".into(),
|
|
"[email protected]".into(),
|
|
"[email protected]".into(),
|
|
]),
|
|
..Default::default()
|
|
})
|
|
.await;
|
|
|
|
// Add test settings
|
|
admin.mta_no_auth().await;
|
|
admin
|
|
.registry_create_object(MtaExtensions {
|
|
vrfy: Expression {
|
|
match_: List::from_iter([ExpressionMatch {
|
|
if_: "remote_ip = '10.0.0.1'".into(),
|
|
then: "true".into(),
|
|
}]),
|
|
else_: "false".into(),
|
|
},
|
|
expn: Expression {
|
|
match_: List::from_iter([ExpressionMatch {
|
|
if_: "remote_ip = '10.0.0.1'".into(),
|
|
then: "true".into(),
|
|
}]),
|
|
else_: "false".into(),
|
|
},
|
|
..Default::default()
|
|
})
|
|
.await;
|
|
admin.reload_settings().await;
|
|
test.reload_core();
|
|
|
|
// EHLO should not advertise VRFY/EXPN to 10.0.0.2
|
|
let mut session = test.new_mta_session();
|
|
session.data.remote_ip_str = "10.0.0.2".into();
|
|
session.eval_session_params().await;
|
|
session
|
|
.ehlo("mx.foobar.org")
|
|
.await
|
|
.assert_not_contains("EXPN")
|
|
.assert_not_contains("VRFY");
|
|
session.cmd("VRFY [email protected]", "252 2.5.1").await;
|
|
session.cmd("EXPN [email protected]", "252 2.5.1").await;
|
|
|
|
// EHLO should advertise VRFY/EXPN for 10.0.0.1
|
|
session.data.remote_ip_str = "10.0.0.1".into();
|
|
session.eval_session_params().await;
|
|
session
|
|
.ehlo("mx.foobar.org")
|
|
.await
|
|
.assert_contains("EXPN")
|
|
.assert_contains("VRFY");
|
|
|
|
// Successful VRFY
|
|
session
|
|
.cmd("VRFY [email protected]", "250 [email protected]")
|
|
.await;
|
|
|
|
// Successful EXPN
|
|
session
|
|
.cmd("EXPN [email protected]", "250")
|
|
.await
|
|
.assert_contains("[email protected]")
|
|
.assert_contains("[email protected]")
|
|
.assert_contains("250 [email protected]");
|
|
|
|
// Non-existent VRFY
|
|
session.cmd("VRFY robert", "550 5.1.2").await;
|
|
|
|
// Non-existent EXPN
|
|
session.cmd("EXPN procurement", "550 5.1.2").await;
|
|
}
|