upgpkg: wordpress 6.2.1-1
[ArchLinux/community.git] / ruby-puma / trunk / ruby-puma_fix_tests.patch
blob525b7aa4a1f99de9ddb139453775eb0fe0a9af5b
1 diff --git a/test/config/ssl_self_signed_config.rb b/test/config/ssl_self_signed_config.rb
2 deleted file mode 100644
3 index d70b51d1..00000000
4 --- a/test/config/ssl_self_signed_config.rb
5 +++ /dev/null
6 @@ -1,7 +0,0 @@
7 -require "localhost"
9 -ssl_bind "0.0.0.0", 9292
11 -app do |env|
12 - [200, {}, ["self-signed certificate app"]]
13 -end
14 diff --git a/test/test_config.rb b/test/test_config.rb
15 index 56f31ca0..a8497190 100644
16 --- a/test/test_config.rb
17 +++ b/test/test_config.rb
18 @@ -58,22 +58,6 @@ class TestConfigFile < TestConfigFileBase
19 assert_equal [200, {}, ["embedded app"]], app.call({})
20 end
22 - def test_ssl_self_signed_configuration_from_DSL
23 - skip_if :jruby
24 - skip_unless :ssl
25 - conf = Puma::Configuration.new do |config|
26 - config.load "test/config/ssl_self_signed_config.rb"
27 - end
29 - conf.load
31 - bind_configuration = conf.options.file_options[:binds].first
32 - app = conf.app
34 - ssl_binding = "ssl://0.0.0.0:9292?&verify_mode=none"
35 - assert_equal [ssl_binding], conf.options[:binds]
36 - end
38 def test_ssl_bind
39 skip_if :jruby
40 skip_unless :ssl
41 diff --git a/test/test_integration_single.rb b/test/test_integration_single.rb
42 index fd930fe6..cb5e202c 100644
43 --- a/test/test_integration_single.rb
44 +++ b/test/test_integration_single.rb
45 @@ -85,7 +85,7 @@ class TestIntegrationSingle < TestIntegration
46 rejected_curl_wait_thread.join
48 assert_match(/Slept 10/, curl_stdout.read)
49 - assert_match(/Connection refused/, rejected_curl_stderr.read)
50 + assert_match(/Connection refused|Couldn't connect to server/, rejected_curl_stderr.read)
52 Process.wait(@server.pid)
53 @server.close unless @server.closed?
54 diff --git a/test/test_integration_ssl.rb b/test/test_integration_ssl.rb
55 index 3c05b419..f74e1f8d 100644
56 --- a/test/test_integration_ssl.rb
57 +++ b/test/test_integration_ssl.rb
58 @@ -152,30 +152,6 @@ RUBY
60 activate_control_app 'tcp://#{HOST}:#{control_tcp_port}', { auth_token: '#{TOKEN}' }
62 -app do |env|
63 - [200, {}, [env['rack.url_scheme']]]
64 -end
65 -RUBY
67 - with_server(config) do |http|
68 - body = nil
69 - http.start do
70 - req = Net::HTTP::Get.new '/', {}
71 - http.request(req) { |resp| body = resp.body }
72 - end
73 - assert_equal 'https', body
74 - end
75 - end
77 - def test_ssl_run_with_localhost_authority
78 - skip_if :jruby
80 - config = <<RUBY
81 - require 'localhost'
82 - ssl_bind '#{HOST}', '#{bind_port}'
84 -activate_control_app 'tcp://#{HOST}:#{control_tcp_port}', { auth_token: '#{TOKEN}' }
86 app do |env|
87 [200, {}, [env['rack.url_scheme']]]
88 end
89 diff --git a/test/test_launcher.rb b/test/test_launcher.rb
90 index 370e0c38..05257020 100644
91 --- a/test/test_launcher.rb
92 +++ b/test/test_launcher.rb
93 @@ -13,9 +13,9 @@ class TestLauncher < Minitest::Test
94 dirs = launcher.send(:files_to_require_after_prune)
96 assert_equal(2, dirs.length)
97 - assert_match(%r{puma/lib$}, dirs[0]) # lib dir
98 - assert_match(%r{puma-#{Puma::Const::PUMA_VERSION}$}, dirs[1]) # native extension dir
99 - refute_match(%r{gems/rdoc-[\d.]+/lib$}, dirs[2])
100 + assert_match(%r{/build/ruby-puma/src/puma-#{Puma::Const::PUMA_VERSION}/lib$}, dirs[0]) # lib dir
101 + assert_match(%r{/build/ruby-puma/src/extensions/x86_64-linux/3.0.0/puma-#{Puma::Const::PUMA_VERSION}$}, dirs[1]) # native extension dir
102 + refute_match(%r{/usr/lib/ruby/gems/3.0.0/gems/rdoc-[\d.]+/lib$}, dirs[2])
105 def test_files_to_require_after_prune_is_correctly_built_with_extra_deps
106 @@ -27,9 +27,9 @@ class TestLauncher < Minitest::Test
107 dirs = launcher(conf).send(:files_to_require_after_prune)
109 assert_equal(3, dirs.length)
110 - assert_match(%r{puma/lib$}, dirs[0]) # lib dir
111 - assert_match(%r{puma-#{Puma::Const::PUMA_VERSION}$}, dirs[1]) # native extension dir
112 - assert_match(%r{gems/rdoc-[\d.]+/lib$}, dirs[2]) # rdoc dir
113 + assert_match(%r{/build/ruby-puma/src/puma-#{Puma::Const::PUMA_VERSION}/lib$}, dirs[0]) # lib dir
114 + assert_match(%r{/build/ruby-puma/src/extensions/x86_64-linux/3.0.0/puma-#{Puma::Const::PUMA_VERSION}$}, dirs[1]) # native extension dir
115 + assert_match(%r{/usr/lib/ruby/gems/3.0.0/gems/rdoc-[\d.]+/lib$}, dirs[2])
118 def test_extra_runtime_deps_directories_is_empty_for_no_config
119 diff --git a/test/test_preserve_bundler_env.rb b/test/test_preserve_bundler_env.rb
120 deleted file mode 100644
121 index 2a2692ea..00000000
122 --- a/test/test_preserve_bundler_env.rb
123 +++ /dev/null
124 @@ -1,110 +0,0 @@
125 -require_relative "helper"
126 -require_relative "helpers/integration"
128 -class TestPreserveBundlerEnv < TestIntegration
129 - def setup
130 - skip_unless :fork
131 - super
132 - end
134 - def teardown
135 - return if skipped?
136 - FileUtils.rm current_release_symlink, force: true
137 - super
138 - end
140 - # It does not wipe out BUNDLE_GEMFILE et al
141 - def test_usr2_restart_preserves_bundler_environment
142 - skip_unless_signal_exist? :USR2
144 - @tcp_port = UniquePort.call
145 - env = {
146 - # Intentionally set this to something we wish to keep intact on restarts
147 - "BUNDLE_GEMFILE" => "Gemfile.bundle_env_preservation_test",
148 - # Don't allow our (rake test's) original env to interfere with the child process
149 - "BUNDLER_ORIG_BUNDLE_GEMFILE" => nil
151 - # Must use `bundle exec puma` here, because otherwise Bundler may not be defined, which is required to trigger the bug
152 - cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}"
153 - Dir.chdir(File.expand_path("bundle_preservation_test", __dir__)) do
154 - @server = IO.popen(env, cmd.split, "r")
155 - end
156 - wait_for_server_to_boot
157 - @pid = @server.pid
158 - connection = connect
159 - initial_reply = read_body(connection)
160 - assert_match("Gemfile.bundle_env_preservation_test", initial_reply)
161 - restart_server connection
162 - new_reply = read_body(connection)
163 - assert_match("Gemfile.bundle_env_preservation_test", new_reply)
164 - end
166 - def test_worker_forking_preserves_bundler_config_path
167 - skip_unless_signal_exist? :TERM
169 - @tcp_port = UniquePort.call
170 - env = {
171 - # Disable the .bundle/config file in the bundle_app_config_test directory
172 - "BUNDLE_APP_CONFIG" => "/dev/null",
173 - # Don't allow our (rake test's) original env to interfere with the child process
174 - "BUNDLE_GEMFILE" => nil,
175 - "BUNDLER_ORIG_BUNDLE_GEMFILE" => nil
177 - cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}"
178 - Dir.chdir File.expand_path("bundle_app_config_test", __dir__) do
179 - @server = IO.popen(env, cmd.split, "r")
180 - end
181 - wait_for_server_to_boot
182 - @pid = @server.pid
183 - reply = read_body(connect)
184 - assert_equal("Hello World", reply)
185 - end
187 - def test_phased_restart_preserves_unspecified_bundle_gemfile
188 - skip_unless_signal_exist? :USR1
190 - @tcp_port = UniquePort.call
191 - env = {
192 - "BUNDLE_GEMFILE" => nil,
193 - "BUNDLER_ORIG_BUNDLE_GEMFILE" => nil
195 - set_release_symlink File.expand_path("bundle_preservation_test/version1", __dir__)
196 - cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}"
197 - Dir.chdir(current_release_symlink) do
198 - @server = IO.popen(env, cmd.split, "r")
199 - end
200 - wait_for_server_to_boot
201 - @pid = @server.pid
202 - connection = connect
204 - # Bundler itself sets ENV['BUNDLE_GEMFILE'] to the Gemfile it finds if ENV['BUNDLE_GEMFILE'] was unspecified
205 - initial_reply = read_body(connection)
206 - expected_gemfile = File.expand_path("bundle_preservation_test/version1/Gemfile", __dir__).inspect
207 - assert_equal(expected_gemfile, initial_reply)
209 - set_release_symlink File.expand_path("bundle_preservation_test/version2", __dir__)
210 - start_phased_restart
212 - connection = connect
213 - new_reply = read_body(connection)
214 - expected_gemfile = File.expand_path("bundle_preservation_test/version2/Gemfile", __dir__).inspect
215 - assert_equal(expected_gemfile, new_reply)
216 - end
218 - private
220 - def current_release_symlink
221 - File.expand_path "bundle_preservation_test/current", __dir__
222 - end
224 - def set_release_symlink(target_dir)
225 - FileUtils.rm current_release_symlink, force: true
226 - FileUtils.symlink target_dir, current_release_symlink, force: true
227 - end
229 - def start_phased_restart
230 - Process.kill :USR1, @pid
232 - true while @server.gets !~ /booted in [.0-9]+s, phase: 1/
233 - end
234 -end
235 diff --git a/test/test_puma_localhost_authority.rb b/test/test_puma_localhost_authority.rb
236 deleted file mode 100644
237 index 8599980b..00000000
238 --- a/test/test_puma_localhost_authority.rb
239 +++ /dev/null
240 @@ -1,95 +0,0 @@
241 -# Nothing in this file runs if Puma isn't compiled with ssl support
243 -# helper is required first since it loads Puma, which needs to be
244 -# loaded so HAS_SSL is defined
245 -require_relative "helper"
246 -require "localhost/authority"
248 -if ::Puma::HAS_SSL && !Puma::IS_JRUBY
249 - require "puma/minissl"
250 - require "net/http"
252 - # net/http (loaded in helper) does not necessarily load OpenSSL
253 - require "openssl" unless Object.const_defined? :OpenSSL
254 -end
256 -class TestPumaLocalhostAuthority < Minitest::Test
257 - parallelize_me!
258 - def setup
259 - @http = nil
260 - @server = nil
261 - end
263 - def teardown
264 - @http.finish if @http && @http.started?
265 - @server.stop(true) if @server
266 - end
268 - # yields ctx to block, use for ctx setup & configuration
269 - def start_server
270 - @host = "localhost"
271 - app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
273 - @events = SSLEventsHelper.new STDOUT, STDERR
274 - @server = Puma::Server.new app, @events
275 - @server.app = app
276 - @server.add_ssl_listener @host, 0,nil
277 - @http = Net::HTTP.new @host, @server.connected_ports[0]
279 - @http.use_ssl = true
280 - # Disabling verification since its self signed
281 - @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
282 - # @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
284 - @server.run
285 - end
287 - def test_localhost_authority_file_generated
288 - # Initiate server to create localhost authority
289 - unless File.exist?(File.join(Localhost::Authority.path,"localhost.key"))
290 - start_server
291 - end
292 - assert_equal(File.exist?(File.join(Localhost::Authority.path,"localhost.key")), true)
293 - assert_equal(File.exist?(File.join(Localhost::Authority.path,"localhost.crt")), true)
294 - end
296 -end if ::Puma::HAS_SSL && !Puma::IS_JRUBY
298 -class TestPumaSSLLocalhostAuthority < Minitest::Test
299 - def test_self_signed_by_localhost_authority
300 - @host = "localhost"
302 - app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
304 - @events = SSLEventsHelper.new STDOUT, STDERR
306 - @server = Puma::Server.new app, @events
307 - @server.app = app
309 - @server.add_ssl_listener @host, 0,nil
311 - @http = Net::HTTP.new @host, @server.connected_ports[0]
312 - @http.use_ssl = true
314 - OpenSSL::PKey::RSA.new File.read(File.join(Localhost::Authority.path,"localhost.key"))
315 - local_authority_crt = OpenSSL::X509::Certificate.new File.read(File.join(Localhost::Authority.path,"localhost.crt"))
317 - @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
318 - @server.run
319 - @cert = nil
320 - begin
321 - @http.start do
322 - req = Net::HTTP::Get.new "/", {}
323 - @http.request(req)
324 - @cert = @http.peer_cert
325 - end
326 - rescue OpenSSL::SSL::SSLError, EOFError, Errno::ECONNRESET
327 - # Errno::ECONNRESET TruffleRuby
328 - # closes socket if open, may not close on error
329 - @http.send :do_finish
330 - end
331 - sleep 0.1
333 - assert_equal(@cert.to_pem, local_authority_crt.to_pem)
334 - end
335 -end if ::Puma::HAS_SSL && !Puma::IS_JRUBY