From 1451add680ec47993b8066f3c8afe7370c45b717 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Tue, 6 Oct 2015 16:25:04 -0300 Subject: [PATCH] Deliver non-list mail locally on integration --- cookbooks/email/recipes/destination.rb | 5 +++++ roles/integration_server.rb | 1 + test/mail_relay_test.sh | 22 +++++++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 cookbooks/email/recipes/destination.rb diff --git a/cookbooks/email/recipes/destination.rb b/cookbooks/email/recipes/destination.rb new file mode 100644 index 0000000..512c9a1 --- /dev/null +++ b/cookbooks/email/recipes/destination.rb @@ -0,0 +1,5 @@ +execute 'postfix::set_as_final_destination' do + command "postconf mydestination='$myhostname, localhost.$mydomain, localhost, #{node['config']['external_hostname']}'" + not_if "grep mydestination.*#{node['config']['external_hostname']} /etc/postfix/main.cf" + notifies :reload, 'service[postfix]' +end diff --git a/roles/integration_server.rb b/roles/integration_server.rb index 674ea57..749159d 100644 --- a/roles/integration_server.rb +++ b/roles/integration_server.rb @@ -5,6 +5,7 @@ description "Server that runs COLAB (user authentication, visual integration and # point in the future run_list *[ 'recipe[basics::nginx]', + 'recipe[email::destination]', 'recipe[mailman-api]', 'recipe[mailman]', 'recipe[mailman::webui]', diff --git a/test/mail_relay_test.sh b/test/mail_relay_test.sh index f64f99d..56f702b 100644 --- a/test/mail_relay_test.sh +++ b/test/mail_relay_test.sh @@ -1,6 +1,6 @@ . $(dirname $0)/test_helper.sh -test_inbound_mail() { +test_inbound_list_mail() { run_on integration create-list mylist foo@example.com # sending FROM EMAIL RELAY HOST @@ -10,7 +10,23 @@ test_inbound_mail() { run_on integration remove-list mylist - assertEquals 'Message arrives at the mailing list' '1' "$messages" + assertEquals 'Message did not arrive at the mailing list' '1' "$messages" +} + +test_inbound_regular_mail() { + messages_before=$(run_on integration sudo grep -c '^From.*foo@example.com' /var/mail/root) + run_on email send-email foo@example.com root@softwarepublico.dev + n=0 + while [ $n -lt 10 ]; do + sleep 1 + messages=$(run_on integration sudo grep -c '^From.*foo@example.com' /var/mail/root) + if [ "$messages" -gt "$messages_before" ]; then + return + else + n=$(($n + 1)) + fi + done + fail "didn't receive incoming email" } _test_outbound_email() { @@ -24,7 +40,7 @@ _test_outbound_email() { run_on email clear-email-queue - assertEquals 'Message delivered through relay' 1 "$messages" + assertEquals 'Message was not delivered through relay' 1 "$messages" } test_outbound_email_integration() { -- libgit2 0.21.2