diff options
Diffstat (limited to 'test/system/oauth_provider_test.rb')
-rw-r--r-- | test/system/oauth_provider_test.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/test/system/oauth_provider_test.rb b/test/system/oauth_provider_test.rb index 897af72c0..364ed4c94 100644 --- a/test/system/oauth_provider_test.rb +++ b/test/system/oauth_provider_test.rb @@ -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, @@ -31,9 +32,9 @@ class OauthProviderSystemTest < ApplicationSystemTestCase check 'View Issues' click_button 'Create' - end - assert_text "Application created" + assert_text "Application created." + end assert app = Doorkeeper::Application.find_by_name('Oauth Test') @@ -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 |