From 91713ef347d49dca7de7dd9360d42763dd961894 Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Thu, 16 Apr 2015 16:14:06 +0100 Subject: Updated test-handler for new API. This update consists of two changes: * No longer return "true" or "false" instead return "TEST_FAILED", or "TEST_SUCCEEDED". * Removed the testing of test-inversion from the class, now it lives in the base-class where it should have done all along. --- lib/custodian/protocoltest/mx.rb | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lib/custodian/protocoltest/mx.rb') diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb index 3770686..cd5e58e 100644 --- a/lib/custodian/protocoltest/mx.rb +++ b/lib/custodian/protocoltest/mx.rb @@ -1,4 +1,5 @@ -require 'custodian/protocoltest/tcp' +require 'custodian/settings' +require 'custodian/testfactory' # # The MX (DNS + smtp) test. @@ -28,12 +29,6 @@ module Custodian # The main domain we're querying @host = line.split(/\s+/)[0] - if line =~ /must\s+not\s+run\s+/ - @inverted = true - else - @inverted = false - end - end @@ -78,7 +73,7 @@ module Custodian end rescue Timeout::Error => e @error = "Timed-out performing DNS lookups: #{e}" - return nil + return Custodian::TestResult::TEST_FAILED end # @@ -92,7 +87,7 @@ module Custodian # if mx.empty? then @error = "Failed to perform DNS lookup of MX record(s) for host #{@host}" - return false + return Custodian::TestResult::TEST_FAILED end @@ -130,7 +125,7 @@ module Custodian error += "Error connecting to #{backend}:25. " end end - rescue Timeout::Error => ex + rescue Timeout::Error => _ex # Timeout failed += 1 error += "Timeout connecting to #{backend}:25. " @@ -142,9 +137,9 @@ module Custodian # if failed > 0 @error = "There are #{mx.size} hosts running as MX-servers for domain #{@host} - #{passed}:OK #{failed}:FAILED - #{error}" - return false + return Custodian::TestResult::TEST_FAILED else - return true + return Custodian::TestResult::TEST_PASSED end end -- cgit v1.2.1