summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket_server
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-01-12 15:18:22 -0800
committerStan Hu <stanhu@gmail.com>2019-01-12 22:14:08 -0800
commit660dcd5b7c038f86002ddecf3562e1b7018e143c (patch)
treedad44705328349dc4e0ed66253e65e6cee255776 /spec/lib/bitbucket_server
parent1161c99e5c5a6e717127b83665de00068d810e0e (diff)
downloadgitlab-ce-660dcd5b7c038f86002ddecf3562e1b7018e143c.tar.gz
Fix Bitbucket Server importer error handling
The importer would display a 500 error page if you attempted to import using a non-existent DNS entry. This commit rescues known network issues and consolidates them into BitbucketServer::Connection::ConnectionError`. The previous error handling in the paginator doesn't work because it returns a lazy collection. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56154
Diffstat (limited to 'spec/lib/bitbucket_server')
-rw-r--r--spec/lib/bitbucket_server/client_spec.rb6
-rw-r--r--spec/lib/bitbucket_server/connection_spec.rb18
2 files changed, 18 insertions, 6 deletions
diff --git a/spec/lib/bitbucket_server/client_spec.rb b/spec/lib/bitbucket_server/client_spec.rb
index 5de0a9a65b5..b021e69800a 100644
--- a/spec/lib/bitbucket_server/client_spec.rb
+++ b/spec/lib/bitbucket_server/client_spec.rb
@@ -17,12 +17,6 @@ describe BitbucketServer::Client do
subject.pull_requests(project, repo_slug)
end
-
- it 'throws an exception when connection fails' do
- allow(BitbucketServer::Collection).to receive(:new).and_raise(OpenSSL::SSL::SSLError)
-
- expect { subject.pull_requests(project, repo_slug) }.to raise_error(described_class::ServerError)
- end
end
describe '#activities' do
diff --git a/spec/lib/bitbucket_server/connection_spec.rb b/spec/lib/bitbucket_server/connection_spec.rb
index b5da4cb1a49..ab8a5b89608 100644
--- a/spec/lib/bitbucket_server/connection_spec.rb
+++ b/spec/lib/bitbucket_server/connection_spec.rb
@@ -26,6 +26,12 @@ describe BitbucketServer::Connection do
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
+
+ it 'throws an exception upon a network error' do
+ WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
+
+ expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
+ end
end
describe '#post' do
@@ -42,6 +48,12 @@ describe BitbucketServer::Connection do
expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
end
+
+ it 'throws an exception upon a network error' do
+ WebMock.stub_request(:post, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
+
+ expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
+ end
end
describe '#delete' do
@@ -63,6 +75,12 @@ describe BitbucketServer::Connection do
expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
end
+
+ it 'throws an exception upon a network error' do
+ WebMock.stub_request(:delete, branch_url).with(headers: headers).to_raise(OpenSSL::SSL::SSLError)
+
+ expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
+ end
end
end
end