class CustomAuthenticityParamControllerTest
Public Instance Methods
setup()
click to toggle source
Calls superclass method
# File actionpack/test/controller/request_forgery_protection_test.rb, line 740 def setup super @old_logger = ActionController::Base.logger @logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new @token = Base64.strict_encode64(SecureRandom.random_bytes(32)) @old_request_forgery_protection_token = ActionController::Base.request_forgery_protection_token ActionController::Base.request_forgery_protection_token = @token end
teardown()
click to toggle source
Calls superclass method
# File actionpack/test/controller/request_forgery_protection_test.rb, line 749 def teardown ActionController::Base.request_forgery_protection_token = @old_request_forgery_protection_token super end
test_should_not_warn_if_form_authenticity_param_matches_form_authenticity_token()
click to toggle source
# File actionpack/test/controller/request_forgery_protection_test.rb, line 754 def test_should_not_warn_if_form_authenticity_param_matches_form_authenticity_token ActionController::Base.logger = @logger begin @controller.stub :valid_authenticity_token?, :true do post :index, params: { custom_token_name: "foobar" } assert_equal 0, @logger.logged(:warn).size end ensure ActionController::Base.logger = @old_logger end end
test_should_warn_if_form_authenticity_param_does_not_match_form_authenticity_token()
click to toggle source
# File actionpack/test/controller/request_forgery_protection_test.rb, line 766 def test_should_warn_if_form_authenticity_param_does_not_match_form_authenticity_token ActionController::Base.logger = @logger begin post :index, params: { custom_token_name: "bazqux" } assert_equal 1, @logger.logged(:warn).size ensure ActionController::Base.logger = @old_logger end end