Sha256: 799c04d1a734eb6c7d3955020f4d060295e4bde742e0e84e4b36286d1b3bae71

Contents?: true

Size: 1.83 KB

Versions: 37

Compression:

Stored size: 1.83 KB

Contents

require 'rack'

describe Rack::Auth do
  it "should have all common authentication schemes" do
    Rack::Auth.schemes.should.include? 'basic'
    Rack::Auth.schemes.should.include? 'digest'
    Rack::Auth.schemes.should.include? 'bearer'
    Rack::Auth.schemes.should.include? 'token'
  end

  it "should allow registration of new auth schemes" do
    Rack::Auth.schemes.should.not.include "test"
    Rack::Auth.add_scheme "test"
    Rack::Auth.schemes.should.include "test"
  end
end

describe Rack::Auth::AbstractRequest do
  it "should symbolize known auth schemes" do
    env = Rack::MockRequest.env_for('/')
    env['HTTP_AUTHORIZATION'] = 'Basic aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :basic


    env['HTTP_AUTHORIZATION'] = 'Digest aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :digest

    env['HTTP_AUTHORIZATION'] = 'Bearer aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :bearer

    env['HTTP_AUTHORIZATION'] = 'MAC aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :mac

    env['HTTP_AUTHORIZATION'] = 'Token aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :token

    env['HTTP_AUTHORIZATION'] = 'OAuth aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :oauth

    env['HTTP_AUTHORIZATION'] = 'OAuth2 aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should.equal :oauth2
  end

  it "should not symbolize unknown auth schemes" do
    env = Rack::MockRequest.env_for('/')
    env['HTTP_AUTHORIZATION'] = 'magic aXJyZXNwb25zaWJsZQ=='
    req = Rack::Auth::AbstractRequest.new(env)
    req.scheme.should == "magic"
  end
end

Version data entries

37 entries across 33 versions & 12 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
rack-1.4.7 test/spec_auth.rb
rack-1.4.6 test/spec_auth.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rack-1.4.5/test/spec_auth.rb
swipe-rails-0.0.5 vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/rack-1.4.5/test/spec_auth.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/rack-1.4.5/test/spec_auth.rb
challah-1.0.0.beta3 vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
challah-1.0.0.beta2 vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
challah-1.0.0.beta vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb