Sha256: ad9839e06d3310f3698f740824c0c5ce8262016376f0e17857d27213377a7f35

Contents?: true

Size: 1023 Bytes

Versions: 1

Compression:

Stored size: 1023 Bytes

Contents

module HTTPotato
  module SSLTestHelper
    def ssl_verify_test(mode, ca_basename, server_cert_filename)
      test_server = nil
      begin
        # Start an HTTPS server
        test_server = SSLTestServer.new(
            :rsa_key => File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)),
            :cert => File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__)))
        test_server.start

        # Build a request
        if mode
          ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__)
          raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path)
          return HTTPotato.get("https://localhost:#{test_server.port}/", :format => :json, :timeout=>30, mode => ca_path)
        else
          return HTTPotato.get("https://localhost:#{test_server.port}/", :format => :json, :timeout=>30)
        end
      ensure
        test_server.stop if test_server
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
httpotato-1.0.2 spec/support/ssl_test_helper.rb