1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-10-17 17:01:01 +00:00

Replaces webrick server used in @OauthProviderSystemTest@ with puma (#24808).

git-svn-id: https://svn.redmine.org/redmine/trunk@23840 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2025-06-16 21:32:45 +00:00
parent eb1fcac5e4
commit 9186b8e64d
2 changed files with 14 additions and 9 deletions

View File

@ -121,7 +121,6 @@ group :test do
# for testing oauth provider capabilities
gem 'oauth2'
gem 'rest-client'
gem 'webrick'
end
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")

View File

@ -2,7 +2,8 @@
require_relative '../application_system_test_case'
require 'oauth2'
require 'webrick'
require 'rack'
require 'puma'
class OauthProviderSystemTest < ApplicationSystemTestCase
fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
@ -61,10 +62,10 @@ class OauthProviderSystemTest < ApplicationSystemTestCase
# launches webrick, listening for the redirect with the auth code.
launch_client_app(port: port) do |req, res|
# get access code from code url param
if code = req.query['code'].presence
if code = req.params['code'].presence
# exchange it for token
token = client.auth_code.get_token(code, redirect_uri: redirect_uri)
res.body = "<html><body><p>Authorization succeeded, you may close this window now.</p></body></html>"
res.body = ["<html><body><p>Authorization succeeded, you may close this window now.</p></body></html>"]
end
end
@ -118,11 +119,16 @@ class OauthProviderSystemTest < ApplicationSystemTestCase
private
def launch_client_app(port: 12345, path: '/', &block)
server = WEBrick::HTTPServer.new Port: port
trap('INT') { server.shutdown }
server.mount_proc(path, block)
Thread.new { server.start }
port
app = ->(env) do
req = Rack::Request.new(env)
res = Rack::Response.new
yield(req, res)
res.finish
end
server = Puma::Server.new app
server.add_tcp_listener '127.0.0.1', port
Thread.new { server.run }
end
def test_port