summaryrefslogtreecommitdiff
path: root/lib/custodian/protocoltest
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2015-03-09 13:19:15 +0000
committerSteve Kemp <steve@steve.org.uk>2015-03-09 13:19:15 +0000
commitaf2ee063abea8235a8cbd1448533e4f4fbc0d0af (patch)
tree969e448e2d5995f7e838a68ef1d25d54df9b8d29 /lib/custodian/protocoltest
parentbb2ec1f07af747c69f2fd1e5b70c41b35fb069e6 (diff)
Prefer single-quotes when you don't need interpolation.
So "foo" is less good than 'foo'.
Diffstat (limited to 'lib/custodian/protocoltest')
-rw-r--r--lib/custodian/protocoltest/dns.rb8
-rw-r--r--lib/custodian/protocoltest/dnsbl.rb8
-rw-r--r--lib/custodian/protocoltest/ftp.rb2
-rw-r--r--lib/custodian/protocoltest/http.rb18
-rw-r--r--lib/custodian/protocoltest/imap.rb2
-rw-r--r--lib/custodian/protocoltest/jabber.rb2
-rw-r--r--lib/custodian/protocoltest/ldap.rb4
-rw-r--r--lib/custodian/protocoltest/mx.rb6
-rw-r--r--lib/custodian/protocoltest/mysql.rb2
-rw-r--r--lib/custodian/protocoltest/named.rb2
-rw-r--r--lib/custodian/protocoltest/openproxy.rb12
-rw-r--r--lib/custodian/protocoltest/ping.rb6
-rw-r--r--lib/custodian/protocoltest/pop3.rb4
-rw-r--r--lib/custodian/protocoltest/postgresql.rb2
-rw-r--r--lib/custodian/protocoltest/redis.rb2
-rw-r--r--lib/custodian/protocoltest/rsync.rb2
-rw-r--r--lib/custodian/protocoltest/smtp.rb2
-rw-r--r--lib/custodian/protocoltest/smtprelay.rb20
-rw-r--r--lib/custodian/protocoltest/ssh.rb2
-rw-r--r--lib/custodian/protocoltest/ssl.rb16
-rw-r--r--lib/custodian/protocoltest/tcp.rb8
-rw-r--r--lib/custodian/protocoltest/telnet.rb2
22 files changed, 66 insertions, 66 deletions
diff --git a/lib/custodian/protocoltest/dns.rb b/lib/custodian/protocoltest/dns.rb
index 8d47e14..7f4b997 100644
--- a/lib/custodian/protocoltest/dns.rb
+++ b/lib/custodian/protocoltest/dns.rb
@@ -64,9 +64,9 @@ module Custodian
#
# Ensure we had all the data.
#
- raise ArgumentError, "Missing host to resolve" unless( @resolve_name )
- raise ArgumentError, "Missing type of record to lookup" unless( @resolve_type )
- raise ArgumentError, "Missing expected results" unless( @resolve_expected )
+ raise ArgumentError, 'Missing host to resolve' unless( @resolve_name )
+ raise ArgumentError, 'Missing type of record to lookup' unless( @resolve_type )
+ raise ArgumentError, 'Missing expected results' unless( @resolve_expected )
raise ArgumentError, "Uknown record type: #{@resolve_type}" unless( @resolve_type =~ /^(A|NS|MX|AAAA)$/ )
#
@@ -193,7 +193,7 @@ module Custodian
- register_test_type "dns"
+ register_test_type 'dns'
diff --git a/lib/custodian/protocoltest/dnsbl.rb b/lib/custodian/protocoltest/dnsbl.rb
index 50a3b7b..d307470 100644
--- a/lib/custodian/protocoltest/dnsbl.rb
+++ b/lib/custodian/protocoltest/dnsbl.rb
@@ -31,7 +31,7 @@ module Custodian
#
# Ensure the host is an IP address.
#
- raise ArgumentError, "The target must be an IP address" unless( @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ )
+ raise ArgumentError, 'The target must be an IP address' unless( @host =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/ )
#
# See which blacklist(s) we're testing against.
@@ -39,7 +39,7 @@ module Custodian
if line =~ /via\s+([^\s]+)\s+/
@zones = $1.dup
else
- @zones = "zen.spamhaus.org"
+ @zones = 'zen.spamhaus.org'
end
#
@@ -73,7 +73,7 @@ module Custodian
# The error is empty.
@error = nil
- @zones.split( "," ).each do |zone|
+ @zones.split( ',' ).each do |zone|
#
# Convert the IP to be looked up.
@@ -110,7 +110,7 @@ module Custodian
end
# register ourselves with the class-factory
- register_test_type "dnsbl"
+ register_test_type 'dnsbl'
end
end
end
diff --git a/lib/custodian/protocoltest/ftp.rb b/lib/custodian/protocoltest/ftp.rb
index bbed744..921de62 100644
--- a/lib/custodian/protocoltest/ftp.rb
+++ b/lib/custodian/protocoltest/ftp.rb
@@ -92,7 +92,7 @@ module Custodian
- register_test_type "ftp"
+ register_test_type 'ftp'
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb
index c43aee3..6ed3c5b 100644
--- a/lib/custodian/protocoltest/http.rb
+++ b/lib/custodian/protocoltest/http.rb
@@ -79,10 +79,10 @@ module Custodian
case line
when /\s+must\s(not\s+)?run\s+http(\s+|\.|$)/i
then
- test_type = "http"
+ test_type = 'http'
when /\s+must\s+(not\s+)?run\s+https(\s+|\.|$)/i
then
- test_type = "https"
+ test_type = 'https'
else
raise ArgumentError, "URL has invalid scheme: #{@line}"
end
@@ -111,7 +111,7 @@ module Custodian
if line =~ /with status ([0-9]+)/
@expected_status = $1.dup
else
- @expected_status = "200"
+ @expected_status = '200'
end
if line =~ /with (IPv[46])/i
@@ -158,9 +158,9 @@ module Custodian
#
def get_type
if @url =~ /^https:/
- "https"
+ 'https'
elsif @url =~ /^http:/
- "http"
+ 'http'
else
raise ArgumentError, "URL isn't http/https: #{@url}"
end
@@ -255,7 +255,7 @@ module Custodian
end
unless @host_override.nil?
- c.headers["Host"] = @host_override
+ c.headers['Host'] = @host_override
end
c.ssl_verify_host = false
@@ -265,7 +265,7 @@ module Custodian
#
# Set a basic protocol message, for use later.
#
- protocol_msg = (resolve_mode == :ipv4 ? "IPv4" : "IPv6")
+ protocol_msg = (resolve_mode == :ipv4 ? 'IPv4' : 'IPv6')
begin
timeout( period ) do
@@ -342,8 +342,8 @@ module Custodian
end
- register_test_type "http"
- register_test_type "https"
+ register_test_type 'http'
+ register_test_type 'https'
end
end
diff --git a/lib/custodian/protocoltest/imap.rb b/lib/custodian/protocoltest/imap.rb
index 3f338b2..fb80305 100644
--- a/lib/custodian/protocoltest/imap.rb
+++ b/lib/custodian/protocoltest/imap.rb
@@ -92,7 +92,7 @@ module Custodian
- register_test_type "imap"
+ register_test_type 'imap'
diff --git a/lib/custodian/protocoltest/jabber.rb b/lib/custodian/protocoltest/jabber.rb
index 1431139..916f15f 100644
--- a/lib/custodian/protocoltest/jabber.rb
+++ b/lib/custodian/protocoltest/jabber.rb
@@ -90,7 +90,7 @@ module Custodian
- register_test_type "jabber"
+ register_test_type 'jabber'
diff --git a/lib/custodian/protocoltest/ldap.rb b/lib/custodian/protocoltest/ldap.rb
index aee09e0..a5f6605 100644
--- a/lib/custodian/protocoltest/ldap.rb
+++ b/lib/custodian/protocoltest/ldap.rb
@@ -92,7 +92,7 @@ module Custodian
begin
require 'ldap'
rescue LoadError
- @error = "LDAP library not available - test disabled"
+ @error = 'LDAP library not available - test disabled'
return false
end
@@ -147,7 +147,7 @@ module Custodian
- register_test_type "ldap"
+ register_test_type 'ldap'
end
diff --git a/lib/custodian/protocoltest/mx.rb b/lib/custodian/protocoltest/mx.rb
index 0df1b5d..61e838c 100644
--- a/lib/custodian/protocoltest/mx.rb
+++ b/lib/custodian/protocoltest/mx.rb
@@ -103,7 +103,7 @@ module Custodian
#
failed = 0
passed = 0
- error = ""
+ error = ''
mx.each do |backend|
@@ -116,7 +116,7 @@ module Custodian
# trim to a sane length & strip newlines.
if ! read.nil?
read = read[0,255]
- read.gsub!(/[\n\r]/, "")
+ read.gsub!(/[\n\r]/, '')
end
if read =~ /^220/
@@ -161,7 +161,7 @@ module Custodian
- register_test_type "mx"
+ register_test_type 'mx'
diff --git a/lib/custodian/protocoltest/mysql.rb b/lib/custodian/protocoltest/mysql.rb
index 135dc38..7abc28f 100644
--- a/lib/custodian/protocoltest/mysql.rb
+++ b/lib/custodian/protocoltest/mysql.rb
@@ -92,7 +92,7 @@ module Custodian
- register_test_type "mysql"
+ register_test_type 'mysql'
diff --git a/lib/custodian/protocoltest/named.rb b/lib/custodian/protocoltest/named.rb
index c4e5e8a..4c1b134 100644
--- a/lib/custodian/protocoltest/named.rb
+++ b/lib/custodian/protocoltest/named.rb
@@ -90,7 +90,7 @@ module Custodian
- register_test_type "named"
+ register_test_type 'named'
diff --git a/lib/custodian/protocoltest/openproxy.rb b/lib/custodian/protocoltest/openproxy.rb
index da432f0..04fe833 100644
--- a/lib/custodian/protocoltest/openproxy.rb
+++ b/lib/custodian/protocoltest/openproxy.rb
@@ -92,20 +92,20 @@ module Custodian
c.ssl_verify_host = false
c.proxy_url = @host
c.proxy_tunnel = true
- c.url = "http://google.com/"
+ c.url = 'http://google.com/'
c.ssl_verify_peer = false
c.timeout = period
c.perform
@status = c.response_code
@content = c.body_str
rescue Curl::Err::SSLCACertificateError => x
- @error = "SSL-Validation error"
+ @error = 'SSL-Validation error'
return false
rescue Curl::Err::TimeoutError
- @error = "Timed out fetching page."
+ @error = 'Timed out fetching page.'
return false
rescue Curl::Err::TooManyRedirectsError
- @error = "Too many redirections (more than 10)"
+ @error = 'Too many redirections (more than 10)'
return false
rescue => x
@error = "Exception: #{x}"
@@ -113,7 +113,7 @@ module Custodian
end
end
rescue Timeout::Error => e
- @error = "Timed out during fetch."
+ @error = 'Timed out during fetch.'
return false
end
@@ -141,7 +141,7 @@ module Custodian
- register_test_type "openproxy"
+ register_test_type 'openproxy'
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 5a9bf0a..7d3d802 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -70,8 +70,8 @@ module Custodian
# Find the binary we're going to invoke.
#
binary = nil
- binary = "./bin/multi-ping"
- binary = "/usr/bin/multi-ping" if File.exist?( "/usr/bin/multi-ping" )
+ binary = './bin/multi-ping'
+ binary = '/usr/bin/multi-ping' if File.exist?( '/usr/bin/multi-ping' )
if binary.nil?
@error = "Failed to find '/usr/bin/multi-ping'"
@@ -200,7 +200,7 @@ module Custodian
- register_test_type "ping"
+ register_test_type 'ping'
diff --git a/lib/custodian/protocoltest/pop3.rb b/lib/custodian/protocoltest/pop3.rb
index 48b2d37..3be34b3 100644
--- a/lib/custodian/protocoltest/pop3.rb
+++ b/lib/custodian/protocoltest/pop3.rb
@@ -92,8 +92,8 @@ module Custodian
- register_test_type "pop3"
- register_test_type "pop"
+ register_test_type 'pop3'
+ register_test_type 'pop'
diff --git a/lib/custodian/protocoltest/postgresql.rb b/lib/custodian/protocoltest/postgresql.rb
index 7ce4d70..2dad5cd 100644
--- a/lib/custodian/protocoltest/postgresql.rb
+++ b/lib/custodian/protocoltest/postgresql.rb
@@ -92,7 +92,7 @@ module Custodian
- register_test_type "postgresql"
+ register_test_type 'postgresql'
end
diff --git a/lib/custodian/protocoltest/redis.rb b/lib/custodian/protocoltest/redis.rb
index 1d732a0..d1815aa 100644
--- a/lib/custodian/protocoltest/redis.rb
+++ b/lib/custodian/protocoltest/redis.rb
@@ -92,7 +92,7 @@ module Custodian
- register_test_type "redis"
+ register_test_type 'redis'
diff --git a/lib/custodian/protocoltest/rsync.rb b/lib/custodian/protocoltest/rsync.rb
index 75c27ae..0f3c288 100644
--- a/lib/custodian/protocoltest/rsync.rb
+++ b/lib/custodian/protocoltest/rsync.rb
@@ -94,7 +94,7 @@ module Custodian
- register_test_type "rsync"
+ register_test_type 'rsync'
diff --git a/lib/custodian/protocoltest/smtp.rb b/lib/custodian/protocoltest/smtp.rb
index 1d98dca..6a8cd65 100644
--- a/lib/custodian/protocoltest/smtp.rb
+++ b/lib/custodian/protocoltest/smtp.rb
@@ -90,7 +90,7 @@ module Custodian
- register_test_type "smtp"
+ register_test_type 'smtp'
diff --git a/lib/custodian/protocoltest/smtprelay.rb b/lib/custodian/protocoltest/smtprelay.rb
index 397c5cb..ef07f82 100644
--- a/lib/custodian/protocoltest/smtprelay.rb
+++ b/lib/custodian/protocoltest/smtprelay.rb
@@ -61,10 +61,10 @@ module Custodian
# Read the hostname for usage in the SMTP-transaction.
#
def get_hostname
- hostname = "localhost.localdomain"
+ hostname = 'localhost.localdomain'
- if File.exist?( "/etc/hostname" )
- File.readlines("/etc/hostname" ).each do |line|
+ if File.exist?( '/etc/hostname' )
+ File.readlines('/etc/hostname' ).each do |line|
hostname = line if !line.nil?
hostname.chomp!
end
@@ -87,10 +87,10 @@ module Custodian
begin
Net::SMTP.start(@host,@port, get_hostname ) do |smtp|
- sent = smtp.send_message message, "noreply@bytemark.co.uk", "noreply@bytemark.co.uk"
+ sent = smtp.send_message message, 'noreply@bytemark.co.uk', 'noreply@bytemark.co.uk'
@status = sent.status.to_s
- if @status === "250"
+ if @status === '250'
@error = "NOT OK: message sent on #{@host} with status #{@status}"
else
@error = "OK: message not sent on #{@host} with status #{@status}"
@@ -101,10 +101,10 @@ module Custodian
# and whether or not we're inverting the test. (eg, 'must not')
#
- return @inverted if @status == "250" and @inverted
- return !@inverted if @status == "250" and !@inverted
- return @inverted if @status != "250" and !@inverted
- return !@inverted if @status != "250" and @inverted
+ return @inverted if @status == '250' and @inverted
+ return !@inverted if @status == '250' and !@inverted
+ return @inverted if @status != '250' and !@inverted
+ return !@inverted if @status != '250' and @inverted
end # Net SMTP
@@ -128,7 +128,7 @@ module Custodian
end
# register ourselves with the class-factory
- register_test_type "smtprelay"
+ register_test_type 'smtprelay'
end
end
end
diff --git a/lib/custodian/protocoltest/ssh.rb b/lib/custodian/protocoltest/ssh.rb
index 9b5a608..3d5e9fb 100644
--- a/lib/custodian/protocoltest/ssh.rb
+++ b/lib/custodian/protocoltest/ssh.rb
@@ -93,7 +93,7 @@ module Custodian
- register_test_type "ssh"
+ register_test_type 'ssh'
diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb
index 86acb34..39a962d 100644
--- a/lib/custodian/protocoltest/ssl.rb
+++ b/lib/custodian/protocoltest/ssl.rb
@@ -26,7 +26,7 @@ class SSLCheck
# Takes one parameter -- the URL.
#
def initialize(uri)
- raise ArgumentError, "URI must be a string" unless uri.is_a?(String)
+ raise ArgumentError, 'URI must be a string' unless uri.is_a?(String)
@uri = URI.parse(uri)
@domain = @uri.host
@@ -60,7 +60,7 @@ class SSLCheck
# Allows the domain to be set manually.
#
def domain=(d)
- raise ArgumentError, "domain must be a String" unless d.is_a?(String)
+ raise ArgumentError, 'domain must be a String' unless d.is_a?(String)
@domain=d
end
@@ -76,7 +76,7 @@ class SSLCheck
# ones from ALL_TESTS are taken. Anything else is ignored.
#
def tests=(ts)
- raise ArgumentError, "tests must be an Array" unless ts.is_a?(Array)
+ raise ArgumentError, 'tests must be an Array' unless ts.is_a?(Array)
@tests = ts.collect{|t| t.to_sym}.select{|t| ALL_TESTS.include?(t)}
@tests
@@ -94,7 +94,7 @@ class SSLCheck
# Probably not much use here.
#
def key=(k)
- raise ArgumentError, "key must be a String" unless k.is_a?(String)
+ raise ArgumentError, 'key must be a String' unless k.is_a?(String)
if k =~ /-----BEGIN/
@key = OpenSSL::PKey::RSA.new(k)
else
@@ -127,7 +127,7 @@ class SSLCheck
elsif b.is_a?(OpenSSL::X509::Certificate)
self.certificate_store.add_cert(b)
else
- raise ArgumentError, "bundle must be a String, an Array, or an OpenSSL::X509::Certificate"
+ raise ArgumentError, 'bundle must be a String, an Array, or an OpenSSL::X509::Certificate'
end
b
end
@@ -140,7 +140,7 @@ class SSLCheck
@certificate_store = OpenSSL::X509::Store.new
@certificate_store.set_default_paths
- @certificate_store.add_path("/etc/ssl/certs")
+ @certificate_store.add_path('/etc/ssl/certs')
@certificate_store
end
@@ -412,7 +412,7 @@ module Custodian
# Double-check we've got an SSL host
#
if ! @host =~ /^https:\/\//
- puts( "Not an SSL URL" )
+ puts( 'Not an SSL URL' )
return true
end
@@ -442,7 +442,7 @@ module Custodian
@error
end
- register_test_type "https"
+ register_test_type 'https'
end
end
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index 60c7be7..ca622bb 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -102,7 +102,7 @@ module Custodian
@error = nil
if @port.nil?
- raise ArgumentError, "Missing port to test against"
+ raise ArgumentError, 'Missing port to test against'
end
end
@@ -280,7 +280,7 @@ module Custodian
# trim to a sane length & strip newlines.
if ! read.nil?
read = read[0,255]
- read.gsub!(/[\n\r]/, "")
+ read.gsub!(/[\n\r]/, '')
end
socket.close
@@ -317,7 +317,7 @@ module Custodian
@error = "TIMEOUT: #{e}"
return false
end
- @error = "Misc failure"
+ @error = 'Misc failure'
false
end
@@ -334,7 +334,7 @@ module Custodian
- register_test_type "tcp"
+ register_test_type 'tcp'
diff --git a/lib/custodian/protocoltest/telnet.rb b/lib/custodian/protocoltest/telnet.rb
index b5e0cde..f485191 100644
--- a/lib/custodian/protocoltest/telnet.rb
+++ b/lib/custodian/protocoltest/telnet.rb
@@ -90,7 +90,7 @@ module Custodian
- register_test_type "telnet"
+ register_test_type 'telnet'