aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/connection_test.rb
diff options
context:
space:
mode:
authorRoy Nicholson <nicholson.roy@gmail.com>2009-08-09 13:57:20 -0400
committerJeremy Kemper <jeremy@bitsweat.net>2009-08-09 13:24:05 -0700
commit3e0951632c52018eefb86d9e0bfe77383f9622fb (patch)
treed34dc23ad89395641345ff162ef6d0edde3403fa /activeresource/test/connection_test.rb
parentc5896bfd8432f6b7a1c6cb06486c5c85eafe9450 (diff)
downloadrails-3e0951632c52018eefb86d9e0bfe77383f9622fb.tar.gz
rails-3e0951632c52018eefb86d9e0bfe77383f9622fb.tar.bz2
rails-3e0951632c52018eefb86d9e0bfe77383f9622fb.zip
Add ability to set SSL options on ARes connections.
[#2370 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activeresource/test/connection_test.rb')
-rw-r--r--activeresource/test/connection_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb
index 12e8058b0c..b482f2dd0e 100644
--- a/activeresource/test/connection_test.rb
+++ b/activeresource/test/connection_test.rb
@@ -204,6 +204,24 @@ class ConnectionTest < Test::Unit::TestCase
assert_nothing_raised(Mocha::ExpectationError) { @conn.get(path, {'Accept' => 'application/xhtml+xml'}) }
end
+ def test_ssl_options_get_applied_to_http
+ http = Net::HTTP.new('')
+ @conn.site="https://secure"
+ @conn.ssl_options={:verify_mode => OpenSSL::SSL::VERIFY_PEER}
+ @conn.timeout = 10 # prevent warning about uninitialized.
+ @conn.send(:configure_http, http)
+
+ assert http.use_ssl?
+ assert_equal http.verify_mode, OpenSSL::SSL::VERIFY_PEER
+ end
+
+ def test_ssl_error
+ http = Net::HTTP.new('')
+ @conn.expects(:http).returns(http)
+ http.expects(:get).raises(OpenSSL::SSL::SSLError, 'Expired certificate')
+ assert_raise(ActiveResource::SSLError) { @conn.get('/people/1.xml') }
+ end
+
protected
def assert_response_raises(klass, code)
assert_raise(klass, "Expected response code #{code} to raise #{klass}") do