diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-01-09 21:34:15 +0000 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-01-09 21:34:15 +0000 |
commit | 4fe1a1d68234197d5303ad7323dd91636b84db14 (patch) | |
tree | e66779ac77cd3ab8d9b39f6957e7e06fa2a4ae4e /vendor/plugins/exception_notification/test | |
parent | bb87d842ec3559483a2c0132dbc0c216e0cb597e (diff) | |
parent | 19a0a2fedf68a256084d4dcfd70b9cb9377b9a09 (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 |