Fix the antispam test: pin the rules it scores against, stop live Pyzor
It failed everywhere but upstream's machines, for two reasons: - The spam rules, which carry every score, came from a path on an upstream developer's own disk. Without SPAM_RULES_URL none loaded, every score was 0.00 and the combined case came out ham instead of spam at 13.70. The published rules of spam-filter v3.0.2 are now pinned beside the test cases (Apache-2.0 or MIT, taken as MIT; in THIRD-PARTY.md). SPAM_RULES_URL still overrides. - The first combined case expects a Pyzor hit, and its digest (that of an empty body) wasn't among the three the test mode answers, so it went to a public Pyzor server: it failed offline and would drift with that server's counts. Test mode now answers every digest from a fixed table, with the empty body's added, and never reaches the network. The test passes online and offline, alone and with the rest of the SMTP tests. queue_retry, unrelated, still fails when it runs after the others in one process, though it passes alone every time.
This commit is contained in:
@@ -81,9 +81,18 @@ async fn antispam() {
|
||||
admin
|
||||
.registry_create_object(SpamSettings {
|
||||
score_spam: Float::new(5.0),
|
||||
// inbuxa: the rules carry the scores the expectations are written
|
||||
// against, so they're pinned (spam-filter v3.0.2, beside the test
|
||||
// cases) rather than read from a developer's own checkout, which
|
||||
// left every score at zero. SPAM_RULES_URL still overrides.
|
||||
spam_filter_rules_url: std::env::var("SPAM_RULES_URL")
|
||||
.unwrap_or_else(|_| {
|
||||
"file:///Users/me/code/spam-filter/spam-filter-rules.json.gz".to_string()
|
||||
concat!(
|
||||
"file://",
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/resources/smtp/antispam/spam-filter-rules.json.gz"
|
||||
)
|
||||
.to_string()
|
||||
})
|
||||
.into(),
|
||||
..Default::default()
|
||||
@@ -156,7 +165,7 @@ async fn antispam() {
|
||||
}))
|
||||
.await;
|
||||
// inbuxa: a rules file that can't be read is retried later; don't wait
|
||||
// for that retry (the path above is a developer's own checkout)
|
||||
// for that retry (SPAM_RULES_URL may name one that isn't there)
|
||||
test.wait_for_tasks_skip_not_due().await;
|
||||
admin.reload_settings().await;
|
||||
admin.reload_lookup_stores().await;
|
||||
|
||||
Reference in New Issue
Block a user