mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
90e9b27800
* Integrate Percy.io for visual regression tests * Configure Travis so Percy runs on latest ruby only. * Wrap Percy::Capybara in a helper method * Lock capybara and related testing gems to major versions * Adjust Percy.io integration so PERCY_ENV=0 prevents Percy from being required
54 lines
1.1 KiB
Ruby
54 lines
1.1 KiB
Ruby
# encoding: utf-8
|
|
# frozen_string_literal: true
|
|
require_relative 'helper'
|
|
require 'sidekiq/web'
|
|
require 'rack/test'
|
|
|
|
class TestWebAuth < Sidekiq::Test
|
|
describe 'sidekiq web with basic auth' do
|
|
include Rack::Test::Methods
|
|
|
|
def app
|
|
app = Sidekiq::Web.new
|
|
app.use(Rack::Auth::Basic) { |user, pass| user == "a" && pass == "b" }
|
|
|
|
app
|
|
end
|
|
|
|
it 'requires basic authentication' do
|
|
get '/'
|
|
|
|
assert_equal 401, last_response.status
|
|
refute_nil last_response.header["WWW-Authenticate"]
|
|
end
|
|
|
|
it 'authenticates successfuly' do
|
|
basic_authorize 'a', 'b'
|
|
|
|
get '/'
|
|
|
|
assert_equal 200, last_response.status
|
|
end
|
|
end
|
|
|
|
describe 'sidekiq web with custom session' do
|
|
include Rack::Test::Methods
|
|
|
|
def app
|
|
app = Sidekiq::Web.new
|
|
|
|
app.use Rack::Session::Cookie, secret: 'v3rys3cr31', host: 'nicehost.org'
|
|
|
|
app
|
|
end
|
|
|
|
it 'requires basic authentication' do
|
|
get '/'
|
|
|
|
session_options = last_request.env['rack.session'].options
|
|
|
|
assert_equal 'v3rys3cr31', session_options[:secret]
|
|
assert_equal 'nicehost.org', session_options[:host]
|
|
end
|
|
end
|
|
end
|