summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2019-12-10 19:06:13 +0900
committerNARUSE, Yui <naruse@airemix.jp>2019-12-10 19:12:21 +0900
commitaf11efd377965b6601bb54aa79072ef0789dc525 (patch)
treec159cf3fad0317f4f027a4db8968ea8fab28ef3e /test/net
parentaedbee52c0e21358c33e775eab41c634905f63c3 (diff)
fix ipaddr parameter of Net::HTTP.start to support proxy
54072e329cab7207fba133caba4fc12b45add8f9
Diffstat (limited to 'test/net')
-rw-r--r--test/net/http/test_https.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb
index 3e918a1..17fabb6 100644
--- a/test/net/http/test_https.rb
+++ b/test/net/http/test_https.rb
@@ -67,6 +67,45 @@ class TestNetHTTPS < Test::Unit::TestCase
assert_equal(SERVER_CERT.to_der, certs[1].to_der)
end
+ def test_get_SNI_proxy
+ TCPServer.open("127.0.0.1", 0) {|serv|
+ _, port, _, _ = serv.addr
+ client_thread = Thread.new {
+ proxy = Net::HTTP.Proxy("127.0.0.1", port, 'user', 'password')
+ http = proxy.new("foo.example.org", 8000)
+ http.ipaddr = "192.0.2.1"
+ http.use_ssl = true
+ http.cert_store = TEST_STORE
+ certs = []
+ http.verify_callback = Proc.new do |preverify_ok, store_ctx|
+ certs << store_ctx.current_cert
+ preverify_ok
+ end
+ begin
+ http.start
+ rescue EOFError
+ end
+ }
+ server_thread = Thread.new {
+ sock = serv.accept
+ begin
+ proxy_request = sock.gets("\r\n\r\n")
+ assert_equal(
+ "CONNECT 192.0.2.1:8000 HTTP/1.1\r\n" +
+ "Host: foo.example.org:8000\r\n" +
+ "Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n" +
+ "\r\n",
+ proxy_request,
+ "[ruby-dev:25673]")
+ ensure
+ sock.close
+ end
+ }
+ assert_join_threads([client_thread, server_thread])
+ }
+
+ end
+
def test_get_SNI_failure
TestNetHTTPUtils.clean_http_proxy_env do
http = Net::HTTP.new("invalid_servername", config("port"))