diff options
author | rick <rick@spacemonkey.local> | 2008-05-06 02:58:32 -0700 |
---|---|---|
committer | rick <rick@spacemonkey.local> | 2008-05-06 02:58:32 -0700 |
commit | c8451aeeea200043d8a3e6eae9c49def3a154ddb (patch) | |
tree | 95def589e8b777cd641809a9af39e7eaea044960 /actionpack/test/controller/request_forgery_protection_test.rb | |
parent | 92e2e5990cc2aa4f699c286ac5d1f73e27ede548 (diff) | |
download | rails-c8451aeeea200043d8a3e6eae9c49def3a154ddb.tar.gz rails-c8451aeeea200043d8a3e6eae9c49def3a154ddb.tar.bz2 rails-c8451aeeea200043d8a3e6eae9c49def3a154ddb.zip |
change ActionController::RequestForgeryProtection to use Mime::Type#verify_request? [#73]
Diffstat (limited to 'actionpack/test/controller/request_forgery_protection_test.rb')
-rw-r--r-- | actionpack/test/controller/request_forgery_protection_test.rb | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index 295075fed4..833e8d8e00 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -107,19 +107,61 @@ module RequestForgeryProtectionTests end def test_should_not_allow_api_formatted_post_without_token - assert_raises(ActionController::InvalidAuthenticityToken) do + assert_raises(ActionController::InvalidAuthenticityToken) do post :index, :format => 'xml' end end - def test_should_not_allow_put_without_token + def test_should_not_allow_api_formatted_put_without_token assert_raises(ActionController::InvalidAuthenticityToken) do put :index, :format => 'xml' end end - def test_should_not_allow_delete_without_token + def test_should_not_allow_api_formatted_delete_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + delete :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_post_sent_as_url_encoded_form_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s + post :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_put_sent_as_url_encoded_form_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s + put :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_delete_sent_as_url_encoded_form_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::URL_ENCODED_FORM.to_s + delete :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_post_sent_as_multipart_form_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s + post :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_put_sent_as_multipart_form_without_token + assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s + put :index, :format => 'xml' + end + end + + def test_should_not_allow_api_formatted_delete_sent_as_multipart_form_without_token assert_raises(ActionController::InvalidAuthenticityToken) do + @request.env['CONTENT_TYPE'] = Mime::MULTIPART_FORM.to_s delete :index, :format => 'xml' end end |