1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

More ssl test helper cleanup.

This commit is contained in:
John Nunemaker 2012-04-15 23:29:36 -04:00
parent 83316de971
commit 9003387a00

View file

@ -1,21 +1,23 @@
require 'pathname'
module HTTParty module HTTParty
module SSLTestHelper module SSLTestHelper
def ssl_verify_test(mode, ca_basename, server_cert_filename) def ssl_verify_test(mode, ca_basename, server_cert_filename)
path = Pathname(__FILE__).join('..', '..', 'fixtures', 'ssl', 'generated').expand_path
options = { options = {
:format => :json, :format => :json,
:timeout => 30, :timeout => 30,
} }
if mode if mode
ca_path = File.expand_path("../../fixtures/ssl/generated/#{ca_basename}", __FILE__) ca_path = path.join(ca_basename)
raise ArgumentError.new("#{ca_path} does not exist") unless File.exist?(ca_path) raise ArgumentError.new("#{ca_path} does not exist") unless ca_path.exist?
options[mode] = ca_path options[mode] = ca_path
end end
begin
test_server = SSLTestServer.new({ test_server = SSLTestServer.new({
:rsa_key => File.read(File.expand_path("../../fixtures/ssl/generated/server.key", __FILE__)), :rsa_key => path.join('server.key').read,
:cert => File.read(File.expand_path("../../fixtures/ssl/generated/#{server_cert_filename}", __FILE__)), :cert => path.join(server_cert_filename).read,
}) })
test_server.start test_server.start
@ -26,4 +28,3 @@ module HTTParty
end end
end end
end end
end