diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-09 11:24:45 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-09 11:24:45 +0000 |
commit | 84190999aa57c5ea6e87f51adadde58d56b22682 (patch) | |
tree | eaf3ba72aa272b549b4d1544204e4c5eb3e09c55 /vendor/plugins/exception_notification/test | |
parent | 74c8ca35eb45554a42cbda91c7896d4d03a18fa6 (diff) | |
parent | 322fb0a831a3da55421ea7f131785989d064bdb2 (diff) |
Merge branch 'release/0.5' of github.com:sebbacon/alaveteli into release/0.5
Diffstat (limited to 'vendor/plugins/exception_notification/test')
-rw-r--r-- | vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb | 62 | ||||
-rw-r--r-- | vendor/plugins/exception_notification/test/test_helper.rb | 8 |
2 files changed, 70 insertions, 0 deletions
diff --git a/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb b/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb new file mode 100644 index 000000000..e077f405b --- /dev/null +++ b/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb @@ -0,0 +1,62 @@ +require 'test_helper' +require 'exception_notification/notifier_helper' + +class ExceptionNotifierHelperTest < Test::Unit::TestCase + + class ExceptionNotifierHelperIncludeTarget + include ExceptionNotification::NotifierHelper + end + + def setup + @helper = ExceptionNotifierHelperIncludeTarget.new + end + + # No controller + + def test_should_not_exclude_raw_post_parameters_if_no_controller + assert !@helper.exclude_raw_post_parameters? + end + + # Controller, no filtering + + class ControllerWithoutFilterParameters; end + + def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters + stub_controller(ControllerWithoutFilterParameters.new) + assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret") + end + def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters + stub_controller(ControllerWithoutFilterParameters.new) + assert !@helper.exclude_raw_post_parameters? + end + def test_should_return_params_if_controller_can_not_filter_parameters + stub_controller(ControllerWithoutFilterParameters.new) + assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params) + end + + # Controller with filtering + + class ControllerWithFilterParameters + def filter_parameters(params) + { "PARAM" => ExceptionNotification::NotifierHelper::PARAM_FILTER_REPLACEMENT } + end + end + + def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters + stub_controller(ControllerWithFilterParameters.new) + assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret") + end + def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters + stub_controller(ControllerWithFilterParameters.new) + assert @helper.exclude_raw_post_parameters? + end + def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters + stub_controller(ControllerWithFilterParameters.new) + assert_equal({"PARAM" => "[FILTERED]" }, @helper.filter_sensitive_post_data_parameters({"PARAM" => 'secret'})) + end + + private + def stub_controller(controller) + @helper.instance_variable_set(:@controller, controller) + end +end
\ No newline at end of file diff --git a/vendor/plugins/exception_notification/test/test_helper.rb b/vendor/plugins/exception_notification/test/test_helper.rb new file mode 100644 index 000000000..5831a1784 --- /dev/null +++ b/vendor/plugins/exception_notification/test/test_helper.rb @@ -0,0 +1,8 @@ +require 'test/unit' +require 'rubygems' +require 'active_support' + +RAILS_ROOT = '.' unless defined?(RAILS_ROOT) + +$:.unshift File.join(File.dirname(__FILE__), '../lib') +require 'exception_notification'
\ No newline at end of file |