diff options
-rw-r--r-- | app/controllers/import/bitbucket_controller.rb | 2 | ||||
-rw-r--r-- | lib/bitbucket/connection.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/legacy_github_import/client.rb | 2 | ||||
-rw-r--r-- | spec/controllers/import/bitbucket_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/bitbucket/connection_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/legacy_github_import/client_spec.rb | 4 |
6 files changed, 27 insertions, 7 deletions
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb index c933b05e0c4..196fadb888d 100644 --- a/app/controllers/import/bitbucket_controller.rb +++ b/app/controllers/import/bitbucket_controller.rb @@ -129,7 +129,7 @@ class Import::BitbucketController < Import::BaseController end def options - OmniAuth::Strategies::Bitbucket.default_options[:client_options].deep_symbolize_keys + OmniAuth::Strategies::Bitbucket.default_options[:client_options].to_h.deep_symbolize_keys end def verify_bitbucket_import_enabled diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb index 9937236fc44..64550a0525c 100644 --- a/lib/bitbucket/connection.rb +++ b/lib/bitbucket/connection.rb @@ -63,7 +63,7 @@ module Bitbucket end def options - OmniAuth::Strategies::Bitbucket.default_options[:client_options].deep_symbolize_keys + OmniAuth::Strategies::Bitbucket.default_options[:client_options].to_h.deep_symbolize_keys end end end diff --git a/lib/gitlab/legacy_github_import/client.rb b/lib/gitlab/legacy_github_import/client.rb index 16c3bc09c4d..e1c3b09d371 100644 --- a/lib/gitlab/legacy_github_import/client.rb +++ b/lib/gitlab/legacy_github_import/client.rb @@ -116,7 +116,7 @@ module Gitlab if config config["args"]["client_options"].deep_symbolize_keys else - OmniAuth::Strategies::GitHub.default_options[:client_options].symbolize_keys + OmniAuth::Strategies::GitHub.default_options[:client_options].to_h.symbolize_keys end end diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb index 906cc5cb336..34e8e5af1f4 100644 --- a/spec/controllers/import/bitbucket_controller_spec.rb +++ b/spec/controllers/import/bitbucket_controller_spec.rb @@ -31,6 +31,16 @@ RSpec.describe Import::BitbucketController, feature_category: :importers do let(:external_bitbucket_auth_url) { "http://fake.bitbucket.host/url" } it "redirects to external auth url" do + expected_client_options = { + site: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['site'], + authorize_url: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['authorize_url'], + token_url: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['token_url'] + } + + expect(OAuth2::Client) + .to receive(:new) + .with(anything, anything, expected_client_options) + allow(SecureRandom).to receive(:base64).and_return(random_key) allow_next_instance_of(OAuth2::Client) do |client| allow(client).to receive_message_chain(:auth_code, :authorize_url) @@ -101,7 +111,7 @@ RSpec.describe Import::BitbucketController, feature_category: :importers do @invalid_repo = double(name: 'mercurialrepo', slug: 'mercurialrepo', owner: 'asd', full_name: 'asd/mercurialrepo', clone_url: 'http://test.host/demo/mercurialrepo.git', 'valid?' => false) end - context "when token does not exists" do + context "when token does not exist" do let(:random_key) { "pure_random" } let(:external_bitbucket_auth_url) { "http://fake.bitbucket.host/url" } diff --git a/spec/lib/bitbucket/connection_spec.rb b/spec/lib/bitbucket/connection_spec.rb index 58a05c52b9f..2b35a37558c 100644 --- a/spec/lib/bitbucket/connection_spec.rb +++ b/spec/lib/bitbucket/connection_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Bitbucket::Connection do +RSpec.describe Bitbucket::Connection, feature_category: :integrations do let(:token) { 'token' } before do @@ -13,6 +13,16 @@ RSpec.describe Bitbucket::Connection do describe '#get' do it 'calls OAuth2::AccessToken::get' do + expected_client_options = { + site: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['site'], + authorize_url: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['authorize_url'], + token_url: OmniAuth::Strategies::Bitbucket.default_options[:client_options]['token_url'] + } + + expect(OAuth2::Client) + .to receive(:new) + .with(anything, anything, expected_client_options) + expect_next_instance_of(OAuth2::AccessToken) do |instance| expect(instance).to receive(:get).and_return(double(parsed: true)) end diff --git a/spec/lib/gitlab/legacy_github_import/client_spec.rb b/spec/lib/gitlab/legacy_github_import/client_spec.rb index d0f63d11469..757bdd8dd6c 100644 --- a/spec/lib/gitlab/legacy_github_import/client_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/client_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Gitlab::LegacyGithubImport::Client do +RSpec.describe Gitlab::LegacyGithubImport::Client, feature_category: :importers do let(:token) { '123456' } let(:github_provider) { GitlabSettings::Options.build('app_id' => 'asd123', 'app_secret' => 'asd123', 'name' => 'github', 'args' => { 'client_options' => {} }) } let(:wait_for_rate_limit_reset) { true } @@ -47,7 +47,7 @@ RSpec.describe Gitlab::LegacyGithubImport::Client do end describe '#api_endpoint' do - context 'when provider does not specity an API endpoint' do + context 'when provider does not specify an API endpoint' do it 'uses GitHub root API endpoint' do expect(client.api.api_endpoint).to eq 'https://api.github.com/' end |