From 5d58fc40f8f89e40de53a54786f721c707ddb93f Mon Sep 17 00:00:00 2001 From: Andy Soiron <asoiron@gitlab.com> Date: Tue, 15 Mar 2022 13:09:52 +0100 Subject: [PATCH] Rename namespace Oauth::Jira to Oauth::JiraDvcs To point out that it's only used for DVCS --- .rubocop_todo/rspec/any_instance_of.yml | 2 +- .rubocop_todo/rspec/verified_doubles.yml | 2 +- .../oauth/{jira => jira_dvcs}/authorizations_controller.rb | 6 +++--- config/routes.rb | 2 +- .../{jira => jira_dvcs}/authorizations_controller_spec.rb | 6 +++--- spec/features/jira_oauth_provider_authorize_spec.rb | 6 +++--- spec/requests/jira_authorizations_spec.rb | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) rename app/controllers/oauth/{jira => jira_dvcs}/authorizations_controller.rb (92%) rename spec/controllers/oauth/{jira => jira_dvcs}/authorizations_controller_spec.rb (93%) diff --git a/.rubocop_todo/rspec/any_instance_of.yml b/.rubocop_todo/rspec/any_instance_of.yml index bf1bc408b66d7..1809dd74dc92c 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 7cffea49d3ac5..bbdbb645da096 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 8169b5fcbb050..613999f4ca7ff 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 9342de492ec1f..ef9e21282fdfc 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 f4a335b30f47e..496ef7859f9a1 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 daecae5610138..a216d2d44b29a 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 24c6001814c76..b43d36e94f4fd 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 -- GitLab