@@ -105,4 +105,26 @@ defmodule Sentry.PlugTest do
105105 "is_admin" => false , "passwd" => "*********" , "credit_card" => "*********" , "cc" => "*********" ,
106106 "another_cc" => "*********" , "user" => % { "password" => "*********" } }
107107 end
108+
109+ test "handles data scrubbing with file upload" do
110+ bypass = Bypass . open
111+ Bypass . expect bypass , fn conn ->
112+ { :ok , body , conn } = Plug.Conn . read_body ( conn )
113+ json = Poison . decode! ( body )
114+ assert is_map ( json [ "request" ] [ "data" ] [ "image" ] )
115+ assert json [ "request" ] [ "data" ] [ "password" ] == "*********"
116+ Plug.Conn . resp ( conn , 200 , ~s< {"id": "340"}> )
117+ end
118+
119+ modify_env ( :sentry , dsn: "http://public:secret@localhost:#{ bypass . port } /1" )
120+ upload = % Plug.Upload { path: "test/fixtures/my_image.png" , filename: "my_image.png" }
121+
122+ assert_raise ( RuntimeError , "Error" , fn ->
123+ conn ( :post , "/error_route" , % { "image" => upload , "password" => "my_password" } )
124+ |> put_req_cookie ( "cookie_key" , "cookie_value" )
125+ |> put_req_header ( "accept-language" , "en-US" )
126+ |> put_req_header ( "authorization" , "ignorme" )
127+ |> Sentry.ExampleApp . call ( [ ] )
128+ end )
129+ end
108130end
0 commit comments