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.5 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.4 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.3 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/test/spec_auth.rb
graphael-on-rails-0.5.1 vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
graphael-on-rails-0.0.1 vendor/bundle/gems/rack-1.4.5/test/spec_auth.rb
rack-1.4.5 test/spec_auth.rb
rack-1.3.10 test/spec_auth.rb
rack-1.2.8 test/spec_auth.rb
devise_sociable-0.1.0 vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
backbone-queryparams-rails-0.0.1 vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
railscast-assets-0.0.2 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
railscast-assets-0.0.2 vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/rack-1.4.4/test/spec_auth.rb
rack-1.4.4 test/spec_auth.rb
rack-1.3.9 test/spec_auth.rb
rack-1.2.7 test/spec_auth.rb