Commit 4b49e8b9 authored by Justin Ho's avatar Justin Ho

Hide instance-level integrations on GitLab.com

- Remove menu from admin sidebar
- Return 404 Not Found on listing and edit integration
pages to prevent access directly through the URL.
parent 797a2c2a
......@@ -32,6 +32,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def integrations
return not_found if Gitlab.com?
@integrations = Service.find_or_initialize_all(Service.for_instance).sort_by(&:title)
end
......
......@@ -10,7 +10,7 @@ class Admin::IntegrationsController < Admin::ApplicationController
end
def integrations_enabled?
true
!Gitlab.com?
end
def scoped_edit_integration_path(integration)
......
......@@ -260,10 +260,11 @@
= link_to general_admin_application_settings_path, title: _('General'), class: 'qa-admin-settings-general-item' do
%span
= _('General')
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span
= _('Integrations')
- unless Gitlab.com?
= nav_link(path: ['application_settings#integrations', 'integrations#edit']) do
= link_to integrations_admin_application_settings_path, title: _('Integrations'), data: { qa_selector: 'integration_settings_link' } do
%span
= _('Integrations')
= nav_link(path: 'application_settings#repository') do
= link_to repository_admin_application_settings_path, title: _('Repository'), class: 'qa-admin-settings-repository-item' do
%span
......
---
title: Hide instance-level integrations on GitLab.com
merge_request: 42808
author:
type: changed
......@@ -15,6 +15,37 @@ RSpec.describe Admin::ApplicationSettingsController do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
describe 'GET #integrations' do
before do
sign_in(admin)
end
context 'when GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { true }
end
it 'returns 404' do
get :integrations
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when not GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { false }
end
it 'renders correct template' do
get :integrations
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('admin/application_settings/integrations')
end
end
end
describe 'GET #usage_data with no access' do
before do
stub_usage_data_connections
......
......@@ -20,6 +20,18 @@ RSpec.describe Admin::IntegrationsController do
end
end
end
context 'when GitLab.com' do
before do
allow(::Gitlab).to receive(:com?) { true }
end
it 'returns 404' do
get :edit, params: { id: Service.available_services_names.sample }
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
describe '#update' do
......
......@@ -92,7 +92,11 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
end
context 'on settings' do
let(:gitlab_com?) { false }
before do
allow(::Gitlab).to receive(:com?) { gitlab_com? }
render
end
......@@ -100,6 +104,20 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
expect(rendered).to have_link('General', href: general_admin_application_settings_path)
end
context 'when GitLab.com' do
let(:gitlab_com?) { true }
it 'does not include Integrations link' do
expect(rendered).not_to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
context 'when not GitLab.com' do
it 'includes Integrations link' do
expect(rendered).to have_link('Integrations', href: integrations_admin_application_settings_path)
end
end
context 'when GitLab FOSS' do
it 'does not include Templates link' do
expect(rendered).not_to have_link('Templates', href: '/admin/application_settings/templates')
......
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