summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-02-18 05:20:01 +0000
committerSteve Kemp <steve@steve.org.uk>2015-02-18 05:20:01 +0000
commit18d773cff39547e7de9fa10e0644cb38d24dede8 (patch)
tree109429f5ea2066beccc173096df4a23202a16fa7 /lib
parentce925462491ec1abf87fcd6448563d873b90ae22 (diff)
Added SSL-expiry checker.
This is a stub for the moment, but it validates that we can have multiple handlers for a given test-type. This updates #9558.
Diffstat (limited to 'lib')
-rw-r--r--lib/custodian/protocoltest/ssl.rb88
-rw-r--r--lib/custodian/protocoltests.rb1
2 files changed, 89 insertions, 0 deletions
diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb
new file mode 100644
index 0000000..704edac
--- /dev/null
+++ b/lib/custodian/protocoltest/ssl.rb
@@ -0,0 +1,88 @@
+require 'custodian/testfactory'
+
+
+#
+# The SSL-expiry test.
+#
+# This object is instantiated if the parser sees a line such as:
+#
+###
+### https://foo.vm.bytemark.co.uk/ must run https with content 'page text' otherwise 'http fail'.
+###
+#
+#
+module Custodian
+
+ module ProtocolTest
+
+ class SSLCertificateTest < TestFactory
+
+
+ #
+ # Constructor
+ #
+ def initialize( line )
+
+ #
+ # Save the line
+ #
+ @line = line
+
+ #
+ # Save the host
+ #
+ @host = line.split( /\s+/)[0]
+
+ end
+
+
+
+
+ #
+ # Allow this test to be serialized.
+ #
+ def to_s
+ @line
+ end
+
+
+
+ #
+ # Run the test - this means making a TCP-connection to the
+ # given host and validating that the SSL-certificate is not
+ # expired.
+ #
+ # Because testing the SSL certificate is relatively heavy-weight
+ # and because they don't change often we only test in office-hours.
+ #
+ #
+ def run_test
+
+ hour = Time.now.hour
+
+ #
+ # If outside 10AM-5PM we don't alert.
+ #
+ if ( hour < 10 || hour > 17 )
+ return true
+ end
+
+ #
+ # NOP - validate here.
+ #
+ return true
+ end
+
+
+ #
+ # If the test fails then report the error.
+ #
+ def error
+ @error
+ end
+
+ register_test_type "https"
+
+ end
+ end
+end
diff --git a/lib/custodian/protocoltests.rb b/lib/custodian/protocoltests.rb
index 2aed748..29f2885 100644
--- a/lib/custodian/protocoltests.rb
+++ b/lib/custodian/protocoltests.rb
@@ -27,6 +27,7 @@ require 'custodian/protocoltest/redis'
require 'custodian/protocoltest/rsync'
require 'custodian/protocoltest/openproxy'
require 'custodian/protocoltest/ssh'
+require 'custodian/protocoltest/ssl'
require 'custodian/protocoltest/smtp'
require 'custodian/protocoltest/smtprelay'
require 'custodian/protocoltest/telnet'