Sha256: e151d5079da260ea7eb6d09cc515e35639e1965cc685dc90fb40c7a7145b552e
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-5.0.0.beta1 | test/test_web_auth.rb |