PATH:
opt
/
alt
/
ruby20
/
lib64
/
ruby
/
gems
/
2.0.0
/
gems
/
rack-1.6.4
/
test
require 'rack/auth/basic' require 'rack/lint' require 'rack/mock' describe Rack::Auth::Basic do def realm 'WallysWorld' end def unprotected_app Rack::Lint.new lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, ["Hi #{env['REMOTE_USER']}"] ] } end def protected_app app = Rack::Auth::Basic.new(unprotected_app) { |username, password| 'Boss' == username } app.realm = realm app end before do @request = Rack::MockRequest.new(protected_app) end def request_with_basic_auth(username, password, &block) request 'HTTP_AUTHORIZATION' => 'Basic ' + ["#{username}:#{password}"].pack("m*"), &block end def request(headers = {}) yield @request.get('/', headers) end def assert_basic_auth_challenge(response) response.should.be.a.client_error response.status.should.equal 401 response.should.include 'WWW-Authenticate' response.headers['WWW-Authenticate'].should =~ /Basic realm="#{Regexp.escape(realm)}"/ response.body.should.be.empty end should 'challenge correctly when no credentials are specified' do request do |response| assert_basic_auth_challenge response end end should 'rechallenge if incorrect credentials are specified' do request_with_basic_auth 'joe', 'password' do |response| assert_basic_auth_challenge response end end should 'return application output if correct credentials are specified' do request_with_basic_auth 'Boss', 'password' do |response| response.status.should.equal 200 response.body.to_s.should.equal 'Hi Boss' end end should 'return 400 Bad Request if different auth scheme used' do request 'HTTP_AUTHORIZATION' => 'Digest params' do |response| response.should.be.a.client_error response.status.should.equal 400 response.should.not.include 'WWW-Authenticate' end end should 'return 400 Bad Request for a malformed authorization header' do request 'HTTP_AUTHORIZATION' => '' do |response| response.should.be.a.client_error response.status.should.equal 400 response.should.not.include 'WWW-Authenticate' end end it 'takes realm as optional constructor arg' do app = Rack::Auth::Basic.new(unprotected_app, realm) { true } realm.should == app.realm end end
[-] spec_fastcgi.rb
[edit]
[-] spec_session_pool.rb
[edit]
[-] spec_auth_basic.rb
[edit]
[-] spec_head.rb
[edit]
[-] spec_multipart.rb
[edit]
[-] spec_builder.rb
[edit]
[-] spec_config.rb
[edit]
[-] spec_recursive.rb
[edit]
[-] spec_runtime.rb
[edit]
[-] spec_server.rb
[edit]
[+]
multipart
[-] spec_commonlogger.rb
[edit]
[-] spec_nulllogger.rb
[edit]
[-] spec_file.rb
[edit]
[-] spec_rewindable_input.rb
[edit]
[+]
registering_handler
[-] spec_sendfile.rb
[edit]
[+]
unregistered_handler
[-] spec_mock.rb
[edit]
[+]
static
[-] spec_tempfile_reaper.rb
[edit]
[-] spec_content_type.rb
[edit]
[-] spec_urlmap.rb
[edit]
[-] spec_lint.rb
[edit]
[-] spec_methodoverride.rb
[edit]
[-] spec_session_memcache.rb
[edit]
[-] spec_utils.rb
[edit]
[-] spec_content_length.rb
[edit]
[-] spec_cgi.rb
[edit]
[-] spec_auth_digest.rb
[edit]
[-] spec_thin.rb
[edit]
[-] spec_showstatus.rb
[edit]
[-] spec_lock.rb
[edit]
[-] spec_mongrel.rb
[edit]
[-] spec_etag.rb
[edit]
[-] spec_chunked.rb
[edit]
[+]
..
[-] spec_request.rb
[edit]
[-] spec_body_proxy.rb
[edit]
[-] spec_static.rb
[edit]
[-] spec_cascade.rb
[edit]
[-] spec_showexceptions.rb
[edit]
[-] spec_session_abstract_id.rb
[edit]
[-] spec_directory.rb
[edit]
[+]
rackup
[-] spec_handler.rb
[edit]
[-] spec_version.rb
[edit]
[-] testrequest.rb
[edit]
[-] spec_conditionalget.rb
[edit]
[-] spec_logger.rb
[edit]
[-] spec_mime.rb
[edit]
[-] spec_response.rb
[edit]
[-] spec_webrick.rb
[edit]
[+]
cgi
[-] gemloader.rb
[edit]
[-] spec_deflater.rb
[edit]
[-] spec_session_cookie.rb
[edit]
[-] spec_lobster.rb
[edit]
[+]
builder