Commit 6bf4e937 authored by syasonik's avatar syasonik

Remove logic for opsgenie integration

parent 194ed506
...@@ -34,5 +34,3 @@ module Projects::AlertManagementHelper ...@@ -34,5 +34,3 @@ module Projects::AlertManagementHelper
) )
end end
end end
Projects::AlertManagementHelper.prepend_if_ee('EE::Projects::AlertManagementHelper')
...@@ -88,5 +88,3 @@ class AlertsService < Service ...@@ -88,5 +88,3 @@ class AlertsService < Service
.execute .execute
end end
end end
AlertsService.prepend_if_ee('EE::AlertsService')
...@@ -10,8 +10,6 @@ module EE ...@@ -10,8 +10,6 @@ module EE
:multiproject_enabled, :multiproject_enabled,
:pass_unstable, :pass_unstable,
:project_name, :project_name,
:opsgenie_mvc_enabled,
:opsgenie_mvc_target_url,
:repository_url, :repository_url,
:static_context, :static_context,
:vulnerabilities_enabled, :vulnerabilities_enabled,
......
...@@ -37,7 +37,7 @@ module EE ...@@ -37,7 +37,7 @@ module EE
override :alerts_settings_data override :alerts_settings_data
def alerts_settings_data(disabled: false) def alerts_settings_data(disabled: false)
super.merge(opsgenie_mvc_data, alert_management_multiple_integrations_data) super.merge(alert_management_multiple_integrations_data)
end end
override :operations_settings_data override :operations_settings_data
...@@ -67,17 +67,6 @@ module EE ...@@ -67,17 +67,6 @@ module EE
::IncidentManagement::IncidentSla.available_for?(@project) ::IncidentManagement::IncidentSla.available_for?(@project)
end end
def opsgenie_mvc_data
return {} unless alerts_service.opsgenie_mvc_available?
{
'opsgenie_mvc_available' => 'true',
'opsgenie_mvc_form_path' => scoped_integration_path(alerts_service),
'opsgenie_mvc_enabled' => alerts_service.opsgenie_mvc_enabled?.to_s,
'opsgenie_mvc_target_url' => alerts_service.opsgenie_mvc_target_url.to_s
}
end
def alert_management_multiple_integrations_data def alert_management_multiple_integrations_data
{ {
'multi_integrations' => @project.feature_available?(:multiple_alert_http_integrations).to_s 'multi_integrations' => @project.feature_available?(:multiple_alert_http_integrations).to_s
......
# frozen_string_literal: true
module EE
module Projects
module AlertManagementHelper
extend ::Gitlab::Utils::Override
override :alert_management_data
def alert_management_data(current_user, project)
super.merge(
alert_management_opsgenie_mvc_data(project.alerts_service)
)
end
private
def alert_management_opsgenie_mvc_data(alerts_service)
return {} unless alerts_service&.opsgenie_mvc_available?
{
'opsgenie_mvc_available' => 'true',
'opsgenie_mvc_enabled' => alerts_service.opsgenie_mvc_enabled?.to_s,
'opsgenie_mvc_target_url' => alerts_service.opsgenie_mvc_target_url.to_s
}
end
end
end
end
# frozen_string_literal: true
module EE
module AlertsService
extend ActiveSupport::Concern
prepended do
boolean_accessor :opsgenie_mvc_enabled
prop_accessor :opsgenie_mvc_target_url
validates :opsgenie_mvc_target_url, presence: true, public_url: true,
if: :opsgenie_mvc_enabled?
end
def opsgenie_mvc_available?
return false if instance? || template?
project.feature_available?(:opsgenie_integration)
end
end
end
...@@ -111,7 +111,6 @@ class License < ApplicationRecord ...@@ -111,7 +111,6 @@ class License < ApplicationRecord
multiple_group_issue_boards multiple_group_issue_boards
object_storage object_storage
operations_dashboard operations_dashboard
opsgenie_integration
package_forwarding package_forwarding
pages_size_limit pages_size_limit
productivity_analytics productivity_analytics
......
...@@ -75,47 +75,6 @@ RSpec.describe OperationsHelper, :routing do ...@@ -75,47 +75,6 @@ RSpec.describe OperationsHelper, :routing do
describe '#alerts_settings_data' do describe '#alerts_settings_data' do
subject { helper.alerts_settings_data } subject { helper.alerts_settings_data }
describe 'Opsgenie MVC attributes' do
let_it_be(:alerts_service) do
create(:alerts_service,
project: project,
opsgenie_mvc_enabled: false,
opsgenie_mvc_target_url: 'https://appname.app.opsgenie.com/alert/list'
)
end
let_it_be(:prometheus_service) { build_stubbed(:prometheus_service) }
before do
allow(helper).to receive(:alerts_service).and_return(alerts_service)
allow(helper).to receive(:prometheus_service).and_return(prometheus_service)
allow(alerts_service).to receive(:opsgenie_mvc_available?).and_return(opsgenie_available)
end
context 'when available' do
let(:opsgenie_available) { true }
it do
is_expected.to include(
'opsgenie_mvc_available' => 'true',
'opsgenie_mvc_form_path' => project_service_path(project, alerts_service),
'opsgenie_mvc_enabled' => 'false',
'opsgenie_mvc_target_url' => 'https://appname.app.opsgenie.com/alert/list'
)
end
end
context 'when not available' do
let(:opsgenie_keys) do
%w[opsgenie_mvc_available opsgenie_mvc_enabled opsgenie_mvc_form_path opsgenie_mvc_target_url]
end
let(:opsgenie_available) { false }
it { is_expected.not_to include(opsgenie_keys) }
end
end
describe 'Multiple Integrations Support' do describe 'Multiple Integrations Support' do
before do before do
stub_licensed_features(multiple_alert_http_integrations: multi_integrations) stub_licensed_features(multiple_alert_http_integrations: multi_integrations)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::AlertManagementHelper do
let(:project) { build_stubbed(:project) }
let(:current_user) { build_stubbed(:user) }
before do
allow(helper).to receive(:can?)
.with(current_user, :admin_operations, project) { true }
end
describe '#alert_management_data' do
let(:alerts_service) do
build_stubbed(:alerts_service,
project: project,
opsgenie_mvc_enabled: false,
opsgenie_mvc_target_url: 'https://appname.app.opsgenie.com/alert/list'
)
end
subject { helper.alert_management_data(current_user, project) }
before do
allow(project).to receive(:alerts_service).and_return(alerts_service)
allow(alerts_service).to receive(:opsgenie_mvc_available?)
.and_return(opsgenie_available)
end
context 'when available' do
let(:opsgenie_available) { true }
it do
is_expected.to include(
'opsgenie_mvc_available' => 'true',
'opsgenie_mvc_enabled' => 'false',
'opsgenie_mvc_target_url' => 'https://appname.app.opsgenie.com/alert/list'
)
end
end
context 'when not available' do
let(:opsgenie_keys) do
%w[opsgenie_mvc_available opsgenie_mvc_enabled opsgenie_mvc_target_url]
end
let(:opsgenie_available) { false }
it { is_expected.not_to include(opsgenie_keys) }
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe AlertsService do
let(:service) { build_stubbed(:alerts_service) }
describe 'Opsgenie MVC' do
describe '#opsgenie_mvc_target_url' do
context 'when enabled' do
before do
service.opsgenie_mvc_enabled = true
end
it 'validates presence' do
expect(service).to validate_presence_of(:opsgenie_mvc_target_url)
end
describe 'enforces public urls' do
where(:url, :valid) do
[
['https://appname.app.opsgenie.com/alert/list', true],
['https://example.com', true],
['http://example.com', true],
['http://0.0.0.0', false],
['http://127.0.0.1', false],
['ftp://example.com', false],
['invalid url', false]
]
end
with_them do
before do
service.opsgenie_mvc_target_url = url
end
if params[:valid]
it { expect(service).to be_valid }
else
it { expect(service).to be_invalid }
end
end
end
end
context 'when disabled' do
before do
service.opsgenie_mvc_enabled = false
end
it 'does not validate presence' do
expect(service).not_to validate_presence_of(:opsgenie_mvc_target_url)
end
it 'allows any value' do
service.opsgenie_mvc_target_url = 'any value'
expect(service).to be_valid
end
end
end
describe '#opsgenie_mvc_available?' do
subject { service.opsgenie_mvc_available? }
before do
stub_licensed_features(opsgenie_integration: true)
end
context 'when license is available' do
it { is_expected.to eq(true) }
end
context 'when license is not available' do
before do
stub_licensed_features(opsgenie_integration: false)
end
it { is_expected.to eq(false) }
end
context 'when template service' do
let(:service) { build_stubbed(:alerts_service, :template) }
it { is_expected.to eq(false) }
end
context 'when instance service' do
let(:service) { build_stubbed(:alerts_service, :instance) }
it { is_expected.to eq(false) }
end
end
end
end
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