From 69412b193307cbeedb1edf0d8e4d84df87a53247 Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Tue, 1 Oct 2019 11:12:57 +0200 Subject: [PATCH] Adds failing test for #1986. We now have failing tests for both that issue and #1994 --- test/test_binder.rb | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/test/test_binder.rb b/test/test_binder.rb index 882a798985..6a252c21cf 100644 --- a/test/test_binder.rb +++ b/test/test_binder.rb @@ -71,7 +71,45 @@ def test_correct_doublebind stdout = @events.stdout.string - # Unsure of what to actually assert on here yet + %w[tcp ssl].each do |prot| + assert_match %r!#{prot}://127.0.0.1:(\d+)!, stdout + if @binder.loopback_addresses.include?("::1") + assert_match %r!#{prot}://\[::1\]:(\d+)!, stdout + end + end + 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 unless UNIX_SKT_EXIST + + path_unix = "test/#{name}_server.sock" + uri_unix = "unix://#{path_unix}" + uri_tcp = "tcp://127.0.0.1:#{UniquePort.call}" + + if order == [:unix, :tcp] + @binder.parse([uri_tcp, uri_unix], @events) + elsif order == [:tcp, :unix] + @binder.parse([uri_unix, uri_tcp], @events) + else + raise ArgumentError + end + + stdout = @events.stdout.string + + assert stdout.include?(uri_unix), "\n#{stdout}\n" + assert stdout.include?(uri_tcp) , "\n#{stdout}\n" + ensure + @binder.close_unix_paths if UNIX_SKT_EXIST end end