1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00
rest-client--rest-client/spec/integration/request_spec.rb

28 lines
1.1 KiB
Ruby
Raw Normal View History

2010-07-03 07:30:06 -04:00
require File.join( File.dirname(File.expand_path(__FILE__)), '../base')
describe RestClient::Request do
describe "ssl verification" do
it "is successful with the correct ca_file" do
request = RestClient::Request.new(
:method => :get,
:url => 'https://www.mozilla.com',
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "equifax.crt")
)
expect { request.execute }.to_not raise_error
end
# This doesn't works any more (under 1.9.3 at the very least). Exceptions in verify_callback are ignored.
# see https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L237
it "is unsuccessful with an incorrect ca_file" do
request = RestClient::Request.new(
:method => :get,
:url => 'https://www.mozilla.com',
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
:ssl_ca_file => File.join(File.dirname(__FILE__), "certs", "verisign.crt")
)
expect { request.execute }.to raise_error(RestClient::SSLCertificateNotVerified)
end
end
end