Ignore spamc.conf in integration tests, update changelog

This commit is contained in:
David Bürgin 2020-10-15 17:45:01 +02:00
parent 49896bba73
commit 04e0539dcf
8 changed files with 23 additions and 6 deletions

View file

@ -1,5 +1,12 @@
# SpamAssassin Milter changelog # SpamAssassin Milter changelog
## unreleased
* Fix a typo in log messages.
* Isolate integration tests from any existing `spamc` configuration present on
the host.
* Various à la mode style improvements in code and project metadata.
## 0.1.3 (2020-07-04) ## 0.1.3 (2020-07-04)
* Add `--reply-code`, `--reply-status-code`, and `--reply-text` options to * Add `--reply-code`, `--reply-status-code`, and `--reply-text` options to

View file

@ -1,3 +1,4 @@
use spamassassin_milter::ConfigBuilder;
use std::{ use std::{
ffi::OsString, ffi::OsString,
io::{ErrorKind, Read, Write}, io::{ErrorKind, Read, Write},
@ -8,6 +9,15 @@ use std::{
time::{Duration, Instant}, time::{Duration, Instant},
}; };
// A file `/etc/spamassassin/spamc.conf` present on the host is read by `spamc`
// by default and may break the integration tests. Isolate `spamc` by overriding
// the configuration file location.
pub fn isolate_from_spamc_conf(mut builder: ConfigBuilder) -> ConfigBuilder {
// Must use `-F` instead of `--config` due to a bug in `spamc`.
builder.spamc_args(vec!["-F", "/dev/null"]);
builder
}
pub const SPAMD_PORT: u16 = 3783; // mock port pub const SPAMD_PORT: u16 = 3783; // mock port
pub type HamOrSpam = Result<String, String>; pub type HamOrSpam = Result<String, String>;

View file

@ -5,7 +5,7 @@ use spamassassin_milter::*;
#[test] #[test]
fn ham_message() { fn ham_message() {
let mut builder = Config::builder(); let mut builder = isolate_from_spamc_conf(Config::builder());
builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]); builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]);
let config = builder.build(); let config = builder.build();

View file

@ -11,7 +11,7 @@ use spamassassin_milter::*;
fn live() { fn live() {
// Without `spamc_args` set, `spamc` will try to connect to the default // Without `spamc_args` set, `spamc` will try to connect to the default
// `spamd` port 783 (see also `/etc/services`). // `spamd` port 783 (see also `/etc/services`).
let config = Default::default(); let config = isolate_from_spamc_conf(Config::builder()).build();
let miltertest = spawn_miltertest_runner(file!()); let miltertest = spawn_miltertest_runner(file!());

View file

@ -5,7 +5,7 @@ use spamassassin_milter::*;
#[test] #[test]
fn reject_spam() { fn reject_spam() {
let mut builder = Config::builder(); let mut builder = isolate_from_spamc_conf(Config::builder());
builder builder
.reject_spam(true) .reject_spam(true)
.reply_code("554".into()) .reply_code("554".into())

View file

@ -5,7 +5,7 @@ use spamassassin_milter::*;
#[test] #[test]
fn skip_oversized() { fn skip_oversized() {
let mut builder = Config::builder(); let mut builder = isolate_from_spamc_conf(Config::builder());
builder.max_message_size(512); builder.max_message_size(512);
builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]); builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]);
let config = builder.build(); let config = builder.build();

View file

@ -5,7 +5,7 @@ use spamassassin_milter::*;
#[test] #[test]
fn spam_message() { fn spam_message() {
let mut builder = Config::builder(); let mut builder = isolate_from_spamc_conf(Config::builder());
builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]); builder.spamc_args(vec![format!("--port={}", SPAMD_PORT)]);
let config = builder.build(); let config = builder.build();

View file

@ -5,7 +5,7 @@ use spamassassin_milter::*;
#[test] #[test]
fn spamc_connection_error() { fn spamc_connection_error() {
let mut builder = Config::builder(); let mut builder = isolate_from_spamc_conf(Config::builder());
// `spamc` always works even if it cannot actually reach `spamd`! // `spamc` always works even if it cannot actually reach `spamd`!
// `--no-safe-fallback` prevents this masking of connection errors. // `--no-safe-fallback` prevents this masking of connection errors.
builder.spamc_args(vec![ builder.spamc_args(vec![