diff --git a/.rubocop_todo/rspec/any_instance_of.yml b/.rubocop_todo/rspec/any_instance_of.yml index bf1bc408b66d7131efa99c86c08248c1622a4d13..1809dd74dc92c7741c5d9aa302497f0c1a38db16 100644 --- a/.rubocop_todo/rspec/any_instance_of.yml +++ b/.rubocop_todo/rspec/any_instance_of.yml @@ -141,7 +141,7 @@ RSpec/AnyInstanceOf: - spec/controllers/groups/settings/ci_cd_controller_spec.rb - spec/controllers/groups_controller_spec.rb - spec/controllers/import/bitbucket_controller_spec.rb - - spec/controllers/oauth/jira/authorizations_controller_spec.rb + - spec/controllers/oauth/jira_dvcs/authorizations_controller_spec.rb - spec/controllers/omniauth_callbacks_controller_spec.rb - spec/controllers/projects/artifacts_controller_spec.rb - spec/controllers/projects/branches_controller_spec.rb diff --git a/.rubocop_todo/rspec/verified_doubles.yml b/.rubocop_todo/rspec/verified_doubles.yml index 7cffea49d3ac5e9c0b270935b1c9ab19a583936a..bbdbb645da096952a321c45201fd745b66f41436 100644 --- a/.rubocop_todo/rspec/verified_doubles.yml +++ b/.rubocop_todo/rspec/verified_doubles.yml @@ -295,7 +295,7 @@ RSpec/VerifiedDoubles: - spec/controllers/import/gitea_controller_spec.rb - spec/controllers/import/github_controller_spec.rb - spec/controllers/import/gitlab_controller_spec.rb - - spec/controllers/oauth/jira/authorizations_controller_spec.rb + - spec/controllers/oauth/jira_dvcs/authorizations_controller_spec.rb - spec/controllers/omniauth_callbacks_controller_spec.rb - spec/controllers/profiles/two_factor_auths_controller_spec.rb - spec/controllers/projects/blob_controller_spec.rb diff --git a/app/controllers/oauth/jira/authorizations_controller.rb b/app/controllers/oauth/jira_dvcs/authorizations_controller.rb similarity index 92% rename from app/controllers/oauth/jira/authorizations_controller.rb rename to app/controllers/oauth/jira_dvcs/authorizations_controller.rb index 8169b5fcbb05031deecde8e38ffd53c5f2404f76..613999f4ca7ff0af39ae888a95291327200b648f 100644 --- a/app/controllers/oauth/jira/authorizations_controller.rb +++ b/app/controllers/oauth/jira_dvcs/authorizations_controller.rb @@ -4,7 +4,7 @@ # flow routes for Jira DVCS integration. # See https://gitlab.com/gitlab-org/gitlab/issues/2381 # -class Oauth::Jira::AuthorizationsController < ApplicationController +class Oauth::JiraDvcs::AuthorizationsController < ApplicationController skip_before_action :authenticate_user! skip_before_action :verify_authenticity_token @@ -17,7 +17,7 @@ def new redirect_to oauth_authorization_path(client_id: params['client_id'], response_type: 'code', scope: normalize_scope(params['scope']), - redirect_uri: oauth_jira_callback_url) + redirect_uri: oauth_jira_dvcs_callback_url) end # 2. Handle the callback call as we were a Github Enterprise instance client. @@ -33,7 +33,7 @@ def callback # 3. Rewire and adjust access_token request accordingly. def access_token # We have to modify request.parameters because Doorkeeper::Server reads params from there - request.parameters[:redirect_uri] = oauth_jira_callback_url + request.parameters[:redirect_uri] = oauth_jira_dvcs_callback_url strategy = Doorkeeper::Server.new(self).token_request('authorization_code') response = strategy.authorize diff --git a/config/routes.rb b/config/routes.rb index 9342de492ec1f56c4c6e2a0b8e49fdf7531c11d2..ef9e21282fdfc7df261a79ef56092a9eba71da51 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,7 +32,7 @@ # This prefixless path is required because Jira gets confused if we set it up with a path # More information: https://gitlab.com/gitlab-org/gitlab/issues/6752 - scope path: '/login/oauth', controller: 'oauth/jira/authorizations', as: :oauth_jira do + scope path: '/login/oauth', controller: 'oauth/jira_dvcs/authorizations', as: :oauth_jira_dvcs do get :authorize, action: :new get :callback post :access_token diff --git a/spec/controllers/oauth/jira/authorizations_controller_spec.rb b/spec/controllers/oauth/jira_dvcs/authorizations_controller_spec.rb similarity index 93% rename from spec/controllers/oauth/jira/authorizations_controller_spec.rb rename to spec/controllers/oauth/jira_dvcs/authorizations_controller_spec.rb index f4a335b30f47e88640e423542ee10a9d347b170f..496ef7859f9a110e16b3d11c41f2abe85266f3fc 100644 --- a/spec/controllers/oauth/jira/authorizations_controller_spec.rb +++ b/spec/controllers/oauth/jira_dvcs/authorizations_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe Oauth::Jira::AuthorizationsController do +RSpec.describe Oauth::JiraDvcs::AuthorizationsController do describe 'GET new' do it 'redirects to OAuth authorization with correct params' do get :new, params: { client_id: 'client-123', scope: 'foo', redirect_uri: 'http://example.com/' } @@ -10,7 +10,7 @@ expect(response).to redirect_to(oauth_authorization_url(client_id: 'client-123', response_type: 'code', scope: 'foo', - redirect_uri: oauth_jira_callback_url)) + redirect_uri: oauth_jira_dvcs_callback_url)) end it 'replaces the GitHub "repo" scope with "api"' do @@ -19,7 +19,7 @@ expect(response).to redirect_to(oauth_authorization_url(client_id: 'client-123', response_type: 'code', scope: 'api', - redirect_uri: oauth_jira_callback_url)) + redirect_uri: oauth_jira_dvcs_callback_url)) end end diff --git a/spec/features/jira_oauth_provider_authorize_spec.rb b/spec/features/jira_oauth_provider_authorize_spec.rb index daecae5610138110f4cdb41dd06d0b7143907bfb..a216d2d44b29aca51dadad3fb04c6800850c608a 100644 --- a/spec/features/jira_oauth_provider_authorize_spec.rb +++ b/spec/features/jira_oauth_provider_authorize_spec.rb @@ -4,13 +4,13 @@ RSpec.describe 'JIRA OAuth Provider' do describe 'JIRA DVCS OAuth Authorization' do - let(:application) { create(:oauth_application, redirect_uri: oauth_jira_callback_url, scopes: 'read_user') } + let(:application) { create(:oauth_application, redirect_uri: oauth_jira_dvcs_callback_url, scopes: 'read_user') } before do sign_in(user) - visit oauth_jira_authorize_path(client_id: application.uid, - redirect_uri: oauth_jira_callback_url, + visit oauth_jira_dvcs_authorize_path(client_id: application.uid, + redirect_uri: oauth_jira_dvcs_callback_url, response_type: 'code', state: 'my_state', scope: 'read_user') diff --git a/spec/requests/jira_authorizations_spec.rb b/spec/requests/jira_authorizations_spec.rb index 24c6001814c7669d54178ffc363ee215ee8bf87e..b43d36e94f4fd33acb8816a3b3e237e7cbc428d3 100644 --- a/spec/requests/jira_authorizations_spec.rb +++ b/spec/requests/jira_authorizations_spec.rb @@ -5,7 +5,7 @@ RSpec.describe 'Jira authorization requests' do let(:user) { create :user } let(:application) { create :oauth_application, scopes: 'api' } - let(:redirect_uri) { oauth_jira_callback_url(host: "http://www.example.com") } + let(:redirect_uri) { oauth_jira_dvcs_callback_url(host: "http://www.example.com") } def generate_access_grant create :oauth_access_grant, application: application, resource_owner_id: user.id, redirect_uri: redirect_uri