From 04ebfaf17cfb4c85e29316937d7d44667ccc049f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 17 Aug 2021 06:08:59 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../admin/integrations_controller.rb | 2 -- app/helpers/integrations_helper.rb | 8 +++--- .../projects/operations/update_service.rb | 9 ++++++- .../instance_level_integration_overrides.yml | 8 ------ doc/api/error_tracking.md | 15 ++++++----- .../project_integration_management.md | 12 +++++++++ doc/user/application_security/dast/index.md | 4 +-- lib/api/entities/error_tracking.rb | 1 + lib/api/error_tracking.rb | 5 ++++ locale/gitlab.pot | 4 +-- .../admin/integrations_controller_spec.rb | 12 --------- ...activates_mattermost_slash_command_spec.rb | 12 --------- ...activates_mattermost_slash_command_spec.rb | 5 ++++ spec/requests/api/error_tracking_spec.rb | 16 +++++++++++- .../operations/update_service_spec.rb | 25 +++++++++++++++++++ 15 files changed, 87 insertions(+), 51 deletions(-) delete mode 100644 config/feature_flags/development/instance_level_integration_overrides.yml diff --git a/app/controllers/admin/integrations_controller.rb b/app/controllers/admin/integrations_controller.rb index 50f97deb99d..a3eb24b9b6f 100644 --- a/app/controllers/admin/integrations_controller.rb +++ b/app/controllers/admin/integrations_controller.rb @@ -8,8 +8,6 @@ class Admin::IntegrationsController < Admin::ApplicationController feature_category :integrations def overrides - return render_404 unless instance_level_integration_overrides? - respond_to do |format| format.json do projects = Project.with_active_integration(integration.class).merge(::Integration.with_custom_settings) diff --git a/app/helpers/integrations_helper.rb b/app/helpers/integrations_helper.rb index d06746c06e3..f15566a551a 100644 --- a/app/helpers/integrations_helper.rb +++ b/app/helpers/integrations_helper.rb @@ -128,14 +128,12 @@ module IntegrationsHelper def integration_tabs(integration:) [ { key: 'edit', text: _('Settings'), href: scoped_edit_integration_path(integration) }, - ({ key: 'overrides', text: s_('Integrations|Projects using custom settings'), href: scoped_overrides_integration_path(integration) } if instance_level_integration_overrides?) + ( + { key: 'overrides', text: s_('Integrations|Projects using custom settings'), href: scoped_overrides_integration_path(integration) } if integration.instance_level? + ) ].compact end - def instance_level_integration_overrides? - Feature.enabled?(:instance_level_integration_overrides, default_enabled: :yaml) - end - def jira_issue_breadcrumb_link(issue_reference) link_to '', { class: 'gl-display-flex gl-align-items-center gl-white-space-nowrap' } do icon = image_tag image_path('illustrations/logos/jira.svg'), width: 15, height: 15, class: 'gl-mr-2' diff --git a/app/services/projects/operations/update_service.rb b/app/services/projects/operations/update_service.rb index 2cc6bcdf57c..51b8e3c6c54 100644 --- a/app/services/projects/operations/update_service.rb +++ b/app/services/projects/operations/update_service.rb @@ -63,8 +63,15 @@ module Projects # Make sure we're converting to symbols because # * ActionController::Parameters#keys returns a list of strings # * in specs we're using hashes with symbols as keys + update_keys = settings.keys.map(&:to_sym) - settings.keys.map(&:to_sym) == %i[enabled] + # Integrated error tracking works without Sentry integration, + # so we don't need to update all those values from error_tracking_params_for_update method. + # Instead we turn it on/off with partial update together with "enabled" attribute. + # But since its optional, we exclude it from the condition below. + update_keys.delete(:integrated) + + update_keys == %i[enabled] end def error_tracking_params_for_partial_update(settings) diff --git a/config/feature_flags/development/instance_level_integration_overrides.yml b/config/feature_flags/development/instance_level_integration_overrides.yml deleted file mode 100644 index 6b1f3dd4276..00000000000 --- a/config/feature_flags/development/instance_level_integration_overrides.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: instance_level_integration_overrides -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66723 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/336750 -milestone: '14.2' -type: development -group: group::integrations -default_enabled: false diff --git a/doc/api/error_tracking.md b/doc/api/error_tracking.md index fbfd2a69ef7..0fbb30ef364 100644 --- a/doc/api/error_tracking.md +++ b/doc/api/error_tracking.md @@ -34,7 +34,8 @@ Example response: "active": true, "project_name": "sample sentry project", "sentry_external_url": "https://sentry.io/myawesomeproject/project", - "api_url": "https://sentry.io/api/0/projects/myawesomeproject/project" + "api_url": "https://sentry.io/api/0/projects/myawesomeproject/project", + "integrated": false } ``` @@ -46,10 +47,11 @@ The API allows you to enable or disable the Error Tracking settings for a projec PATCH /projects/:id/error_tracking/settings ``` -| Attribute | Type | Required | Description | -| --------- | ------- | -------- | --------------------- | -| `id` | integer | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user. | -| `active` | boolean | yes | Pass `true` to enable the already configured error tracking settings or `false` to disable it. | +| Attribute | Type | Required | Description | +| ------------ | ------- | -------- | --------------------- | +| `id` | integer | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user. | +| `active` | boolean | yes | Pass `true` to enable the already configured error tracking settings or `false` to disable it. | +| `integrated` | boolean | no | Pass `true` to enable the integrated error tracking backend. Available in [GitLab 14.2](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/68260) and later. | ```shell curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/error_tracking/settings?active=true" @@ -62,6 +64,7 @@ Example response: "active": true, "project_name": "sample sentry project", "sentry_external_url": "https://sentry.io/myawesomeproject/project", - "api_url": "https://sentry.io/api/0/projects/myawesomeproject/project" + "api_url": "https://sentry.io/api/0/projects/myawesomeproject/project", + "integrated": false } ``` diff --git a/doc/user/admin_area/settings/project_integration_management.md b/doc/user/admin_area/settings/project_integration_management.md index b8f9fef41ec..3b949b638d8 100644 --- a/doc/user/admin_area/settings/project_integration_management.md +++ b/doc/user/admin_area/settings/project_integration_management.md @@ -61,6 +61,18 @@ integration on all non-configured groups and projects by default. Resetting an instance-level default setting removes the integration from all projects that have the integration set to use default settings. +### View projects that override the default settings + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/218252) in GitLab 14.2. + +You can view which projects in your instance use custom settings that [override the instance-level default settings](#use-custom-settings-for-a-group-or-project-integration) +for an integration. + +1. On the top bar, select **Menu >** **{admin}** **Admin**. +1. In the left sidebar, select **Settings > Integrations**. +1. Select an integration. +1. Select the **Projects using custom settings** tab. + ## Manage group-level default settings for a project integration > [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/2543) in GitLab 13.6. diff --git a/doc/user/application_security/dast/index.md b/doc/user/application_security/dast/index.md index cffdf208016..7455915761c 100644 --- a/doc/user/application_security/dast/index.md +++ b/doc/user/application_security/dast/index.md @@ -1049,8 +1049,8 @@ When an API site type is selected, a [host override](#host-override) is used to #### Site profile validation > - Site profile validation [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/233020) in GitLab 13.8. -> - Meta tag validation [enabled on GitLab.com](https://gitlab.com/issue/etc) in GitLab 14.2 and is ready for production use. -> - Meta tag validation [enabled with `dast_meta_tag_validation flag` flag](https://gitlab.com/issue/etc) for self-managed GitLab in GitLab 14.2 and is ready for production use. +> - Meta tag validation [enabled on GitLab.com](https://gitlab.com/groups/gitlab-org/-/epics/6460) in GitLab 14.2 and is ready for production use. +> - Meta tag validation [enabled with `dast_meta_tag_validation flag` flag](https://gitlab.com/gitlab-org/gitlab/-/issues/337711) for self-managed GitLab in GitLab 14.2 and is ready for production use. FLAG: On self-managed GitLab, by default this feature is available. To hide the feature, ask an administrator to [disable the `dast_meta_tag_validation` flag](../../../administration/feature_flags.md). On GitLab.com, this feature is available but can be configured by GitLab.com administrators only. diff --git a/lib/api/entities/error_tracking.rb b/lib/api/entities/error_tracking.rb index c762c274486..a38e00ca295 100644 --- a/lib/api/entities/error_tracking.rb +++ b/lib/api/entities/error_tracking.rb @@ -8,6 +8,7 @@ module API expose :project_name expose :sentry_external_url expose :api_url + expose :integrated end end end diff --git a/lib/api/error_tracking.rb b/lib/api/error_tracking.rb index 0e44c8b1081..3abf2831bd3 100644 --- a/lib/api/error_tracking.rb +++ b/lib/api/error_tracking.rb @@ -32,6 +32,7 @@ module API end params do requires :active, type: Boolean, desc: 'Specifying whether to enable or disable error tracking settings', allow_blank: false + optional :integrated, type: Boolean, desc: 'Specifying whether to enable or disable integrated error tracking' end patch ':id/error_tracking/settings/' do @@ -45,6 +46,10 @@ module API error_tracking_setting_attributes: { enabled: params[:active] } } + unless params[:integrated].nil? + update_params[:error_tracking_setting_attributes][:integrated] = params[:integrated] + end + result = ::Projects::Operations::UpdateService.new(user_project, current_user, update_params).execute if result[:status] == :success diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 0a34adb8894..7461a106699 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -660,7 +660,7 @@ msgstr "" msgid "%{labelStart}Namespace:%{labelEnd} %{namespace}" msgstr "" -msgid "%{labelStart}Scan Type:%{labelEnd} %{reportType}" +msgid "%{labelStart}Scanner:%{labelEnd} %{scanner}" msgstr "" msgid "%{labelStart}Sent request:%{labelEnd} %{headers}" @@ -669,7 +669,7 @@ msgstr "" msgid "%{labelStart}Severity:%{labelEnd} %{severity}" msgstr "" -msgid "%{labelStart}Tool:%{labelEnd} %{scanner}" +msgid "%{labelStart}Tool:%{labelEnd} %{reportType}" msgstr "" msgid "%{labelStart}Unmodified response:%{labelEnd} %{headers}" diff --git a/spec/controllers/admin/integrations_controller_spec.rb b/spec/controllers/admin/integrations_controller_spec.rb index 3d37fe7bf79..64ae2a95b4e 100644 --- a/spec/controllers/admin/integrations_controller_spec.rb +++ b/spec/controllers/admin/integrations_controller_spec.rb @@ -131,18 +131,6 @@ RSpec.describe Admin::IntegrationsController do expect(response).to render_template 'shared/integrations/overrides' expect(assigns(:integration)).to eq(instance_integration) end - - context 'when `instance_level_integration_overrides` is not enabled' do - before do - stub_feature_flags(instance_level_integration_overrides: false) - end - - it 'renders a 404' do - subject - - expect(response).to have_gitlab_http_status(:not_found) - end - end end end end diff --git a/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb index c4626996d0c..22a27b33671 100644 --- a/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb +++ b/spec/features/admin/integrations/user_activates_mattermost_slash_command_spec.rb @@ -19,16 +19,4 @@ RSpec.describe 'User activates the instance-level Mattermost Slash Command integ expect(page).to have_link('Settings', href: edit_path) expect(page).to have_link('Projects using custom settings', href: overrides_path) end - - context 'when instance_level_integration_overrides is disabled' do - before do - stub_feature_flags(instance_level_integration_overrides: false) - visit_instance_integration('Mattermost slash commands') - end - - it 'does not display the overrides tab' do - expect(page).not_to have_link('Settings', href: edit_path) - expect(page).not_to have_link('Projects using custom settings', href: overrides_path) - end - end end diff --git a/spec/features/groups/integrations/user_activates_mattermost_slash_command_spec.rb b/spec/features/groups/integrations/user_activates_mattermost_slash_command_spec.rb index 7703268af39..02aa418cd73 100644 --- a/spec/features/groups/integrations/user_activates_mattermost_slash_command_spec.rb +++ b/spec/features/groups/integrations/user_activates_mattermost_slash_command_spec.rb @@ -13,4 +13,9 @@ RSpec.describe 'User activates the group-level Mattermost Slash Command integrat let(:edit_path) { edit_group_settings_integration_path(group, :mattermost_slash_commands) } include_examples 'user activates the Mattermost Slash Command integration' + + it 'does not display the overrides tab' do + expect(page).not_to have_link('Settings', href: edit_path) + expect(page).not_to have_link('Projects using custom settings', href: overrides_admin_application_settings_integration_path(:mattermost_slash_commands)) + end end diff --git a/spec/requests/api/error_tracking_spec.rb b/spec/requests/api/error_tracking_spec.rb index 39121af7bc3..ec9a3378acc 100644 --- a/spec/requests/api/error_tracking_spec.rb +++ b/spec/requests/api/error_tracking_spec.rb @@ -17,7 +17,8 @@ RSpec.describe API::ErrorTracking do 'active' => setting.reload.enabled, 'project_name' => setting.project_name, 'sentry_external_url' => setting.sentry_external_url, - 'api_url' => setting.api_url + 'api_url' => setting.api_url, + 'integrated' => setting.integrated ) end end @@ -79,6 +80,19 @@ RSpec.describe API::ErrorTracking do .to eq('active is empty') end end + + context 'with integrated param' do + let(:params) { { active: true, integrated: true } } + + it 'updates the integrated flag' do + expect(setting.integrated).to be_falsey + + make_request + + expect(json_response).to include('integrated' => true) + expect(setting.reload.integrated).to be_truthy + end + end end context 'without a project setting' do diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb index f91f879b772..1d9d5f6e938 100644 --- a/spec/services/projects/operations/update_service_spec.rb +++ b/spec/services/projects/operations/update_service_spec.rb @@ -262,6 +262,31 @@ RSpec.describe Projects::Operations::UpdateService do expect(project.error_tracking_setting.previous_changes.keys) .to contain_exactly('enabled') end + + context 'with integrated attribute' do + let(:params) do + { + error_tracking_setting_attributes: { + enabled: true, + integrated: true + } + } + end + + it 'updates integrated attribute' do + expect { result } + .to change { project.reload.error_tracking_setting.integrated } + .from(false) + .to(true) + end + + it 'only updates enabled and integrated attributes' do + result + + expect(project.error_tracking_setting.previous_changes.keys) + .to contain_exactly('enabled', 'integrated') + end + end end context 'without setting' do