Commit b5f0b012 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'cat-log-unauthorized-bitbucket-exceptions' into 'master'

Log Bitbucket unauthorized exceptions

See merge request gitlab-org/gitlab!74250
parents ec60abcf da503d12
......@@ -116,7 +116,9 @@ class Import::BitbucketController < Import::BaseController
redirect_to oauth_client.auth_code.authorize_url(redirect_uri: users_import_bitbucket_callback_url)
end
def bitbucket_unauthorized
def bitbucket_unauthorized(exception)
log_exception(exception)
go_to_bitbucket_for_permissions
end
......
......@@ -252,6 +252,30 @@ RSpec.describe Import::BitbucketController do
end
end
end
context "when exceptions occur" do
shared_examples "handles exceptions" do
it "logs an exception" do
expect(Bitbucket::Client).to receive(:new).and_raise(error)
expect(controller).to receive(:log_exception)
post :create, format: :json
end
end
context "for OAuth2 errors" do
let(:fake_response) { double('Faraday::Response', headers: {}, body: '', status: 403) }
let(:error) { OAuth2::Error.new(OAuth2::Response.new(fake_response)) }
it_behaves_like "handles exceptions"
end
context "for Bitbucket errors" do
let(:error) { Bitbucket::Error::Unauthorized.new("error") }
it_behaves_like "handles exceptions"
end
end
end
context 'user has chosen an existing nested namespace and name for the project' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment