Upgrade to Rails 2.0.2
Upgraded to Rails 2.0.2, except that we maintain vendor/rails/actionpack/lib/action_controller/routing.rb from Rail 1.2.6 (at least for now), so that Routes don't change. We still get to enjoy Rails's many new features. Also fixed a bug in Chunk-handling: disable WikiWord processing in tags (for real this time).
This commit is contained in:
parent
0f6889e09f
commit
6873fc8026
1083 changed files with 52810 additions and 41058 deletions
54
vendor/rails/actionpack/test/controller/http_authentication_test.rb
vendored
Normal file
54
vendor/rails/actionpack/test/controller/http_authentication_test.rb
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
require File.dirname(__FILE__) + '/../abstract_unit'
|
||||
|
||||
class HttpBasicAuthenticationTest < Test::Unit::TestCase
|
||||
include ActionController::HttpAuthentication::Basic
|
||||
|
||||
class DummyController
|
||||
attr_accessor :headers, :renders, :request
|
||||
|
||||
def initialize
|
||||
@headers, @renders = {}, []
|
||||
@request = ActionController::TestRequest.new
|
||||
end
|
||||
|
||||
def render(options)
|
||||
self.renders << options
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@controller = DummyController.new
|
||||
@credentials = ActionController::HttpAuthentication::Basic.encode_credentials("dhh", "secret")
|
||||
end
|
||||
|
||||
def test_successful_authentication
|
||||
login = Proc.new { |user_name, password| user_name == "dhh" && password == "secret" }
|
||||
set_headers
|
||||
assert authenticate(@controller, &login)
|
||||
|
||||
set_headers ''
|
||||
assert_nothing_raised do
|
||||
assert !authenticate(@controller, &login)
|
||||
end
|
||||
|
||||
set_headers nil
|
||||
set_headers @credentials, 'REDIRECT_X_HTTP_AUTHORIZATION'
|
||||
assert authenticate(@controller, &login)
|
||||
end
|
||||
|
||||
def test_failing_authentication
|
||||
set_headers
|
||||
assert !authenticate(@controller) { |user_name, password| user_name == "dhh" && password == "incorrect" }
|
||||
end
|
||||
|
||||
def test_authentication_request
|
||||
authentication_request(@controller, "Megaglobalapp")
|
||||
assert_equal 'Basic realm="Megaglobalapp"', @controller.headers["WWW-Authenticate"]
|
||||
assert_equal :unauthorized, @controller.renders.first[:status]
|
||||
end
|
||||
|
||||
private
|
||||
def set_headers(value = @credentials, name = 'HTTP_AUTHORIZATION')
|
||||
@controller.request.env[name] = value
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue