Commit
Author: Mauro D [mauro@stalw.art]
Hash: 94149fa5472c28cd7f965d8ee7c5c16cecf59674
Timestamp: Mon, 09 Jan 2023 16:15:03 +0000 (1 year ago)

+8 -8 +/-2 browse
Fixed SPF tests
1diff --git a/src/common/auth_results.rs b/src/common/auth_results.rs
2index 7e139c8..6939b28 100644
3--- a/src/common/auth_results.rs
4+++ b/src/common/auth_results.rs
5 @@ -83,11 +83,12 @@ impl<'x> AuthenticationResults<'x> {
6 spf: &SpfOutput,
7 ip_addr: IpAddr,
8 from: &str,
9+ ehlo_domain: &str,
10 ) -> Self {
11 let (mail_from, addr) = if !from.is_empty() {
12 (Cow::from(from), from)
13 } else {
14- (format!("postmaster@{}", from).into(), "<>")
15+ (format!("postmaster@{}", ehlo_domain).into(), "<>")
16 };
17 self.auth_results.push_str(";\r\n\tspf=");
18 spf.result.as_spf_result(
19 @@ -419,7 +420,7 @@ mod test {
20 (
21 concat!(
22 "spf=pass (localhost: domain of jdoe@example.org designates 192.168.1.1 ",
23- "as permitted sender) smtp.mailfrom=jdoe@example.org smtp.helo=example.org"
24+ "as permitted sender) smtp.mailfrom=jdoe@example.org"
25 ),
26 concat!(
27 "pass (localhost: domain of jdoe@example.org designates 192.168.1.1 as ",
28 @@ -435,8 +436,7 @@ mod test {
29 (
30 concat!(
31 "spf=fail (mx.domain.org: domain of sender@otherdomain.org does not ",
32- "designate a:b:c::f as permitted sender) smtp.mailfrom=sender@otherdomain.org ",
33- "smtp.helo=otherdomain.org"
34+ "designate a:b:c::f as permitted sender) smtp.mailfrom=sender@otherdomain.org"
35 ),
36 concat!(
37 "fail (mx.domain.org: domain of sender@otherdomain.org does not designate ",
38 @@ -453,7 +453,7 @@ mod test {
39 (
40 concat!(
41 "spf=neutral (mx.domain.org: domain of postmaster@example.org reports neutral ",
42- "for a:b:c::f) smtp.mailfrom=postmaster@example.org smtp.helo=example.org"
43+ "for a:b:c::f) smtp.mailfrom=<>"
44 ),
45 concat!(
46 "neutral (mx.domain.org: domain of postmaster@example.org reports neutral for ",
47 @@ -468,7 +468,7 @@ mod test {
48 ),
49 ] {
50 auth_results.hostname = receiver;
51- auth_results = auth_results.with_spf_result(
52+ auth_results = auth_results.with_spf_mailfrom_result(
53 &SpfOutput {
54 result,
55 domain: "".to_string(),
56 @@ -476,8 +476,8 @@ mod test {
57 explanation: None,
58 },
59 ip_addr,
60- helo,
61 mail_from,
62+ helo,
63 );
64 let received_spf = ReceivedSpf::new(
65 &SpfOutput {
66 diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs
67index 0cea162..ca2f0af 100644
68--- a/src/dkim/sign.rs
69+++ b/src/dkim/sign.rs
70 @@ -46,7 +46,7 @@ impl<T: SigningKey> DkimSigner<T, Done> {
71
72 // Create Signature
73 let mut signature = self.template.clone();
74- signature.bh = base64_encode(&body_hasher.complete().as_ref())?;
75+ signature.bh = base64_encode(body_hasher.complete().as_ref())?;
76 signature.t = now;
77 signature.x = if signature.x > 0 {
78 now + signature.x