diff options
author | Michael Koziarski <michael@koziarski.com> | 2012-09-13 20:44:45 -0700 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2012-09-13 20:44:45 -0700 |
commit | bb732beba7c0c6f54b12eb774bc78790dd955b65 (patch) | |
tree | 7e7e7c0d59a74db292434ea9abc9136cb5d17a9b /actionpack/test | |
parent | 0247443debe3670b016495aa32602e82186bfce4 (diff) | |
parent | 95be790ece75710f2588558a6d5f40fd09543b97 (diff) | |
download | rails-bb732beba7c0c6f54b12eb774bc78790dd955b65.tar.gz rails-bb732beba7c0c6f54b12eb774bc78790dd955b65.tar.bz2 rails-bb732beba7c0c6f54b12eb774bc78790dd955b65.zip |
Merge pull request #7616 from lest/null-session-forgery-protection
Implement :null_session CSRF protection method
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/request_forgery_protection_test.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index 0289f4070b..1f637eb791 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -56,22 +56,18 @@ module RequestForgeryProtectionActions end # sample controllers -class RequestForgeryProtectionController < ActionController::Base +class RequestForgeryProtectionControllerUsingResetSession < ActionController::Base include RequestForgeryProtectionActions - protect_from_forgery :only => %w(index meta) + protect_from_forgery :only => %w(index meta), :with => :reset_session end class RequestForgeryProtectionControllerUsingException < ActionController::Base include RequestForgeryProtectionActions - protect_from_forgery :only => %w(index meta) - - def handle_unverified_request - raise(ActionController::InvalidAuthenticityToken) - end + protect_from_forgery :only => %w(index meta), :with => :exception end -class FreeCookieController < RequestForgeryProtectionController +class FreeCookieController < RequestForgeryProtectionControllerUsingResetSession self.allow_forgery_protection = false def index @@ -83,7 +79,7 @@ class FreeCookieController < RequestForgeryProtectionController end end -class CustomAuthenticityParamController < RequestForgeryProtectionController +class CustomAuthenticityParamController < RequestForgeryProtectionControllerUsingResetSession def form_authenticity_param 'foobar' end @@ -268,7 +264,7 @@ end # OK let's get our test on -class RequestForgeryProtectionControllerTest < ActionController::TestCase +class RequestForgeryProtectionControllerUsingResetSessionTest < ActionController::TestCase include RequestForgeryProtectionTests setup do |