Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binder fixes for 4.2.1 #2006

Merged
merged 3 commits into from Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/puma/binder.rb
Expand Up @@ -105,6 +105,7 @@ def parse(binds, logger)
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
Expand Down
32 changes: 29 additions & 3 deletions test/test_binder.rb
Expand Up @@ -66,12 +66,38 @@ def test_correct_zero_port_ssl
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

Expand Down