2005-06-06 22:49:16 -04:00
|
|
|
begin
|
|
|
|
require 'net/https'
|
|
|
|
rescue LoadError
|
|
|
|
end
|
2005-06-03 12:11:40 -04:00
|
|
|
require 'test/unit'
|
|
|
|
|
|
|
|
class HTTPSProxyTest < Test::Unit::TestCase
|
|
|
|
def test_https_proxy_authentication
|
2005-06-03 16:40:39 -04:00
|
|
|
TCPServer.open("127.0.0.1", 0) {|serv|
|
2005-06-03 14:03:52 -04:00
|
|
|
_, port, _, _ = serv.addr
|
2005-06-03 12:11:40 -04:00
|
|
|
t = Thread.new {
|
2005-06-03 14:03:52 -04:00
|
|
|
proxy = Net::HTTP.Proxy("127.0.0.1", port, 'user', 'password')
|
2005-06-03 12:11:40 -04:00
|
|
|
http = proxy.new("foo.example.org", 8000)
|
|
|
|
http.use_ssl = true
|
2005-06-03 12:49:56 -04:00
|
|
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
2005-06-03 14:03:52 -04:00
|
|
|
http.start
|
2005-06-03 12:11:40 -04:00
|
|
|
}
|
|
|
|
sock = serv.accept
|
|
|
|
proxy_request = sock.gets("\r\n\r\n")
|
|
|
|
assert_equal(
|
|
|
|
"CONNECT foo.example.org:8000 HTTP/1.1\r\n" +
|
|
|
|
"Host: foo.example.org:8000\r\n" +
|
|
|
|
"Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA==\r\n" +
|
|
|
|
"\r\n",
|
2005-06-03 13:14:06 -04:00
|
|
|
proxy_request,
|
|
|
|
"[ruby-dev:25673]")
|
2005-06-03 12:11:40 -04:00
|
|
|
}
|
|
|
|
end
|
2005-06-06 22:49:16 -04:00
|
|
|
end if defined?(OpenSSL)
|
2005-06-03 12:11:40 -04:00
|
|
|
|