Skip to content

Commit

Permalink
Add spec to validate appsec.blocked tag present
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Jun 5, 2023
1 parent 04e6ef0 commit 27ae1a7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
12 changes: 6 additions & 6 deletions spec/datadog/appsec/contrib/rack/integration_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand Down Expand Up @@ -295,7 +295,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand All @@ -315,7 +315,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down Expand Up @@ -360,7 +360,7 @@

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand Down Expand Up @@ -390,7 +390,7 @@

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down Expand Up @@ -430,7 +430,7 @@

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/datadog/appsec/contrib/rails/integration_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def set_user

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand All @@ -237,7 +237,7 @@ def set_user

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand All @@ -250,7 +250,7 @@ def set_user

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end

context 'with an event-triggering response' do
Expand Down Expand Up @@ -317,7 +317,7 @@ def set_user

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand All @@ -339,7 +339,7 @@ def set_user

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand All @@ -361,7 +361,7 @@ def set_user

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down Expand Up @@ -435,7 +435,7 @@ def set_user

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/datadog/appsec/contrib/sinatra/integration_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand Down Expand Up @@ -243,7 +243,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand All @@ -256,7 +256,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end

context 'with an event-triggering response' do
Expand Down Expand Up @@ -286,7 +286,7 @@

it_behaves_like 'a GET 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end
end
Expand Down Expand Up @@ -323,7 +323,7 @@

it_behaves_like 'a POST 403 span'
it_behaves_like 'a trace with AppSec tags'
it_behaves_like 'a trace with AppSec events'
it_behaves_like 'a trace with AppSec events', { blocking: true }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@
end
end

RSpec.shared_examples 'a trace with AppSec events' do
RSpec.shared_examples 'a trace with AppSec events' do |params = { blocking: false }|
let(:blocking_request) { params[:blocking] }

it do
expect(spans.select { |s| s.get_tag('appsec.event') }).to_not be_empty
expect(service_span.send(:meta)['_dd.appsec.json']).to be_a String
expect(spans.select { |s| s.get_tag('appsec.blocked') }).to_not be_empty if blocking_request
end

context 'with appsec disabled' do
Expand Down

0 comments on commit 27ae1a7

Please sign in to comment.