Skip to content

Commit

Permalink
Handle old rack-test
Browse files Browse the repository at this point in the history
Prior to 0.7 an argument is lacking to generate multipart requests
without uploading a file.
  • Loading branch information
lloeki committed Oct 11, 2022
1 parent 89b8b1c commit ca7e22e
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions spec/datadog/appsec/contrib/rack/integration_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,23 +229,25 @@
it_behaves_like 'a trace with AppSec events'
end

context 'with an event-triggering request in multipart/form-data body' do
let(:params) { Rack::Test::Utils.build_multipart({ q: '1 OR 1;' }, true, true) }
let(:headers) { { 'CONTENT_TYPE' => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}" } }

let(:middlewares) do
[
Datadog::Tracing::Contrib::Rack::TraceMiddleware,
Datadog::AppSec::Contrib::Rack::RequestMiddleware,
Datadog::AppSec::Contrib::Rack::RequestBodyMiddleware,
]
end
unless Gem.loaded_specs['rack-test'].version.to_s < '0.7'
context 'with an event-triggering request in multipart/form-data body' do
let(:params) { Rack::Test::Utils.build_multipart({ q: '1 OR 1;' }, true, true) }
let(:headers) { { 'CONTENT_TYPE' => "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}" } }

let(:middlewares) do
[
Datadog::Tracing::Contrib::Rack::TraceMiddleware,
Datadog::AppSec::Contrib::Rack::RequestMiddleware,
Datadog::AppSec::Contrib::Rack::RequestBodyMiddleware,
]
end

it { is_expected.to be_ok }
it { is_expected.to be_ok }

it_behaves_like 'a POST 200 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a POST 200 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
end
end

context 'with an event-triggering request as JSON' do
Expand Down

0 comments on commit ca7e22e

Please sign in to comment.