From 1952848f99e3d219a5ca670b04daa1bd10759d93 Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 31 Aug 2016 16:59:46 -0700 Subject: mx test: skip email delivery test if clamd is not running because signature files are still downloading. --- tests/white-box/mx.rb | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'tests/white-box') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index e0cb273a..0eeaacd0 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -63,10 +63,10 @@ class Mx < LeapTest if Dir.glob("/var/lib/clamav/main.{c[vl]d,inc}").size > 0 and Dir.glob("/var/lib/clamav/daily.{c[vl]d,inc}").size > 0 assert_running '^/usr/sbin/clamd' assert_running '^/usr/sbin/clamav-milter' + pass else - skip "Downloading the clamav signature files (/var/lib/clamav/{daily,main}.{c[vl]d,inc}) is still in progress, so clamd is not running.\nDon't worry, mail delivery will work without clamav. The download should finish soon." + skip "Downloading the clamav signature files (/var/lib/clamav/{daily,main}.{c[vl]d,inc}) is still in progress, so clamd is not running." end - pass end # @@ -125,21 +125,25 @@ class Mx < LeapTest # get sent to root, so the sysadmin will still figure out pretty # quickly that something is wrong. # - def test_06_Can_deliver_email? - addr = [TEST_EMAIL_USER, property('domain.full_suffix')].join('@') - bad_addr = [TEST_BAD_USER, property('domain.full_suffix')].join('@') + def test_05_Can_deliver_email? + if pgrep('^/usr/sbin/clamd').empty? || pgrep('^/usr/sbin/clamav-milter').empty? + skip "Mail delivery is being deferred because clamav daemon is not running" + else + addr = [TEST_EMAIL_USER, property('domain.full_suffix')].join('@') + bad_addr = [TEST_BAD_USER, property('domain.full_suffix')].join('@') - assert !identity_exists?(bad_addr), "the address #{bad_addr} must not exist." - if !identity_exists?(addr) - user = assert_create_user(TEST_EMAIL_USER, :monitor) - upload_public_key(user.id, TEST_EMAIL_PUBLIC_KEY) - end - assert identity_exists?(addr), "The identity #{addr} should have been created, but it doesn't exist yet." - assert_send_email(addr) - assert_raises(Net::SMTPError) do - send_email(bad_addr) + assert !identity_exists?(bad_addr), "the address #{bad_addr} must not exist." + if !identity_exists?(addr) + user = assert_create_user(TEST_EMAIL_USER, :monitor) + upload_public_key(user.id, TEST_EMAIL_PUBLIC_KEY) + end + assert identity_exists?(addr), "The identity #{addr} should have been created, but it doesn't exist yet." + assert_send_email(addr) + assert_raises(Net::SMTPError) do + send_email(bad_addr) + end + pass end - pass end private -- cgit v1.2.3