Skip to content

Commit 682849d

Browse files
committed
Improve AppSec::Response tests
1 parent 549cef9 commit 682849d

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

spec/datadog/appsec/response_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@
3333
context 'body' do
3434
subject(:body) { described_class.from_interrupt_params(interrupt_params, http_accept_header).body }
3535

36-
it 'returns response template with security response ID' do
37-
expect(body).to eq([
38-
Datadog::AppSec::Assets
39-
.blocked(format: :html)
40-
.gsub(Datadog::AppSec::Response::SECURITY_RESPONSE_ID_PLACEHOLDER, security_response_id)
41-
])
36+
it 'includes security response ID in the response body' do
37+
expect(body).to match_array([include(security_response_id)])
4238
end
4339

4440
context 'type is auto it uses the HTTP_ACCEPT to decide the result' do
4541
let(:type) { 'auto' }
4642
let(:http_accept_header) { 'application/json' }
4743

44+
it 'includes security response ID in the response body' do
45+
expect(body).to match_array([include(security_response_id)])
46+
end
47+
4848
it 'returns the response body with correct content type' do
4949
expect(body).to eq([
5050
Datadog::AppSec::Assets
@@ -77,12 +77,10 @@
7777
it 'uses default response replaces placeholders in the template' do
7878
expect(response.status).to eq 403
7979
expect(response.headers['Content-Type']).to eq 'text/html'
80+
end
8081

81-
expect(response.body).to eq([
82-
Datadog::AppSec::Assets
83-
.blocked(format: :html)
84-
.gsub(Datadog::AppSec::Response::SECURITY_RESPONSE_ID_PLACEHOLDER, '')
85-
])
82+
it 'does not render security response ID placeholders' do
83+
expect(response.body).not_to match_array([include(Datadog::AppSec::Response::SECURITY_RESPONSE_ID_PLACEHOLDER)])
8684
end
8785
end
8886
end

0 commit comments

Comments
 (0)