mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Binder fixes for 4.2.1 (#2006)
* Adds failing test for #1986. We now have failing tests for both that issue and #1994 * Fix #1986. Fix #1994 * Fixup and reorder test a bit Original test was using localhost + port 0 for ssl, two things which will not be corretly supported in 4.2.1. Instead, test for 127.0.0.1 and a real port with SSL, which we do support correctly today. Also re-use test method for the ssl test.
This commit is contained in:
parent
e0cf703f3b
commit
47f7c7fb2d
2 changed files with 30 additions and 3 deletions
|
@ -105,6 +105,7 @@ module Puma
|
|||
io = add_tcp_listener uri.host, uri.port, opt, bak
|
||||
|
||||
@ios.each do |i|
|
||||
next unless TCPServer === i
|
||||
addr = if i.local_address.ipv6?
|
||||
"[#{i.local_address.ip_unpack[0]}]:#{i.local_address.ip_unpack[1]}"
|
||||
else
|
||||
|
|
|
@ -66,12 +66,38 @@ class TestBinder < TestBinderBase
|
|||
end
|
||||
end
|
||||
|
||||
def test_correct_doublebind
|
||||
@binder.parse(["ssl://localhost:0?key=#{key}&cert=#{cert}", "tcp://localhost:0"], @events)
|
||||
def test_allows_both_ssl_and_tcp
|
||||
assert_parsing_logs_uri [:ssl, :tcp]
|
||||
end
|
||||
|
||||
def test_allows_both_unix_and_tcp
|
||||
assert_parsing_logs_uri [:unix, :tcp]
|
||||
end
|
||||
|
||||
def test_allows_both_tcp_and_unix
|
||||
assert_parsing_logs_uri [:tcp, :unix]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_parsing_logs_uri(order = [:unix, :tcp])
|
||||
skip UNIX_SKT_MSG if order.include?(:unix) && !UNIX_SKT_EXIST
|
||||
|
||||
prepared_paths = {
|
||||
ssl: "ssl://127.0.0.1:#{UniquePort.call}?key=#{key}&cert=#{cert}",
|
||||
tcp: "tcp://127.0.0.1:#{UniquePort.call}",
|
||||
unix: "unix://test/#{name}_server.sock"
|
||||
}
|
||||
|
||||
tested_paths = [prepared_paths[order[0]], prepared_paths[order[1]]]
|
||||
|
||||
@binder.parse(tested_paths, @events)
|
||||
stdout = @events.stdout.string
|
||||
|
||||
# Unsure of what to actually assert on here yet
|
||||
assert stdout.include?(prepared_paths[order[0]]), "\n#{stdout}\n"
|
||||
assert stdout.include?(prepared_paths[order[1]]), "\n#{stdout}\n"
|
||||
ensure
|
||||
@binder.close_unix_paths if order.include?(:unix) && UNIX_SKT_EXIST
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue