Skip to content

Commit

Permalink
Make Rack::Auth handlers compatible with Rack::ShowStatus
Browse files Browse the repository at this point in the history
darcs-hash:20070403201720-5d7f7-94eac54327fa04f61552b8fa5de2b1eb81b3886b.gz
  • Loading branch information
Tim Fletcher committed Apr 3, 2007
1 parent 6e640a6 commit 9879a29
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
8 changes: 2 additions & 6 deletions lib/rack/auth/abstract/handler.rb
Expand Up @@ -9,15 +9,11 @@ def initialize(app, &authenticator)
end

def unauthorized(www_authenticate = challenge)
headers = {
'Content-Type' => 'text/html',
'WWW-Authenticate' => www_authenticate.to_s
}
return [ 401, headers, ['<h1>401 Unauthorized</h1>'] ]
return [ 401, { 'WWW-Authenticate' => www_authenticate.to_s }, [] ]
end

def bad_request
[ 400, { 'Content-Type' => 'text/html' }, ['<h1>400 Bad Request</h1>'] ]
[ 400, {}, [] ]
end

end
Expand Down
3 changes: 2 additions & 1 deletion test/spec_rack_auth_basic.rb
@@ -1,5 +1,6 @@
require 'test/spec'
require 'base64'
require 'rack'

context 'Rack::Auth::Basic' do

Expand Down Expand Up @@ -34,7 +35,7 @@ def assert_basic_auth_challenge(response)
response.status.should.equal 401
response.should.include 'WWW-Authenticate'
response.headers['WWW-Authenticate'].should =~ /Basic realm="/
response.should =~ /401 Unauthorized/
response.body.should.be.empty
end

specify 'should challenge correctly when no credentials are specified' do
Expand Down
2 changes: 1 addition & 1 deletion test/spec_rack_auth_digest.rb
Expand Up @@ -90,7 +90,7 @@ def assert_digest_auth_challenge(response)
response.status.should.equal 401
response.should.include 'WWW-Authenticate'
response.headers['WWW-Authenticate'].should =~ /^Digest /
response.should =~ /401 Unauthorized/
response.body.should.be.empty
end

def assert_bad_request(response)
Expand Down

0 comments on commit 9879a29

Please sign in to comment.