From f59d938c5744dcb2bc44412d684c10acf4a35936 Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 19 Nov 2015 15:20:28 +0100 Subject: [feat] Check for postfwd procs on mx nodes --- tests/white-box/mx.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 794a9a41..f49d2ab4 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -34,6 +34,9 @@ class Mx < LeapTest def test_03_Are_MX_daemons_running? assert_running 'leap_mx' assert_running '/usr/lib/postfix/master' + assert_running '/usr/sbin/postfwd' + assert_running 'postfwd2::cache' + assert_running 'postfwd2::policy' assert_running '/usr/sbin/unbound' pass end -- cgit v1.2.3 From b610c85e9872b5f9347a52af1fe6acb9a2662530 Mon Sep 17 00:00:00 2001 From: Micah Date: Thu, 26 Nov 2015 15:50:17 -0500 Subject: Check for clamav processes on mx nodes (#7648) Change-Id: I751985c0537d430b568a670a2f70d1906b0f0f35 --- tests/white-box/mx.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index f49d2ab4..8b5cc485 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -38,6 +38,9 @@ class Mx < LeapTest assert_running 'postfwd2::cache' assert_running 'postfwd2::policy' assert_running '/usr/sbin/unbound' + assert_running '^/usr/sbin/clamd -c /etc/clamav/clamd.conf$' + assert_running '^/usr/sbin/clamav-milter --config-file=/etc/clamav/clamav-milter.conf$' + assert_running '^/usr/bin/freshclam -d --quiet --config-file=/etc/clamav/freshclam.conf$' pass end -- cgit v1.2.3 From fa90ab06aa09224d5a1fbac69c9bc0f067099206 Mon Sep 17 00:00:00 2001 From: Micah Date: Mon, 30 Nov 2015 12:48:10 -0500 Subject: improve whitebox tests to match on more specific processes (#7655, #7676) Change-Id: I9f267ba38130ceb308d284c926b14d2cee9f87be --- tests/white-box/mx.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 8b5cc485..ba523fe0 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -32,15 +32,15 @@ class Mx < LeapTest end def test_03_Are_MX_daemons_running? - assert_running 'leap_mx' - assert_running '/usr/lib/postfix/master' - assert_running '/usr/sbin/postfwd' - assert_running 'postfwd2::cache' - assert_running 'postfwd2::policy' - assert_running '/usr/sbin/unbound' - assert_running '^/usr/sbin/clamd -c /etc/clamav/clamd.conf$' - assert_running '^/usr/sbin/clamav-milter --config-file=/etc/clamav/clamav-milter.conf$' - assert_running '^/usr/bin/freshclam -d --quiet --config-file=/etc/clamav/freshclam.conf$' + assert_running '.*/usr/bin/twistd.*leap_mx.tac' + assert_running '^/usr/lib/postfix/master$' + assert_running '^/usr/sbin/postfwd' + assert_running 'postfwd2::cache$' + assert_running 'postfwd2::policy$' + assert_running '^/usr/sbin/unbound$' + assert_running '^/usr/sbin/clamd' + assert_running '^/usr/sbin/clamav-milter' + assert_running '^/usr/bin/freshclam' pass end -- cgit v1.2.3 From dc853191a92cb22641f65b1099d69630ca1e79f4 Mon Sep 17 00:00:00 2001 From: Christoph Kluenter Date: Mon, 7 Dec 2015 15:23:54 +0100 Subject: tac file was renamed --- tests/white-box/mx.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index ba523fe0..336f78a4 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -32,7 +32,7 @@ class Mx < LeapTest end def test_03_Are_MX_daemons_running? - assert_running '.*/usr/bin/twistd.*leap_mx.tac' + assert_running '.*/usr/bin/twistd.*mx.tac' assert_running '^/usr/lib/postfix/master$' assert_running '^/usr/sbin/postfwd' assert_running 'postfwd2::cache$' -- cgit v1.2.3 From bfca1b32e33ccd0f5130bae546148529a3642cc3 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 26 Feb 2016 09:48:09 -0800 Subject: skip clamd process test if clamav sig file has not yet been downloaded, closes #7683 --- tests/white-box/mx.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 336f78a4..9f577516 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -38,9 +38,13 @@ class Mx < LeapTest assert_running 'postfwd2::cache$' assert_running 'postfwd2::policy$' assert_running '^/usr/sbin/unbound$' - assert_running '^/usr/sbin/clamd' - assert_running '^/usr/sbin/clamav-milter' - assert_running '^/usr/bin/freshclam' + if File.exists?('/var/lib/clamav/daily.cld') + assert_running '^/usr/sbin/clamd' + assert_running '^/usr/sbin/clamav-milter' + assert_running '^/usr/bin/freshclam' + else + skip "The clamav signature file (/var/lib/clamav/daily.cld) has yet to be downloaded, so clamd is not running." + end pass end -- cgit v1.2.3 From dab3b9227dc2f7977c5f34396f132984fa0485bf Mon Sep 17 00:00:00 2001 From: varac Date: Tue, 15 Mar 2016 15:41:39 +0100 Subject: [bug] Clamav test depends on multiple files The systemd clamav service depends on these files, see the `/lib/systemd/system/clamav-daemon.service` unit file: ConditionPathExistsGlob=/var/lib/clamav/main.{c[vl]d,inc} ConditionPathExistsGlob=/var/lib/clamav/daily.{c[vl]d,inc} Also, leap test should always check for the freshclam daemon. - Resolves: #7683 --- tests/white-box/mx.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 9f577516..9335649a 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -38,12 +38,12 @@ class Mx < LeapTest assert_running 'postfwd2::cache$' assert_running 'postfwd2::policy$' assert_running '^/usr/sbin/unbound$' - if File.exists?('/var/lib/clamav/daily.cld') + assert_running '^/usr/bin/freshclam' + 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 > 1 assert_running '^/usr/sbin/clamd' assert_running '^/usr/sbin/clamav-milter' - assert_running '^/usr/bin/freshclam' else - skip "The clamav signature file (/var/lib/clamav/daily.cld) has yet to be downloaded, so clamd is not running." + 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." end pass end -- cgit v1.2.3 From dbdd754747c754f7a678659bc52e2c60ee5b751c Mon Sep 17 00:00:00 2001 From: varac Date: Thu, 17 Mar 2016 20:15:13 +0100 Subject: [bug] Fix query for clamav signature files --- tests/white-box/mx.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 9335649a..ff8cb744 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -39,7 +39,7 @@ class Mx < LeapTest assert_running 'postfwd2::policy$' assert_running '^/usr/sbin/unbound$' assert_running '^/usr/bin/freshclam' - 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 > 1 + 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' else -- cgit v1.2.3 From df8b42ffd48a324d63a229a55c11c61076166657 Mon Sep 17 00:00:00 2001 From: Micah Date: Thu, 17 Mar 2016 15:16:48 -0400 Subject: add whitebox test for opendkim (#7649) Change-Id: I8c8ec225d703e3caf6c77fc72305da847cea9560 --- tests/white-box/mx.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index ff8cb744..ed990a2e 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -39,6 +39,7 @@ class Mx < LeapTest assert_running 'postfwd2::policy$' assert_running '^/usr/sbin/unbound$' assert_running '^/usr/bin/freshclam' + assert_running '^/usr/sbin/opendkim' 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' -- cgit v1.2.3 From 61441a85b2a96cedd33c7bdc5940f0b8858de7be Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 17 Mar 2016 16:53:33 -0700 Subject: mx test: query identities table for a random record. closes #6406 --- tests/white-box/mx.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index ed990a2e..768b561f 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -31,6 +31,37 @@ class Mx < LeapTest end end + # + # this test picks a random identity document, then queries + # using the by_address view for that same document again. + # + def test_03_Can_query_identities_db? + assert_get(couchdb_url("/identities", url_options)) do |body| + assert response = JSON.parse(body) + doc_count = response['doc_count'].to_i + if doc_count < 1 + skip "There are no identity records yet." + else + offset = rand(doc_count) # pick a random document + count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options) + assert_get(count_url) do |body| + assert response = JSON.parse(body) + record = response['rows'].first + address = record['doc']['address'] + assert address, "address should not be empty" + url_base = %(/identities/_design/Identity/_view/by_address) + params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}") + assert_get(couchdb_url(url_base+params, url_options)) do |body| + assert response = JSON.parse(body) + assert record = response['rows'].first + assert_equal address, record['doc']['address'] + pass + end + end + end + end + end + def test_03_Are_MX_daemons_running? assert_running '.*/usr/bin/twistd.*mx.tac' assert_running '^/usr/lib/postfix/master$' -- cgit v1.2.3 From 966120293ec289636874edda6089b99dc49cb9ae Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 18 Mar 2016 09:40:41 -0700 Subject: tests: fix mx test, ensure password is redacted. --- tests/white-box/mx.rb | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 768b561f..57ec9117 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -39,23 +39,32 @@ class Mx < LeapTest assert_get(couchdb_url("/identities", url_options)) do |body| assert response = JSON.parse(body) doc_count = response['doc_count'].to_i - if doc_count < 1 - skip "There are no identity records yet." + if doc_count <= 1 + # the design document counts as one document. + skip "There are no identity documents yet." else - offset = rand(doc_count) # pick a random document - count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options) - assert_get(count_url) do |body| - assert response = JSON.parse(body) - record = response['rows'].first - address = record['doc']['address'] - assert address, "address should not be empty" - url_base = %(/identities/_design/Identity/_view/by_address) - params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}") - assert_get(couchdb_url(url_base+params, url_options)) do |body| + # try five times to get a valid doc + for i in 1..5 + offset = rand(doc_count) # pick a random document + count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options) + assert_get(count_url) do |body| assert response = JSON.parse(body) - assert record = response['rows'].first - assert_equal address, record['doc']['address'] - pass + record = response['rows'].first + if record['id'] =~ /_design/ + next + else + address = record['doc']['address'] + assert address, "Identity document #{record['id']} is missing an address field. #{record['doc'].inspect}" + url_base = %(/identities/_design/Identity/_view/by_address) + params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}") + assert_get(couchdb_url(url_base+params, url_options)) do |body| + assert response = JSON.parse(body) + assert record = response['rows'].first + assert_equal address, record['doc']['address'] + pass + end + break + end end end end -- cgit v1.2.3 From eac3056c237d523f4786593922fe8f88eb65dff7 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 29 Mar 2016 13:27:01 -0700 Subject: testing: adds mx delivery tests --- tests/white-box/mx.rb | 99 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 7 deletions(-) (limited to 'tests/white-box/mx.rb') diff --git a/tests/white-box/mx.rb b/tests/white-box/mx.rb index 57ec9117..6c0982ce 100644 --- a/tests/white-box/mx.rb +++ b/tests/white-box/mx.rb @@ -1,9 +1,11 @@ raise SkipTest unless service?(:mx) require 'json' +require 'net/smtp' class Mx < LeapTest depends_on "Network" + depends_on "Webapp" if service?(:webapp) def setup end @@ -11,7 +13,7 @@ class Mx < LeapTest def test_01_Can_contact_couchdb? dbs = ["identities"] dbs.each do |db_name| - couchdb_urls("/"+db_name, url_options).each do |url| + couchdb_urls("/"+db_name, couch_url_options).each do |url| assert_get(url) do |body| assert response = JSON.parse(body) assert_equal db_name, response['db_name'] @@ -23,7 +25,7 @@ class Mx < LeapTest def test_02_Can_contact_couchdb_via_haproxy? if property('haproxy.couch') - url = couchdb_url_via_haproxy("", url_options) + url = couchdb_url_via_haproxy("", couch_url_options) assert_get(url) do |body| assert_match /"couchdb":"Welcome"/, body, "Request to #{url} should return couchdb welcome message." end @@ -36,7 +38,7 @@ class Mx < LeapTest # using the by_address view for that same document again. # def test_03_Can_query_identities_db? - assert_get(couchdb_url("/identities", url_options)) do |body| + assert_get(couchdb_url("/identities", couch_url_options)) do |body| assert response = JSON.parse(body) doc_count = response['doc_count'].to_i if doc_count <= 1 @@ -46,7 +48,7 @@ class Mx < LeapTest # try five times to get a valid doc for i in 1..5 offset = rand(doc_count) # pick a random document - count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", url_options) + count_url = couchdb_url("/identities/_all_docs?include_docs=true&limit=1&skip=#{offset}", couch_url_options) assert_get(count_url) do |body| assert response = JSON.parse(body) record = response['rows'].first @@ -57,7 +59,7 @@ class Mx < LeapTest assert address, "Identity document #{record['id']} is missing an address field. #{record['doc'].inspect}" url_base = %(/identities/_design/Identity/_view/by_address) params = %(?include_docs=true&reduce=false&startkey="#{address}"&endkey="#{address}") - assert_get(couchdb_url(url_base+params, url_options)) do |body| + assert_get(couchdb_url(url_base+params, couch_url_options)) do |body| assert response = JSON.parse(body) assert record = response['rows'].first assert_equal address, record['doc']['address'] @@ -71,7 +73,7 @@ class Mx < LeapTest end end - def test_03_Are_MX_daemons_running? + def test_04_Are_MX_daemons_running? assert_running '.*/usr/bin/twistd.*mx.tac' assert_running '^/usr/lib/postfix/master$' assert_running '^/usr/sbin/postfwd' @@ -89,13 +91,96 @@ class Mx < LeapTest pass end + # + # The email sent by this test might get bounced back. + # In this case, the test will pass, but the bounce message will + # get sent to root, so the sysadmin will still figure out pretty + # quickly that something is wrong. + # + def test_05_Can_deliver_email? + 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) + end + pass + end + private - def url_options + def couch_url_options { :username => property('couchdb_leap_mx_user.username'), :password => property('couchdb_leap_mx_user.password') } end + TEST_EMAIL_PUBLIC_KEY=<