@@ -29,6 +29,7 @@ def to_s
2929 def setup
3030 super
3131 @client = Raygun ::Client . new
32+ Raygun . configuration . record_raw_data = true
3233 fake_successful_entry
3334
3435 # Force NZ time zone for utcOffset tests
@@ -222,15 +223,36 @@ def test_getting_request_information_with_nil_env
222223 assert_equal ( { } , @client . send ( :request_information , nil ) )
223224 end
224225
225- def test_non_form_parameters
226- put_body_env_hash = sample_env_hash . merge ( {
227- "REQUEST_METHOD" => "PUT" ,
228- "action_dispatch.request.parameters" => { "a" => "b" , "c" => "4945438" , "password" => "swordfish" }
226+ def test_raw_post_body
227+ env_hash = sample_env_hash . merge ( {
228+ "CONTENT_TYPE" => "application/json" ,
229+ "REQUEST_METHOD" => "POST" ,
230+ "rack.input" => StringIO . new ( '{"foo": "bar"}' )
229231 } )
230232
231- expected_form_hash = { "a" => "b" , "c" => "4945438" , "password" => "[FILTERED]" }
233+ assert_equal '{"foo": "bar"}' , @client . send ( :request_information , env_hash ) [ :rawData ]
234+ end
235+
236+ def test_raw_post_body_with_more_than_4096_chars
237+ input = "0" * 5000 ;
238+ env_hash = sample_env_hash . merge ( {
239+ "CONTENT_TYPE" => "application/json" ,
240+ "REQUEST_METHOD" => "POST" ,
241+ "rack.input" => StringIO . new ( input )
242+ } )
232243
233- assert_equal expected_form_hash , @client . send ( :request_information , put_body_env_hash ) [ :rawData ]
244+ assert_equal input . slice ( 0 , 4096 ) , @client . send ( :request_information , env_hash ) [ :rawData ]
245+ end
246+
247+ def test_raw_post_body_with_config_disabled
248+ Raygun . configuration . record_raw_data = false
249+ env_hash = sample_env_hash . merge ( {
250+ "CONTENT_TYPE" => "application/json" ,
251+ "REQUEST_METHOD" => "POST" ,
252+ "rack.input" => StringIO . new ( '{"foo": "bar"}' )
253+ } )
254+
255+ assert_equal ( nil , @client . send ( :request_information , env_hash ) [ :rawData ] )
234256 end
235257
236258 def test_error_raygun_custom_data
@@ -461,6 +483,7 @@ def test_filter_payload_with_whitelist_default_request_post
461483 Raygun . configuration . filter_payload_with_whitelist = true
462484
463485 post_body_env_hash = sample_env_hash . merge (
486+ "CONTENT_TYPE" => 'application/x-www-form-urlencoded' ,
464487 "REQUEST_METHOD" => "POST" ,
465488 "rack.input" => StringIO . new ( "a=b&c=4945438&password=swordfish" )
466489 )
@@ -475,7 +498,7 @@ def test_filter_payload_with_whitelist_default_request_post
475498 queryString : { } ,
476499 headers : { "Version" => "HTTP/1.1" , "Host" => "localhost:3000" , "Cookie" => "cookieval" } ,
477500 form : { "a" => "[FILTERED]" , "c" => "[FILTERED]" , "password" => "[FILTERED]" } ,
478- rawData : nil
501+ rawData : { }
479502 }
480503
481504 assert_equal expected_hash , details [ :request ]
@@ -506,7 +529,7 @@ def test_filter_payload_with_whitelist_request_post_except_formkey
506529 queryString : { } ,
507530 headers : { "Version" => "HTTP/1.1" , "Host" => "localhost:3000" , "Cookie" => "cookieval" } ,
508531 form : { "username" => "foo" , "password" => "[FILTERED]" } ,
509- rawData : nil
532+ rawData : { }
510533 }
511534
512535 assert_equal expected_hash , details [ :request ]
0 commit comments