Skip to content

Commit

Permalink
Added mail.ru example report
Browse files Browse the repository at this point in the history
  • Loading branch information
cry-inc committed Jul 22, 2024
1 parent 4aa9f96 commit 516fdf8
Showing 2 changed files with 54 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/dmarc_report.rs
Original file line number Diff line number Diff line change
@@ -177,6 +177,59 @@ mod tests {
use super::*;
use std::fs::File;

#[test]
fn mailru_report() {
let reader = File::open("testdata/dmarc-reports/mailru.xml").unwrap();
let report: Report = serde_xml_rs::from_reader(reader).unwrap();

// Check metadata
assert_eq!(report.report_metadata.org_name, "Mail.Ru");
assert_eq!(report.report_metadata.email, "dmarc_support@corp.mail.ru");
assert_eq!(
report.report_metadata.extra_contact_info.as_deref(),
Some("http://help.mail.ru/mail-help")
);
assert_eq!(
report.report_metadata.report_id,
"28327321193681154911721360800"
);
assert_eq!(report.report_metadata.date_range.begin, 1721260800);
assert_eq!(report.report_metadata.date_range.end, 1721347200);

// Check policy
assert_eq!(report.policy_published.domain, "foobar.de");
assert_eq!(report.policy_published.adkim, Some(AlignmentType::Relaxed));
assert_eq!(report.policy_published.aspf, Some(AlignmentType::Relaxed));
assert_eq!(report.policy_published.p, DispositionType::Reject);
assert_eq!(report.policy_published.sp, Some(DispositionType::Reject));
assert_eq!(report.policy_published.pct, 100);

// Check record
assert_eq!(report.record.len(), 1);
let record = report.record.first().unwrap();
assert_eq!(record.row.source_ip.to_string(), "118.41.204.2");
assert_eq!(record.row.count, 1);
assert_eq!(
record.row.policy_evaluated.disposition,
DispositionType::Reject
);
assert_eq!(
record.row.policy_evaluated.dkim,
Some(DmarcResultType::Fail)
);
assert_eq!(record.row.policy_evaluated.spf, Some(DmarcResultType::Fail));
assert_eq!(record.identifiers.header_from, "foobar.de");
assert_eq!(record.auth_results.dkim, None);
assert_eq!(
record.auth_results.spf,
vec![SpfAuthResultType {
domain: String::from("foobar.de"),
scope: Some(SpfDomainScope::MailForm),
result: SpfResultType::SoftFail,
}]
);
}

#[test]
fn aol_report() {
let reader = File::open("testdata/dmarc-reports/aol.xml").unwrap();
1 change: 1 addition & 0 deletions testdata/dmarc-reports/mailru.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version='1.0' encoding='utf-8'?><feedback><report_metadata><org_name>Mail.Ru</org_name><email>dmarc_support@corp.mail.ru</email><extra_contact_info>http://help.mail.ru/mail-help</extra_contact_info><report_id>28327321193681154911721360800</report_id><date_range><begin>1721260800</begin><end>1721347200</end></date_range></report_metadata><policy_published><domain>foobar.de</domain><adkim>r</adkim><aspf>r</aspf><p>reject</p><sp>reject</sp><pct>100</pct></policy_published><record><row><source_ip>118.41.204.2</source_ip><count>1</count><policy_evaluated><disposition>reject</disposition><dkim>fail</dkim><spf>fail</spf></policy_evaluated></row><identifiers><header_from>foobar.de</header_from></identifiers><auth_results><spf><domain>foobar.de</domain><scope>mfrom</scope><result>softfail</result></spf></auth_results></record></feedback>

0 comments on commit 516fdf8

Please sign in to comment.