diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2011-03-28 18:09:50 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-03-28 18:10:08 -0700 |
commit | e2b07ee000439d0bd41f725ff9f7ad53e52a7e9b (patch) | |
tree | 0f49fd2489ad5e019d5bde163daefa0fe8babb6f /actionpack/test/controller | |
parent | aea1477362b640ebe52cf991b915ad32e7bf2571 (diff) | |
download | rails-e2b07ee000439d0bd41f725ff9f7ad53e52a7e9b.tar.gz rails-e2b07ee000439d0bd41f725ff9f7ad53e52a7e9b.tar.bz2 rails-e2b07ee000439d0bd41f725ff9f7ad53e52a7e9b.zip |
Added Base.http_basic_authenticate_with to do simple http basic authentication with a single class method call [DHH]
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/http_basic_authentication_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/actionpack/test/controller/http_basic_authentication_test.rb b/actionpack/test/controller/http_basic_authentication_test.rb index 01c650a494..bd3e13e6fa 100644 --- a/actionpack/test/controller/http_basic_authentication_test.rb +++ b/actionpack/test/controller/http_basic_authentication_test.rb @@ -6,6 +6,8 @@ class HttpBasicAuthenticationTest < ActionController::TestCase before_filter :authenticate_with_request, :only => :display before_filter :authenticate_long_credentials, :only => :show + http_basic_authenticate_with :name => "David", :password => "Goliath", :only => :search + def index render :text => "Hello Secret" end @@ -17,6 +19,10 @@ class HttpBasicAuthenticationTest < ActionController::TestCase def show render :text => 'Only for loooooong credentials' end + + def search + render :text => 'All inline' + end private @@ -104,6 +110,16 @@ class HttpBasicAuthenticationTest < ActionController::TestCase assert assigns(:logged_in) assert_equal 'Definitely Maybe', @response.body end + + test "authenticate with class method" do + @request.env['HTTP_AUTHORIZATION'] = encode_credentials('David', 'Goliath') + get :search + assert_response :success + + @request.env['HTTP_AUTHORIZATION'] = encode_credentials('David', 'WRONG!') + get :search + assert_response :unauthorized + end private |