Commit 77282d62 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '229158-remove-pagerduty_webhook-feature-flag' into 'master'

Remove pagerduty_webhook feature flag

See merge request gitlab-org/gitlab!37193
parents 5059c8bd 013360a9
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { GlButton, GlTabs, GlTab } from '@gitlab/ui'; import { GlButton, GlTabs, GlTab } from '@gitlab/ui';
import AlertsSettingsForm from './alerts_form.vue'; import AlertsSettingsForm from './alerts_form.vue';
import PagerDutySettingsForm from './pagerduty_form.vue'; import PagerDutySettingsForm from './pagerduty_form.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { INTEGRATION_TABS_CONFIG, I18N_INTEGRATION_TABS } from '../constants'; import { INTEGRATION_TABS_CONFIG, I18N_INTEGRATION_TABS } from '../constants';
export default { export default {
...@@ -13,17 +12,8 @@ export default { ...@@ -13,17 +12,8 @@ export default {
AlertsSettingsForm, AlertsSettingsForm,
PagerDutySettingsForm, PagerDutySettingsForm,
}, },
mixins: [glFeatureFlagMixin()],
tabs: INTEGRATION_TABS_CONFIG, tabs: INTEGRATION_TABS_CONFIG,
i18n: I18N_INTEGRATION_TABS, i18n: I18N_INTEGRATION_TABS,
methods: {
isFeatureFlagEnabled(tab) {
if (tab.featureFlag) {
return this.glFeatures[tab.featureFlag];
}
return true;
},
},
}; };
</script> </script>
...@@ -49,7 +39,7 @@ export default { ...@@ -49,7 +39,7 @@ export default {
<gl-tabs> <gl-tabs>
<gl-tab <gl-tab
v-for="(tab, index) in $options.tabs" v-for="(tab, index) in $options.tabs"
v-if="tab.active && isFeatureFlagEnabled(tab)" v-if="tab.active"
:key="`${tab.title}_${index}`" :key="`${tab.title}_${index}`"
:title="tab.title" :title="tab.title"
> >
......
...@@ -11,7 +11,6 @@ export const INTEGRATION_TABS_CONFIG = [ ...@@ -11,7 +11,6 @@ export const INTEGRATION_TABS_CONFIG = [
title: s__('IncidentSettings|PagerDuty integration'), title: s__('IncidentSettings|PagerDuty integration'),
component: 'PagerDutySettingsForm', component: 'PagerDutySettingsForm',
active: true, active: true,
featureFlag: 'pagerdutyWebhook',
}, },
{ {
title: s__('IncidentSettings|Grafana integration'), title: s__('IncidentSettings|Grafana integration'),
......
...@@ -6,10 +6,6 @@ module Projects ...@@ -6,10 +6,6 @@ module Projects
before_action :authorize_admin_operations! before_action :authorize_admin_operations!
before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token] before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token]
before_action do
push_frontend_feature_flag(:pagerduty_webhook, project)
end
respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token] respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token]
helper_method :error_tracking_setting helper_method :error_tracking_setting
......
...@@ -40,8 +40,7 @@ module IncidentManagement ...@@ -40,8 +40,7 @@ module IncidentManagement
end end
def webhook_available? def webhook_available?
Feature.enabled?(:pagerduty_webhook, project) && incident_management_setting.pagerduty_active?
incident_management_setting.pagerduty_active?
end end
def forbidden def forbidden
......
...@@ -39,8 +39,7 @@ module IncidentManagement ...@@ -39,8 +39,7 @@ module IncidentManagement
end end
def webhook_setting_active? def webhook_setting_active?
Feature.enabled?(:pagerduty_webhook, project) && incident_management_setting.pagerduty_active?
incident_management_setting.pagerduty_active?
end end
def valid_token?(token) def valid_token?(token)
......
---
title: Add PagerDuty incident integration.
merge_request: 37193
author:
type: added
...@@ -6,9 +6,7 @@ describe('IncidentsSettingTabs', () => { ...@@ -6,9 +6,7 @@ describe('IncidentsSettingTabs', () => {
let wrapper; let wrapper;
beforeEach(() => { beforeEach(() => {
wrapper = shallowMount(IncidentsSettingTabs, { wrapper = shallowMount(IncidentsSettingTabs);
provide: { glFeatures: { pagerdutyWebhook: true } },
});
}); });
afterEach(() => { afterEach(() => {
......
...@@ -12,84 +12,63 @@ RSpec.describe IncidentManagement::PagerDuty::CreateIncidentIssueService do ...@@ -12,84 +12,63 @@ RSpec.describe IncidentManagement::PagerDuty::CreateIncidentIssueService do
subject(:execute) { described_class.new(project, incident_payload).execute } subject(:execute) { described_class.new(project, incident_payload).execute }
describe '#execute' do describe '#execute' do
context 'when pagerduty_webhook feature enabled' do context 'when PagerDuty webhook setting is active' do
before do let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: true) }
stub_feature_flags(pagerduty_webhook: project)
end
context 'when PagerDuty webhook setting is active' do context 'when issue can be created' do
let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: true) } it 'creates a new issue' do
expect { execute }.to change(Issue, :count).by(1)
context 'when issue can be created' do
it 'creates a new issue' do
expect { execute }.to change(Issue, :count).by(1)
end
it 'responds with success' do
response = execute
expect(response).to be_success
expect(response.payload[:issue]).to be_kind_of(Issue)
end
it 'the issue author is Alert bot' do
expect(execute.payload[:issue].author).to eq(User.alert_bot)
end
it 'issue has a correct title' do
expect(execute.payload[:issue].title).to eq(incident_payload['title'])
end
it 'issue has a correct description' do
markdown_line_break = ' '
expect(execute.payload[:issue].description).to eq(
<<~MARKDOWN.chomp
**Incident:** [My new incident](https://webdemo.pagerduty.com/incidents/PRORDTY)#{markdown_line_break}
**Incident number:** 33#{markdown_line_break}
**Urgency:** high#{markdown_line_break}
**Status:** triggered#{markdown_line_break}
**Incident key:** #{markdown_line_break}
**Created at:** 26 September 2017, 3:14PM (UTC)#{markdown_line_break}
**Assignees:** [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)#{markdown_line_break}
**Impacted services:** [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75)
MARKDOWN
)
end
end end
context 'when the payload does not contain a title' do it 'responds with success' do
let(:incident_payload) { {} } response = execute
expect(response).to be_success
expect(response.payload[:issue]).to be_kind_of(Issue)
end
it 'does not create a GitLab issue' do it 'the issue author is Alert bot' do
expect { execute }.not_to change(Issue, :count) expect(execute.payload[:issue].author).to eq(User.alert_bot)
end end
it 'responds with error' do it 'issue has a correct title' do
expect(execute).to be_error expect(execute.payload[:issue].title).to eq(incident_payload['title'])
expect(execute.message).to eq("Title can't be blank") end
end
it 'issue has a correct description' do
markdown_line_break = ' '
expect(execute.payload[:issue].description).to eq(
<<~MARKDOWN.chomp
**Incident:** [My new incident](https://webdemo.pagerduty.com/incidents/PRORDTY)#{markdown_line_break}
**Incident number:** 33#{markdown_line_break}
**Urgency:** high#{markdown_line_break}
**Status:** triggered#{markdown_line_break}
**Incident key:** #{markdown_line_break}
**Created at:** 26 September 2017, 3:14PM (UTC)#{markdown_line_break}
**Assignees:** [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)#{markdown_line_break}
**Impacted services:** [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75)
MARKDOWN
)
end end
end end
context 'when PagerDuty webhook setting is not active' do context 'when the payload does not contain a title' do
let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) } let(:incident_payload) { {} }
it 'does not create a GitLab issue' do it 'does not create a GitLab issue' do
expect { execute }.not_to change(Issue, :count) expect { execute }.not_to change(Issue, :count)
end end
it 'responds with forbidden' do it 'responds with error' do
expect(execute).to be_error expect(execute).to be_error
expect(execute.http_status).to eq(:forbidden) expect(execute.message).to eq("Title can't be blank")
end end
end end
end end
context 'when pagerduty_webhook feature disabled' do context 'when PagerDuty webhook setting is not active' do
before do let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) }
stub_feature_flags(pagerduty_webhook: false)
end
it 'does not create a GitLab issue' do it 'does not create a GitLab issue' do
expect { execute }.not_to change(Issue, :count) expect { execute }.not_to change(Issue, :count)
......
...@@ -19,92 +19,68 @@ RSpec.describe IncidentManagement::PagerDuty::ProcessWebhookService do ...@@ -19,92 +19,68 @@ RSpec.describe IncidentManagement::PagerDuty::ProcessWebhookService do
subject(:execute) { described_class.new(project, nil, webhook_payload).execute(token) } subject(:execute) { described_class.new(project, nil, webhook_payload).execute(token) }
context 'when pagerduty_webhook feature is enabled' do context 'when PagerDuty webhook setting is active' do
before do let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: true) }
stub_feature_flags(pagerduty_webhook: project)
end
context 'when PagerDuty webhook setting is active' do
let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: true) }
context 'when token is valid' do
let(:token) { incident_management_setting.pagerduty_token }
context 'when webhook payload has acceptable size' do context 'when token is valid' do
it 'responds with Accepted' do let(:token) { incident_management_setting.pagerduty_token }
result = execute
expect(result).to be_success context 'when webhook payload has acceptable size' do
expect(result.http_status).to eq(:accepted) it 'responds with Accepted' do
end result = execute
it 'processes issues' do
incident_payload = ::PagerDuty::WebhookPayloadParser.call(webhook_payload).first['incident']
expect(::IncidentManagement::PagerDuty::ProcessIncidentWorker)
.to receive(:perform_async)
.with(project.id, incident_payload)
.once
execute expect(result).to be_success
end expect(result.http_status).to eq(:accepted)
end end
context 'when webhook payload is too big' do it 'processes issues' do
let(:deep_size) { instance_double(Gitlab::Utils::DeepSize, valid?: false) } incident_payload = ::PagerDuty::WebhookPayloadParser.call(webhook_payload).first['incident']
before do
allow(Gitlab::Utils::DeepSize)
.to receive(:new)
.with(webhook_payload, max_size: described_class::PAGER_DUTY_PAYLOAD_SIZE_LIMIT)
.and_return(deep_size)
end
it 'responds with Bad Request' do expect(::IncidentManagement::PagerDuty::ProcessIncidentWorker)
result = execute .to receive(:perform_async)
.with(project.id, incident_payload)
.once
expect(result).to be_error execute
expect(result.http_status).to eq(:bad_request)
end
it_behaves_like 'does not process incidents'
end end
end
context 'when webhook payload is blank' do context 'when webhook payload is too big' do
let(:webhook_payload) { nil } let(:deep_size) { instance_double(Gitlab::Utils::DeepSize, valid?: false) }
it 'responds with Accepted' do before do
result = execute allow(Gitlab::Utils::DeepSize)
.to receive(:new)
.with(webhook_payload, max_size: described_class::PAGER_DUTY_PAYLOAD_SIZE_LIMIT)
.and_return(deep_size)
end
expect(result).to be_success it 'responds with Bad Request' do
expect(result.http_status).to eq(:accepted) result = execute
end
it_behaves_like 'does not process incidents' expect(result).to be_error
expect(result.http_status).to eq(:bad_request)
end end
it_behaves_like 'does not process incidents'
end end
context 'when token is invalid' do context 'when webhook payload is blank' do
let(:token) { 'invalid-token' } let(:webhook_payload) { nil }
it 'responds with Unauthorized' do it 'responds with Accepted' do
result = execute result = execute
expect(result).to be_error expect(result).to be_success
expect(result.http_status).to eq(:unauthorized) expect(result.http_status).to eq(:accepted)
end end
it_behaves_like 'does not process incidents' it_behaves_like 'does not process incidents'
end end
end end
context 'when both tokens are nil' do context 'when token is invalid' do
let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) } let(:token) { 'invalid-token' }
let(:token) { nil }
before do
incident_management_setting.update_column(:pagerduty_active, true)
end
it 'responds with Unauthorized' do it 'responds with Unauthorized' do
result = execute result = execute
...@@ -115,25 +91,28 @@ RSpec.describe IncidentManagement::PagerDuty::ProcessWebhookService do ...@@ -115,25 +91,28 @@ RSpec.describe IncidentManagement::PagerDuty::ProcessWebhookService do
it_behaves_like 'does not process incidents' it_behaves_like 'does not process incidents'
end end
end
context 'when PagerDuty webhook setting is not active' do context 'when both tokens are nil' do
let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) } let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) }
let(:token) { nil }
it 'responds with Forbidden' do before do
result = execute incident_management_setting.update_column(:pagerduty_active, true)
end
expect(result).to be_error it 'responds with Unauthorized' do
expect(result.http_status).to eq(:forbidden) result = execute
end
it_behaves_like 'does not process incidents' expect(result).to be_error
expect(result.http_status).to eq(:unauthorized)
end end
it_behaves_like 'does not process incidents'
end end
context 'when pagerduty_webhook feature is disabled' do context 'when PagerDuty webhook setting is not active' do
before do let_it_be(:incident_management_setting) { create(:project_incident_management_setting, project: project, pagerduty_active: false) }
stub_feature_flags(pagerduty_webhook: false)
end
it 'responds with Forbidden' do it 'responds with Forbidden' do
result = execute result = execute
......
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