aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/http_authentication_test.rb
diff options
context:
space:
mode:
authorAhmed El-Daly <aeldaly@developergurus.com>2009-01-29 23:04:49 -0500
committerAhmed El-Daly <aeldaly@developergurus.com>2009-01-29 23:04:49 -0500
commit43d63298f7693a437b454b4b8ee84946af350572 (patch)
tree55166f7c3118061a1fd0df2cb3cf6ea6e31647b9 /actionpack/test/controller/http_authentication_test.rb
parent6623e4f92a69c2aa0a12957db430b00690d50d19 (diff)
parent24b688d31d34dc7582c8e2ac4347d0c36e3c5e10 (diff)
downloadrails-43d63298f7693a437b454b4b8ee84946af350572.tar.gz
rails-43d63298f7693a437b454b4b8ee84946af350572.tar.bz2
rails-43d63298f7693a437b454b4b8ee84946af350572.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/controller/http_authentication_test.rb')
-rw-r--r--actionpack/test/controller/http_authentication_test.rb54
1 files changed, 0 insertions, 54 deletions
diff --git a/actionpack/test/controller/http_authentication_test.rb b/actionpack/test/controller/http_authentication_test.rb
deleted file mode 100644
index c0069e8032..0000000000
--- a/actionpack/test/controller/http_authentication_test.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-require '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