diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-30 17:15:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-30 17:15:08 +0300 |
commit | 427cb4dfa77bccf1594503a7e00d7e782e281c16 (patch) | |
tree | dcafd13e81af3eb982ae1adcbb9dc18f0c5be1e9 /spec | |
parent | d02a25c8704150b5ad0c516720ce625256f7cbac (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-ee
Diffstat (limited to 'spec')
-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 |
3 files changed, 24 insertions, 4 deletions
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 |