aboutsummaryrefslogtreecommitdiffstats
path: root/test/open-uri/test_ssl.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-12 11:07:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-12 11:07:05 +0000
commit5ee445bc0c978076946de998e62193ccaa9b29dd (patch)
tree1ee505101f4b8cd8ef24e42eb71dc45d90243df3 /test/open-uri/test_ssl.rb
parentf34cf072a4bcb135e2cc099d6f9f5dd2cecda269 (diff)
downloadruby-5ee445bc0c978076946de998e62193ccaa9b29dd.tar.gz
test proxy log.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/open-uri/test_ssl.rb')
-rw-r--r--test/open-uri/test_ssl.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/open-uri/test_ssl.rb b/test/open-uri/test_ssl.rb
index 28c9ecf46f..29c794a598 100644
--- a/test/open-uri/test_ssl.rb
+++ b/test/open-uri/test_ssl.rb
@@ -1,8 +1,10 @@
require 'test/unit'
require 'open-uri'
require 'openssl'
+require 'stringio'
require 'webrick'
require 'webrick/https'
+require 'webrick/httpproxy'
class TestOpenURISSL < Test::Unit::TestCase
@@ -59,6 +61,31 @@ class TestOpenURISSL < Test::Unit::TestCase
}
end
+ def test_proxy
+ with_https {|srv, dr, url|
+ cacert_filename = "#{dr}/cacert.pem"
+ open(cacert_filename, "w") {|f| f << CA_CERT }
+ prxy = WEBrick::HTTPProxyServer.new({
+ :ServerType => Thread,
+ :Logger => WEBrick::Log.new(NullLog),
+ :AccessLog => [[sio=StringIO.new, WEBrick::AccessLog::COMMON_LOG_FORMAT]],
+ :BindAddress => '127.0.0.1',
+ :Port => 0})
+ _, p_port, _, p_host = prxy.listeners[0].addr
+ begin
+ th = prxy.start
+ open("#{dr}/proxy", "w") {|f| f << "proxy" }
+ open("#{url}/proxy", :proxy=>"http://#{p_host}:#{p_port}/", :ssl_ca_cert => cacert_filename) {|f|
+ assert_equal("200", f.status[0])
+ assert_equal("proxy", f.read)
+ }
+ assert_match(%r[CONNECT #{url.sub(%r{\Ahttps://}, '')} ], sio.string)
+ ensure
+ prxy.shutdown
+ end
+ }
+ end
+
end
# mkdir demoCA demoCA/private demoCA/newcerts