Commit 74ea508e authored by Imre Farkas's avatar Imre Farkas

Merge branch 'remove_jira_connect_app_feature_flag' into 'master'

Remove jira_connect_app feature flag

See merge request gitlab-org/gitlab!24818
parents e8f51a55 a4806fa0
...@@ -15,8 +15,6 @@ The following are required to install and test the app: ...@@ -15,8 +15,6 @@ The following are required to install and test the app:
or [ngrok](https://ngrok.com). These also take care of SSL for you because Jira or [ngrok](https://ngrok.com). These also take care of SSL for you because Jira
requires all connections to the app host to be over SSL. requires all connections to the app host to be over SSL.
> This feature is currently behind the `:jira_connect_app` feature flag
## Installing the app in Jira ## Installing the app in Jira
1. Enable Jira development mode to install apps that are not from the Atlassian Marketplace 1. Enable Jira development mode to install apps that are not from the Atlassian Marketplace
......
...@@ -5,17 +5,12 @@ class JiraConnect::ApplicationController < ApplicationController ...@@ -5,17 +5,12 @@ class JiraConnect::ApplicationController < ApplicationController
skip_before_action :authenticate_user! skip_before_action :authenticate_user!
skip_before_action :verify_authenticity_token skip_before_action :verify_authenticity_token
before_action :check_feature_flag_enabled!
before_action :verify_atlassian_jwt! before_action :verify_atlassian_jwt!
attr_reader :current_jira_installation attr_reader :current_jira_installation
private private
def check_feature_flag_enabled!
render_404 unless Feature.enabled?(:jira_connect_app)
end
def verify_atlassian_jwt! def verify_atlassian_jwt!
return render_403 unless atlassian_jwt_valid? return render_403 unless atlassian_jwt_valid?
......
...@@ -748,6 +748,10 @@ module EE ...@@ -748,6 +748,10 @@ module EE
::Project.with_groups_level_repos_templates.exists?(id) ::Project.with_groups_level_repos_templates.exists?(id)
end end
def jira_subscription_exists?
feature_available?(:jira_dev_panel_integration) && JiraConnectSubscription.for_project(self).exists?
end
private private
def group_hooks def group_hooks
......
...@@ -11,7 +11,7 @@ module EE ...@@ -11,7 +11,7 @@ module EE
def branch_change_hooks def branch_change_hooks
super super
return unless jira_subscription_exists? return unless project.jira_subscription_exists?
branch_to_sync = branch_name if Atlassian::JiraIssueKeyExtractor.has_keys?(branch_name) branch_to_sync = branch_name if Atlassian::JiraIssueKeyExtractor.has_keys?(branch_name)
commits_to_sync = limited_commits.select { |commit| Atlassian::JiraIssueKeyExtractor.has_keys?(commit.safe_message) }.map(&:sha) commits_to_sync = limited_commits.select { |commit| Atlassian::JiraIssueKeyExtractor.has_keys?(commit.safe_message) }.map(&:sha)
...@@ -21,12 +21,6 @@ module EE ...@@ -21,12 +21,6 @@ module EE
end end
end end
def jira_subscription_exists?
::Feature.enabled?(:jira_connect_app) &&
project.feature_available?(:jira_dev_panel_integration) &&
JiraConnectSubscription.for_project(project).exists?
end
override :pipeline_options override :pipeline_options
def pipeline_options def pipeline_options
mirror_update = project.mirror? && mirror_update = project.mirror? &&
......
...@@ -9,7 +9,7 @@ module EE ...@@ -9,7 +9,7 @@ module EE
def execute_hooks(merge_request, action = 'open', old_rev: nil, old_associations: {}) def execute_hooks(merge_request, action = 'open', old_rev: nil, old_associations: {})
super super
return unless jira_subscription_exists? return unless project.jira_subscription_exists?
if Atlassian::JiraIssueKeyExtractor.has_keys?(merge_request.title, merge_request.description) if Atlassian::JiraIssueKeyExtractor.has_keys?(merge_request.title, merge_request.description)
JiraConnect::SyncMergeRequestWorker.perform_async(merge_request.id) JiraConnect::SyncMergeRequestWorker.perform_async(merge_request.id)
...@@ -20,12 +20,6 @@ module EE ...@@ -20,12 +20,6 @@ module EE
attr_accessor :blocking_merge_requests_params attr_accessor :blocking_merge_requests_params
def jira_subscription_exists?
::Feature.enabled?(:jira_connect_app) &&
project.feature_available?(:jira_dev_panel_integration) &&
JiraConnectSubscription.for_project(project).exists?
end
override :filter_params override :filter_params
def filter_params(merge_request) def filter_params(merge_request)
unless current_user.can?(:update_approvers, merge_request) unless current_user.can?(:update_approvers, merge_request)
......
---
title: Release Jira connect feature
merge_request: 24818
author:
type: added
...@@ -4,35 +4,17 @@ require 'spec_helper' ...@@ -4,35 +4,17 @@ require 'spec_helper'
describe JiraConnect::AppDescriptorController do describe JiraConnect::AppDescriptorController do
describe '#show' do describe '#show' do
context 'feature disabled' do it 'returns JSON app descriptor' do
before do get :show
stub_feature_flags(jira_connect_app: false)
end
it 'returns 404' do expect(response).to have_gitlab_http_status(:ok)
get :show expect(json_response).to include(
'baseUrl' => 'https://test.host/-/jira_connect',
expect(response).to have_gitlab_http_status(:not_found) 'lifecycle' => {
end 'installed' => '/events/installed',
end 'uninstalled' => '/events/uninstalled'
}
context 'feature enabled' do )
before do
stub_feature_flags(jira_connect_app: true)
end
it 'returns JSON app descriptor' do
get :show
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include(
'baseUrl' => 'https://test.host/-/jira_connect',
'lifecycle' => {
'installed' => '/events/installed',
'uninstalled' => '/events/uninstalled'
}
)
end
end end
end end
end end
...@@ -3,63 +3,35 @@ ...@@ -3,63 +3,35 @@
require 'spec_helper' require 'spec_helper'
describe JiraConnect::EventsController do describe JiraConnect::EventsController do
context 'feature disabled' do describe '#installed' do
before do subject do
stub_feature_flags(jira_connect_app: false) post :installed, params: {
clientKey: '1234',
sharedSecret: 'secret',
baseUrl: 'https://test.atlassian.net'
}
end end
describe '#installed' do it 'saves the jira installation data' do
it 'returns 404' do expect { subject }.to change { JiraConnectInstallation.count }.by(1)
post :installed
expect(response).to have_gitlab_http_status(:not_found)
end
end end
describe '#uninstalled' do it 'saves the correct values' do
it 'returns 404' do subject
post :uninstalled
expect(response).to have_gitlab_http_status(:not_found) installation = JiraConnectInstallation.find_by_client_key('1234')
end
end
end
context 'feature enabled' do expect(installation.shared_secret).to eq('secret')
before do expect(installation.base_url).to eq('https://test.atlassian.net')
stub_feature_flags(jira_connect_app: true)
end end
describe '#installed' do context 'client key already exists' do
subject do it 'returns 422' do
post :installed, params: { create(:jira_connect_installation, client_key: '1234')
clientKey: '1234',
sharedSecret: 'secret',
baseUrl: 'https://test.atlassian.net'
}
end
it 'saves the jira installation data' do
expect { subject }.to change { JiraConnectInstallation.count }.by(1)
end
it 'saves the correct values' do
subject subject
installation = JiraConnectInstallation.find_by_client_key('1234') expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(installation.shared_secret).to eq('secret')
expect(installation.base_url).to eq('https://test.atlassian.net')
end
context 'client key already exists' do
it 'returns 422' do
create(:jira_connect_installation, client_key: '1234')
subject
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end end
end end
......
...@@ -3,164 +3,126 @@ ...@@ -3,164 +3,126 @@
require 'spec_helper' require 'spec_helper'
describe JiraConnect::SubscriptionsController do describe JiraConnect::SubscriptionsController do
context 'feature disabled' do let_it_be(:installation) { create(:jira_connect_installation) }
describe '#index' do
before do before do
stub_feature_flags(jira_connect_app: false) get :index, params: { jwt: jwt }
end end
describe '#index' do context 'without JWT' do
it 'returns 404' do let(:jwt) { nil }
get :index
expect(response).to have_gitlab_http_status(:not_found) it 'returns 403' do
expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
describe '#create' do context 'with valid JWT' do
it '#create returns 404' do let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/subscriptions', 'GET', 'https://gitlab.test') }
post :create let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) }
expect(response).to have_gitlab_http_status(:not_found) it 'returns 200' do
expect(response).to have_gitlab_http_status(:ok)
end end
end
describe '#destroy' do
let(:subscription) { create(:jira_connect_subscription) }
it '#destroy returns 404' do it 'removes X-Frame-Options to allow rendering in iframe' do
delete :destroy, params: { id: subscription.id } expect(response.headers['X-Frame-Options']).to be_nil
expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
context 'feature enabled' do describe '#create' do
let(:group) { create(:group) }
let(:user) { create(:user) }
let(:current_user) { user }
before do before do
stub_feature_flags(jira_connect_app: true) group.add_maintainer(user)
end end
let(:installation) { create(:jira_connect_installation) } subject { post :create, params: { jwt: jwt, namespace_path: group.path, format: :json } }
describe '#index' do context 'without JWT' do
before do let(:jwt) { nil }
get :index, params: { jwt: jwt }
end
context 'without JWT' do
let(:jwt) { nil }
it 'returns 403' do
expect(response).to have_gitlab_http_status(:forbidden)
end
end
context 'with valid JWT' do it 'returns 403' do
let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/subscriptions', 'GET', 'https://gitlab.test') } sign_in(user)
let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) }
it 'returns 200' do subject
expect(response).to have_gitlab_http_status(:ok)
end
it 'removes X-Frame-Options to allow rendering in iframe' do expect(response).to have_gitlab_http_status(:forbidden)
expect(response.headers['X-Frame-Options']).to be_nil
end
end end
end end
describe '#create' do context 'with valid JWT' do
let(:group) { create(:group) } let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key }, installation.shared_secret) }
let(:user) { create(:user) }
let(:current_user) { user }
before do
group.add_maintainer(user)
end
subject { post :create, params: { jwt: jwt, namespace_path: group.path, format: :json } }
context 'without JWT' do context 'signed in to GitLab' do
let(:jwt) { nil } before do
it 'returns 403' do
sign_in(user) sign_in(user)
subject
expect(response).to have_gitlab_http_status(:forbidden)
end end
end
context 'with valid JWT' do context 'dev panel integration is available' do
let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key }, installation.shared_secret) }
context 'signed in to GitLab' do
before do before do
sign_in(user) stub_licensed_features(jira_dev_panel_integration: true)
end end
context 'dev panel integration is available' do it 'creates a subscription' do
before do expect { subject }.to change { installation.subscriptions.count }.from(0).to(1)
stub_licensed_features(jira_dev_panel_integration: true) end
end
it 'creates a subscription' do
expect { subject }.to change { installation.subscriptions.count }.from(0).to(1)
end
it 'returns 200' do it 'returns 200' do
subject subject
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end
end end
end
context 'dev panel integration is not available' do context 'dev panel integration is not available' do
before do before do
stub_licensed_features(jira_dev_panel_integration: false) stub_licensed_features(jira_dev_panel_integration: false)
end end
it 'returns 422' do it 'returns 422' do
subject subject
expect(response).to have_gitlab_http_status(:unprocessable_entity) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end end
end end
end
context 'not signed in to GitLab' do context 'not signed in to GitLab' do
it 'returns 401' do it 'returns 401' do
subject subject
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end
end end
end end
end end
end
describe '#destroy' do describe '#destroy' do
let(:subscription) { create(:jira_connect_subscription, installation: installation) } let(:subscription) { create(:jira_connect_subscription, installation: installation) }
before do before do
delete :destroy, params: { jwt: jwt, id: subscription.id } delete :destroy, params: { jwt: jwt, id: subscription.id }
end end
context 'without JWT' do context 'without JWT' do
let(:jwt) { nil } let(:jwt) { nil }
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end
end end
end
context 'with valid JWT' do context 'with valid JWT' do
let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key }, installation.shared_secret) } let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key }, installation.shared_secret) }
it 'deletes the subscription' do it 'deletes the subscription' do
expect { subscription.reload }.to raise_error ActiveRecord::RecordNotFound expect { subscription.reload }.to raise_error ActiveRecord::RecordNotFound
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end
end end
end end
end end
......
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe 'Subscriptions Content Security Policy' do describe 'Subscriptions Content Security Policy' do
before do
stub_feature_flags(jira_connect_app: true)
end
let(:installation) { create(:jira_connect_installation) } let(:installation) { create(:jira_connect_installation) }
let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/subscriptions', 'GET', 'https://gitlab.test') } let(:qsh) { Atlassian::Jwt.create_query_string_hash('https://gitlab.test/subscriptions', 'GET', 'https://gitlab.test') }
let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) } let(:jwt) { Atlassian::Jwt.encode({ iss: installation.client_key, qsh: qsh }, installation.shared_secret) }
......
...@@ -2640,4 +2640,22 @@ describe Project do ...@@ -2640,4 +2640,22 @@ describe Project do
end end
end end
end end
describe '#jira_subscription_exists?' do
subject { project.jira_subscription_exists? }
context 'jira connect subscription exists' do
let!(:jira_connect_subscription) { create(:jira_connect_subscription, namespace: project.namespace) }
it { is_expected.to eq(false) }
context 'dev panel integration is available' do
before do
stub_licensed_features(jira_dev_panel_integration: true)
end
it { is_expected.to eq(true) }
end
end
end
end end
...@@ -176,60 +176,46 @@ describe Git::BranchPushService do ...@@ -176,60 +176,46 @@ describe Git::BranchPushService do
end end
end end
context 'when feature is enabled' do context 'has Jira dev panel integration license' do
before do before do
stub_feature_flags(jira_connect_app: true) stub_licensed_features(jira_dev_panel_integration: true)
end end
context 'has Jira dev panel integration license' do context 'with a Jira subscription' do
before do before do
stub_licensed_features(jira_dev_panel_integration: true) create(:jira_connect_subscription, namespace: project.namespace)
end end
context 'with a Jira subscription' do context 'branch name contains Jira issue key' do
before do let(:branch_to_sync) { 'branch-JIRA-123' }
create(:jira_connect_subscription, namespace: project.namespace) let(:ref) { "refs/heads/#{branch_to_sync}" }
end
context 'branch name contains Jira issue key' do
let(:branch_to_sync) { 'branch-JIRA-123' }
let(:ref) { "refs/heads/#{branch_to_sync}" }
it_behaves_like 'enqueues Jira sync worker' it_behaves_like 'enqueues Jira sync worker'
end end
context 'commit message contains Jira issue key' do
let(:commits_to_sync) { [newrev] }
before do context 'commit message contains Jira issue key' do
allow_any_instance_of(Commit).to receive(:safe_message).and_return('Commit with key JIRA-123') let(:commits_to_sync) { [newrev] }
end
it_behaves_like 'enqueues Jira sync worker' before do
allow_any_instance_of(Commit).to receive(:safe_message).and_return('Commit with key JIRA-123')
end end
context 'branch name and commit message does not contain Jira issue key' do it_behaves_like 'enqueues Jira sync worker'
it_behaves_like 'does not enqueue Jira sync worker'
end
end end
context 'without a Jira subscription' do context 'branch name and commit message does not contain Jira issue key' do
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
end end
end end
context 'does not have Jira dev panel integration license' do context 'without a Jira subscription' do
before do
stub_licensed_features(jira_dev_panel_integration: false)
end
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
end end
end end
context 'when feature is disabled' do context 'does not have Jira dev panel integration license' do
before do before do
stub_feature_flags(jira_connect_app: false) stub_licensed_features(jira_dev_panel_integration: false)
end end
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
......
...@@ -35,49 +35,35 @@ describe MergeRequests::BaseService do ...@@ -35,49 +35,35 @@ describe MergeRequests::BaseService do
end end
end end
context 'when feature is enabled' do context 'has Jira dev panel integration license' do
before do before do
stub_feature_flags(jira_connect_app: true) stub_licensed_features(jira_dev_panel_integration: true)
end end
context 'has Jira dev panel integration license' do context 'with a Jira subscription' do
before do before do
stub_licensed_features(jira_dev_panel_integration: true) create(:jira_connect_subscription, namespace: project.namespace)
end end
context 'with a Jira subscription' do context 'MR contains Jira issue key' do
before do let(:title) { 'Awesome merge_request with issue JIRA-123' }
create(:jira_connect_subscription, namespace: project.namespace)
end
context 'MR contains Jira issue key' do it_behaves_like 'enqueues Jira sync worker'
let(:title) { 'Awesome merge_request with issue JIRA-123' }
it_behaves_like 'enqueues Jira sync worker'
end
context 'MR does not contain Jira issue key' do
it_behaves_like 'does not enqueue Jira sync worker'
end
end end
context 'without a Jira subscription' do context 'MR does not contain Jira issue key' do
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
end end
end end
context 'does not have Jira dev panel integration license' do context 'without a Jira subscription' do
before do
stub_licensed_features(jira_dev_panel_integration: false)
end
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
end end
end end
context 'when feature is disabled' do context 'does not have Jira dev panel integration license' do
before do before do
stub_feature_flags(jira_connect_app: false) stub_licensed_features(jira_dev_panel_integration: false)
end end
it_behaves_like 'does not enqueue Jira sync worker' it_behaves_like 'does not enqueue Jira sync worker'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment