diff options
author | Jack McCracken <jack.mccracken@shopify.com> | 2017-10-02 16:35:13 -0400 |
---|---|---|
committer | Jack McCracken <jack.mccracken@shopify.com> | 2017-11-03 13:34:57 -0400 |
commit | acdba1c6a653bf5c787d3457af95b37708be1e2b (patch) | |
tree | c85ea841a78d034da6d4b139f87c8243c056a274 /actionpack/test | |
parent | 9ec67362054e874ed905310a79b670941fa397af (diff) | |
download | rails-acdba1c6a653bf5c787d3457af95b37708be1e2b.tar.gz rails-acdba1c6a653bf5c787d3457af95b37708be1e2b.tar.bz2 rails-acdba1c6a653bf5c787d3457af95b37708be1e2b.zip |
Add a better error message when a "null" Origin header occurs
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/request_forgery_protection_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb index eb3d2f34a8..4822d85bcb 100644 --- a/actionpack/test/controller/request_forgery_protection_test.rb +++ b/actionpack/test/controller/request_forgery_protection_test.rb @@ -446,6 +446,19 @@ module RequestForgeryProtectionTests end end + def test_should_raise_for_post_with_null_origin + forgery_protection_origin_check do + session[:_csrf_token] = @token + @controller.stub :form_authenticity_token, @token do + exception = assert_raises(ActionController::InvalidAuthenticityToken) do + @request.set_header "HTTP_ORIGIN", "null" + post :index, params: { custom_authenticity_token: @token } + end + assert_match "The browser returned a 'null' origin for a request", exception.message + end + end + end + def test_should_block_post_with_origin_checking_and_wrong_origin old_logger = ActionController::Base.logger logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new |