From 0448264ed4a208c5ff8c310f8af14e5efb86ad6c Mon Sep 17 00:00:00 2001 From: dakkar Date: Wed, 4 Jan 2017 16:52:43 +0000 Subject: tested interaction Debounce+Moderate, plus workaround --- TODO.md | 1 - example/sietima | 2 +- t/tests/sietima/multi-role/debounce-moderate.t | 64 ++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 t/tests/sietima/multi-role/debounce-moderate.t diff --git a/TODO.md b/TODO.md index c47b836..ed53731 100644 --- a/TODO.md +++ b/TODO.md @@ -3,7 +3,6 @@ * bugs! * messy permissions, we should set some umask (we'd like group-writable mailstore) - * `Moderate`+`Debounce` means resuming fails to send * maybe auto-mkpath for `::MailStore::FS`? * list footer * append to plain text single part diff --git a/example/sietima b/example/sietima index 4fafeb3..2e0f338 100755 --- a/example/sietima +++ b/example/sietima @@ -7,11 +7,11 @@ Sietima::CmdLine->new({ traits => [qw( NoMail ReplyTo - SubscriberOnly::Moderate Headers WithAdmin Debounce SubjectTag + SubscriberOnly::Moderate WithMailStore )], args => { diff --git a/t/tests/sietima/multi-role/debounce-moderate.t b/t/tests/sietima/multi-role/debounce-moderate.t new file mode 100644 index 0000000..8612df0 --- /dev/null +++ b/t/tests/sietima/multi-role/debounce-moderate.t @@ -0,0 +1,64 @@ +#!perl +use lib 't/lib'; +use Test::Sietima; +use Test::Sietima::MailStore; + +sub test_one($traits,$should_send=1) { + my @subscriber_addresses = ( + 'one@users.example.com', + 'two@users.example.com', + ); + my $admin = 'admin@lists.example.com'; + my $ms = Test::Sietima::MailStore->new(); + + my $s = make_sietima( + with_traits => $traits, + subscribers => \@subscriber_addresses, + admin => $admin, + mail_store => $ms, + ); + + test_sending( + sietima => $s, + mail => { from=>'someone@users.example.com' }, + mails => [{ + o => object { + call [header_str => 'subject'] => match qr{\bheld for moderation\b}; + }, + }], + ); + transport->clear_deliveries; + + my $to_moderate = $ms->retrieve_by_tags('moderation'); + my $msg_id = $to_moderate->[0]->{id}; + $s->resume($msg_id); + + if ($should_send) { + deliveries_are( + to => \@subscriber_addresses, + test_message => 'the resumed message should be sent', + ); + } + else { + deliveries_are( + mails => [], + test_message => 'the resumed message should be dropped', + ); + } +} + +# there's an ordering dependency between Debounce and Moderate: if we +# moderate a message that already has the X-Been-There header, it will +# be dropped when resumed; the simplest solution is to apply Debounce +# *before* Moderate, so messages are moderated *before* getting the +# anti-loop header + +subtest 'debounce first' => sub { + test_one(['Debounce','SubscriberOnly::Moderate'],1); +}; + +subtest 'moderate first' => sub { + test_one(['SubscriberOnly::Moderate','Debounce'],0); +}; + +done_testing; -- cgit v1.2.3