diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-24 14:01:22 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-07-24 14:01:22 +0000 |
commit | 2a07275121b9c965bca01767c5ccdb58c6f6e660 (patch) | |
tree | 55a1f6fce1e1e9b5c84a555d067a5169fb15d135 | |
parent | f987e03c42635491e970fcbef309216821ac051c (diff) | |
parent | 1f403720293393f0f0bf6f99476abe4ba79580a4 (diff) | |
download | gitlab-ce-2a07275121b9c965bca01767c5ccdb58c6f6e660.tar.gz |
Merge branch 'mc/feature/use-only-pat-cicd-projects' into 'master'
Remove OAuth GitHub CI/CD project code paths
See merge request gitlab-org/gitlab-ce!30716
-rw-r--r-- | app/controllers/import/github_controller.rb | 8 | ||||
-rw-r--r-- | spec/controllers/import/github_controller_spec.rb | 10 |
2 files changed, 16 insertions, 2 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index aa4aa0fbdac..ebb50fc8b10 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -10,7 +10,7 @@ class Import::GithubController < Import::BaseController rescue_from Octokit::Unauthorized, with: :provider_unauthorized def new - if github_import_configured? && logged_in_with_provider? + if !ci_cd_only? && github_import_configured? && logged_in_with_provider? go_to_provider_for_permissions elsif session[access_token_key] redirect_to status_import_url @@ -169,11 +169,15 @@ class Import::GithubController < Import::BaseController # rubocop: enable CodeReuse/ActiveRecord def provider_auth - if session[access_token_key].blank? + if !ci_cd_only? && session[access_token_key].blank? go_to_provider_for_permissions end end + def ci_cd_only? + %w[1 true].include?(params[:ci_cd_only]) + end + def client_options {} end diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb index 059354870b5..5675798ac33 100644 --- a/spec/controllers/import/github_controller_spec.rb +++ b/spec/controllers/import/github_controller_spec.rb @@ -33,6 +33,16 @@ describe Import::GithubController do expect(response).to have_http_status(200) end + + context 'when importing a CI/CD project' do + it 'always prompts for an access token' do + allow(controller).to receive(:github_import_configured?).and_return(true) + + get :new, params: { ci_cd_only: true } + + expect(response).to render_template(:new) + end + end end describe "GET callback" do |