summaryrefslogtreecommitdiff
path: root/lib/custodian/protocoltest
diff options
context:
space:
mode:
Diffstat (limited to 'lib/custodian/protocoltest')
-rw-r--r--lib/custodian/protocoltest/http.rb16
-rw-r--r--lib/custodian/protocoltest/ping.rb12
-rw-r--r--lib/custodian/protocoltest/ssl.rb22
-rw-r--r--lib/custodian/protocoltest/tcp.rb14
4 files changed, 32 insertions, 32 deletions
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb
index 0bf1a68..084e9aa 100644
--- a/lib/custodian/protocoltest/http.rb
+++ b/lib/custodian/protocoltest/http.rb
@@ -59,7 +59,7 @@ module Custodian
# raise an alert, but if it is this false-error then we
# will silently disable this test-run.
#
- def ignore_failure?( protocol )
+ def ignore_failure?(protocol)
# Get the hostname we're connecting to.
u = URI.parse(@url)
@@ -116,7 +116,7 @@ module Custodian
#
# "ips" being empty because the DNS failure was genuine
#
- return ( ! ips.empty? )
+ return (!ips.empty?)
end
@@ -189,8 +189,8 @@ module Custodian
#
# Save username/password if they were specified
#
- @username = u.user if ( u.user )
- @password = u.password if ( u.password )
+ @username = u.user if (u.user)
+ @password = u.password if (u.password)
#
# Expected status
@@ -278,7 +278,7 @@ module Custodian
# Do we have basic auth?
#
def basic_auth?
- ( @username.nil? == false ) && ( @password.nil? == false )
+ (@username.nil? == false) && (@password.nil? == false)
end
#
@@ -341,7 +341,7 @@ module Custodian
# If we're running with HTTP-basic-auth we should remove
# the username/password from the URL we're passing to curb.
#
- if ( basic_auth? )
+ if (basic_auth?)
u = URI.parse(test_url)
u.user = nil
u.password = nil
@@ -365,7 +365,7 @@ module Custodian
#
# Should we use HTTP basic-auth?
#
- if basic_auth?
+ if basic_auth?
c.http_auth_types = :basic
c.username = basic_auth_username
c.password = basic_auth_password
@@ -421,7 +421,7 @@ module Custodian
rescue Curl::Err::TooManyRedirectsError
errors << "#{protocol_msg}: More than 10 redirections."
rescue Curl::Err::HostResolutionError => x
- resolution_errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}." unless ignore_failure?( resolve_mode)
+ resolution_errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}." unless ignore_failure?(resolve_mode)
rescue => x
errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}."
diff --git a/lib/custodian/protocoltest/ping.rb b/lib/custodian/protocoltest/ping.rb
index 44da04d..3ee722e 100644
--- a/lib/custodian/protocoltest/ping.rb
+++ b/lib/custodian/protocoltest/ping.rb
@@ -112,17 +112,17 @@ module Custodian
#
# Both types?
#
- do_ipv6 = true
- do_ipv4 = true
+ ipv6 = true
+ ipv4 = true
#
# Allow the test to disable one/both
#
if @line =~ /ipv4_only/
- do_ipv6 = false
+ ipv6 = false
end
if @line =~ /ipv6_only/
- do_ipv4 = false
+ ipv4 = false
end
#
@@ -133,11 +133,11 @@ module Custodian
timeout(period) do
Resolv::DNS.open do |dns|
- if do_ipv4
+ if ipv4
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::A)
ress.map { |r| ips.push(r.address.to_s) }
end
- if do_ipv6
+ if ipv6
ress = dns.getresources(@host, Resolv::DNS::Resource::IN::AAAA)
ress.map { |r| ips.push(r.address.to_s) }
end
diff --git a/lib/custodian/protocoltest/ssl.rb b/lib/custodian/protocoltest/ssl.rb
index 82754c6..6bc1a04 100644
--- a/lib/custodian/protocoltest/ssl.rb
+++ b/lib/custodian/protocoltest/ssl.rb
@@ -162,25 +162,25 @@ class SSLCheck
# is valid.
#
def certificate_fallback
- cert = ""
+ cert = ''
in_cert = false
# Run the command.
out = `echo "" | openssl s_client -servername #{uri.host} -connect #{uri.host}:#{uri.port} 2>/dev/null`
# For each line of the output
- out.split( /[\r\n]/ ).each do |line|
+ out.split(/[\r\n]/).each do |line|
# Are we in a certificate?
- in_cert = true if ( line =~ /BEGIN CERT/ )
+ in_cert = true if (line =~ /BEGIN CERT/)
# If so append the line.
- if ( in_cert )
+ if (in_cert)
cert += line
cert += "\n"
end
# Are we at the end?
- in_cert = false if ( line =~ /END CERT/ )
+ in_cert = false if (line =~ /END CERT/)
end
# Return the certificate
@@ -248,10 +248,10 @@ class SSLCheck
if self.certificate.nil?
# Use our fallback method.
- fallback = certificate_fallback()
+ fallback = certificate_fallback
# If we failed to fetch it then we cannot do anything useful.
- if ( fallback.nil? )
+ if (fallback.nil?)
self.errors << verbose("Failed to fetch certificate for #{self.domain}")
return nil
else
@@ -373,9 +373,9 @@ class SSLCheck
# signature is valid, because we're missing the bundle that
# the remote server should have sent us.
#
- if ( @fallback )
+ if (@fallback)
verbose "Skipping certificate signature validation for #{self.domain} because fallback SSL-certificate had to be used and we think we'll fail"
- return true;
+ return true
end
unless self.tests.include?(:signature)
@@ -514,7 +514,7 @@ module Custodian
return Custodian::TestResult::TEST_SKIPPED
end
- s = SSLCheck.new(@host,@expiry_days)
+ s = SSLCheck.new(@host, @expiry_days)
result = s.verify
if true == result
@@ -522,7 +522,7 @@ module Custodian
return Custodian::TestResult::TEST_PASSED
elsif result.nil?
puts("SSL Verification returned no result #{@host}")
- @error = "SSL Verification for #{@host} failed - TLS negotiation failure?\n";
+ @error = "SSL Verification for #{@host} failed - TLS negotiation failure?\n"
@error += s.errors.join("\n")
return Custodian::TestResult::TEST_FAILED
else
diff --git a/lib/custodian/protocoltest/tcp.rb b/lib/custodian/protocoltest/tcp.rb
index 0081a18..c62303f 100644
--- a/lib/custodian/protocoltest/tcp.rb
+++ b/lib/custodian/protocoltest/tcp.rb
@@ -113,7 +113,7 @@ module Custodian
# reset the error, in case we were previously executed.
@error = nil
- (run_test_internal(@host, @port, @banner, (! @banner.nil?)))
+ (run_test_internal(@host, @port, @banner, (!@banner.nil?)))
end
@@ -165,17 +165,17 @@ module Custodian
#
# Both types?
#
- do_ipv6 = true
- do_ipv4 = true
+ ipv6 = true
+ ipv4 = true
#
# Allow the test to disable one/both
#
if @line =~ /ipv4_only/
- do_ipv6 = false
+ ipv6 = false
end
if @line =~ /ipv6_only/
- do_ipv4 = false
+ ipv4 = false
end
@@ -188,11 +188,11 @@ module Custodian
Resolv::DNS.open do |dns|
- if do_ipv4
+ if ipv4
ress = dns.getresources(host, Resolv::DNS::Resource::IN::A)
ress.map { |r| ips.push(r.address.to_s) }
end
- if do_ipv6
+ if ipv6
ress = dns.getresources(host, Resolv::DNS::Resource::IN::AAAA)
ress.map { |r| ips.push(r.address.to_s) }
end