Class: SSLVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/support/ssl_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSSLVersion

Returns a new instance of SSLVersion.



7
8
9
10
# File 'lib/support/ssl_version.rb', line 7

def initialize
  @gateways = GatewaySupport.new.gateways
  @success, @failed, @missing, @errored = [], [], [], []
end

Instance Attribute Details

#erroredObject

Returns the value of attribute errored.



5
6
7
# File 'lib/support/ssl_version.rb', line 5

def errored
  @errored
end

#failedObject

Returns the value of attribute failed.



5
6
7
# File 'lib/support/ssl_version.rb', line 5

def failed
  @failed
end

#missingObject

Returns the value of attribute missing.



5
6
7
# File 'lib/support/ssl_version.rb', line 5

def missing
  @missing
end

#successObject

Returns the value of attribute success.



5
6
7
# File 'lib/support/ssl_version.rb', line 5

def success
  @success
end

Instance Method Details



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/support/ssl_version.rb', line 42

def print_summary
  puts "\n\nSucceeded gateways (#{success.length})"

  puts "\n\nFailed Gateways (#{failed.length}):"
  failed.each do |f|
    puts "#{f[:gateway].name} - #{f[:message]}"
  end

  puts "\n\nError Gateways (#{errored.length}):"
  errored.each do |e|
    puts "#{e[:gateway].name} - #{e[:message]}"
  end

  if missing.length > 0
    puts "\n\nGateways missing live_url (#{missing.length}):"
    missing.each do |m|
      puts m.name
    end
  end
end

#test_gateways(min_version = :TLS1_1) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/support/ssl_version.rb', line 12

def test_gateways(min_version = :TLS1_1)
  raise 'Requires Ruby 2.5 or better' unless Net::HTTP.instance_methods.include?(:min_version=)

  puts "Verifying #{@gateways.count} gateways for SSL min_version=#{min_version}\n\n"

  @gateways.each do |g|
    unless g.live_url
      missing << g unless g.abstract_class
      next
    end

    uri = URI.parse(g.live_url)
    result, message = test_min_version(uri, min_version)

    case result
    when :success
      print '.'
      success << g
    when :fail
      print 'F'
      failed << {:gateway => g, :message => message}
    when :error
      print 'E'
      errored << {:gateway => g, :message => message}
    end
  end

  print_summary
end