aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-01-04 16:52:43 +0000
committerdakkar <dakkar@thenautilus.net>2017-01-04 16:52:43 +0000
commit0448264ed4a208c5ff8c310f8af14e5efb86ad6c (patch)
treea831a7b7c23055bc6675ec900399af3f6415d1a6 /t
parentallow custom deliveries test message (diff)
downloadSietima-0448264ed4a208c5ff8c310f8af14e5efb86ad6c.tar.gz
Sietima-0448264ed4a208c5ff8c310f8af14e5efb86ad6c.tar.bz2
Sietima-0448264ed4a208c5ff8c310f8af14e5efb86ad6c.zip
tested interaction Debounce+Moderate, plus workaround
Diffstat (limited to 't')
-rw-r--r--t/tests/sietima/multi-role/debounce-moderate.t64
1 files changed, 64 insertions, 0 deletions
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;