Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/error_tracking/sentry_client')
-rw-r--r--spec/lib/error_tracking/sentry_client/event_spec.rb5
-rw-r--r--spec/lib/error_tracking/sentry_client/issue_link_spec.rb7
-rw-r--r--spec/lib/error_tracking/sentry_client/issue_spec.rb28
-rw-r--r--spec/lib/error_tracking/sentry_client/projects_spec.rb5
-rw-r--r--spec/lib/error_tracking/sentry_client/repo_spec.rb3
5 files changed, 26 insertions, 22 deletions
diff --git a/spec/lib/error_tracking/sentry_client/event_spec.rb b/spec/lib/error_tracking/sentry_client/event_spec.rb
index 64e674f1e9b..d65bfa31018 100644
--- a/spec/lib/error_tracking/sentry_client/event_spec.rb
+++ b/spec/lib/error_tracking/sentry_client/event_spec.rb
@@ -32,6 +32,7 @@ RSpec.describe ErrorTracking::SentryClient do
subject { client.issue_latest_event(issue_id: issue_id) }
it_behaves_like 'calls sentry api'
+ it_behaves_like 'Sentry API response size limit'
it 'has correct return type' do
expect(subject).to be_a(Gitlab::ErrorTracking::ErrorEvent)
@@ -50,7 +51,7 @@ RSpec.describe ErrorTracking::SentryClient do
end
end
- context 'error object created from sentry response' do
+ context 'with error object created from sentry response' do
it_behaves_like 'assigns error tracking event correctly'
it 'parses the stack trace' do
@@ -58,7 +59,7 @@ RSpec.describe ErrorTracking::SentryClient do
expect(subject.stack_trace_entries).not_to be_empty
end
- context 'error without stack trace' do
+ context 'with error without stack trace' do
before do
sample_response['entries'] = []
stub_sentry_request(sentry_request_url, body: sample_response)
diff --git a/spec/lib/error_tracking/sentry_client/issue_link_spec.rb b/spec/lib/error_tracking/sentry_client/issue_link_spec.rb
index f86d328ef89..75e7ac8304e 100644
--- a/spec/lib/error_tracking/sentry_client/issue_link_spec.rb
+++ b/spec/lib/error_tracking/sentry_client/issue_link_spec.rb
@@ -9,6 +9,7 @@ RSpec.describe ErrorTracking::SentryClient::IssueLink do
let_it_be(:error_tracking_setting) { create(:project_error_tracking_setting, api_url: sentry_url) }
let_it_be(:issue) { create(:issue, project: error_tracking_setting.project) }
+ let(:token) { 'test-token' }
let(:client) { error_tracking_setting.sentry_client }
let(:sentry_issue_id) { 11111111 }
@@ -22,11 +23,12 @@ RSpec.describe ErrorTracking::SentryClient::IssueLink do
subject { client.create_issue_link(integration_id, sentry_issue_id, issue) }
+ it_behaves_like 'Sentry API response size limit'
it_behaves_like 'calls sentry api'
it { is_expected.to be_present }
- context 'redirects' do
+ context 'with redirects' do
let(:sentry_api_url) { sentry_issue_link_url }
it_behaves_like 'no Sentry redirects', :put
@@ -45,11 +47,12 @@ RSpec.describe ErrorTracking::SentryClient::IssueLink do
let(:issue_link_sample_response) { Gitlab::Json.parse(fixture_file('sentry/plugin_link_sample_response.json')) }
let!(:sentry_api_request) { stub_sentry_request(sentry_issue_link_url, :post, body: sentry_api_response) }
+ it_behaves_like 'Sentry API response size limit'
it_behaves_like 'calls sentry api'
it { is_expected.to be_present }
- context 'redirects' do
+ context 'with redirects' do
let(:sentry_api_url) { sentry_issue_link_url }
it_behaves_like 'no Sentry redirects', :post
diff --git a/spec/lib/error_tracking/sentry_client/issue_spec.rb b/spec/lib/error_tracking/sentry_client/issue_spec.rb
index d7bb0ca5c9a..1468a1ff7eb 100644
--- a/spec/lib/error_tracking/sentry_client/issue_spec.rb
+++ b/spec/lib/error_tracking/sentry_client/issue_spec.rb
@@ -58,6 +58,8 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
it_behaves_like 'issues have correct return type', Gitlab::ErrorTracking::Error
it_behaves_like 'issues have correct length', 3
+ it_behaves_like 'maps Sentry exceptions'
+ it_behaves_like 'Sentry API response size limit', enabled_by_default: true
shared_examples 'has correct external_url' do
describe '#external_url' do
@@ -151,7 +153,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
context 'with older sentry versions where keys are not present' do
let(:sentry_api_response) do
- issues_sample_response[0...1].map do |issue|
+ issues_sample_response.first(1).map do |issue|
issue[:project].delete(:id)
issue
end
@@ -167,7 +169,7 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
context 'when essential keys are missing in API response' do
let(:sentry_api_response) do
- issues_sample_response[0...1].map do |issue|
+ issues_sample_response.first(1).map do |issue|
issue.except(:id)
end
end
@@ -178,18 +180,6 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
end
end
- context 'when sentry api response is too large' do
- it 'raises exception' do
- deep_size = instance_double(Gitlab::Utils::DeepSize, valid?: false)
- allow(Gitlab::Utils::DeepSize).to receive(:new).with(sentry_api_response).and_return(deep_size)
-
- expect { subject }.to raise_error(ErrorTracking::SentryClient::ResponseInvalidSizeError,
- 'Sentry API response is too big. Limit is 1 MB.')
- end
- end
-
- it_behaves_like 'maps Sentry exceptions'
-
context 'when search term is present' do
let(:search_term) { 'NoMethodError' }
let(:sentry_request_url) { "#{sentry_url}/issues/?limit=20&query=is:unresolved NoMethodError" }
@@ -219,10 +209,14 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
end
let(:sentry_request_url) { "#{sentry_url}/issues/#{issue_id}/" }
- let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: issue_sample_response) }
+ let(:sentry_api_response) { issue_sample_response }
+ let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: sentry_api_response) }
subject { client.issue_details(issue_id: issue_id) }
+ it_behaves_like 'maps Sentry exceptions'
+ it_behaves_like 'Sentry API response size limit'
+
context 'with error object created from sentry response' do
using RSpec::Parameterized::TableSyntax
@@ -321,6 +315,10 @@ RSpec.describe ErrorTracking::SentryClient::Issue do
subject { client.update_issue(issue_id: issue_id, params: params) }
+ it_behaves_like 'Sentry API response size limit' do
+ let(:sentry_api_response) { {} }
+ end
+
it_behaves_like 'calls sentry api' do
let(:sentry_api_request) { stub_sentry_request(sentry_request_url, :put) }
end
diff --git a/spec/lib/error_tracking/sentry_client/projects_spec.rb b/spec/lib/error_tracking/sentry_client/projects_spec.rb
index 247f9c1c085..52f8cdc915e 100644
--- a/spec/lib/error_tracking/sentry_client/projects_spec.rb
+++ b/spec/lib/error_tracking/sentry_client/projects_spec.rb
@@ -35,10 +35,11 @@ RSpec.describe ErrorTracking::SentryClient::Projects do
it_behaves_like 'has correct return type', Gitlab::ErrorTracking::Project
it_behaves_like 'has correct length', 2
+ it_behaves_like 'Sentry API response size limit'
context 'essential keys missing in API response' do
let(:sentry_api_response) do
- projects_sample_response[0...1].map do |project|
+ projects_sample_response.first(1).map do |project|
project.except(:slug)
end
end
@@ -50,7 +51,7 @@ RSpec.describe ErrorTracking::SentryClient::Projects do
context 'optional keys missing in sentry response' do
let(:sentry_api_response) do
- projects_sample_response[0...1].map do |project|
+ projects_sample_response.first(1).map do |project|
project[:organization].delete(:id)
project.delete(:id)
project.except(:status)
diff --git a/spec/lib/error_tracking/sentry_client/repo_spec.rb b/spec/lib/error_tracking/sentry_client/repo_spec.rb
index 9a1c7a69c3d..445a8e35f8e 100644
--- a/spec/lib/error_tracking/sentry_client/repo_spec.rb
+++ b/spec/lib/error_tracking/sentry_client/repo_spec.rb
@@ -19,12 +19,13 @@ RSpec.describe ErrorTracking::SentryClient::Repo do
subject { client.repos(organization_slug) }
it_behaves_like 'calls sentry api'
+ it_behaves_like 'Sentry API response size limit'
it { is_expected.to all( be_a(Gitlab::ErrorTracking::Repo)) }
it { expect(subject.length).to eq(1) }
- context 'redirects' do
+ context 'with redirects' do
let(:sentry_api_url) { sentry_repos_url }
it_behaves_like 'no Sentry redirects'