diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb index aacd9d463e9..584b460d783 100644 --- a/app/mailers/report_mailer.rb +++ b/app/mailers/report_mailer.rb @@ -16,9 +16,4 @@ def system_demand_report(email:, data:, name:) attachments['system_demand.csv'] = data mail(to: email, subject: t('report_mailer.system_demand_report.subject')) end - - def warn_error(email:, error:, env: Rails.env) - @error = error - mail(to: email, subject: "[#{env}] identity-idp error: #{error.class.name}") - end end diff --git a/app/services/service_provider_seeder.rb b/app/services/service_provider_seeder.rb index cfe816c2732..fee5f47d928 100644 --- a/app/services/service_provider_seeder.rb +++ b/app/services/service_provider_seeder.rb @@ -80,12 +80,6 @@ def check_for_missing_sps extra_sp_error = ExtraServiceProviderError.new( "Extra service providers found in DB: #{extra_sps.join(', ')}", ) - - if IdentityConfig.store.team_ursula_email.present? - ReportMailer.warn_error( - email: IdentityConfig.store.team_ursula_email, - error: extra_sp_error, - ).deliver_now_or_later - end + NewRelic::Agent.notice_error(extra_sp_error) end end diff --git a/app/views/report_mailer/warn_error.text.erb b/app/views/report_mailer/warn_error.text.erb deleted file mode 100644 index d114ae14356..00000000000 --- a/app/views/report_mailer/warn_error.text.erb +++ /dev/null @@ -1,5 +0,0 @@ -**Error**: -<%= @error.class.name %> - -**Message**: -<%= @error.message %> diff --git a/config/application.yml.default b/config/application.yml.default index 025c1908025..2497649d566 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -324,7 +324,6 @@ sp_handoff_bounce_max_seconds: 2 show_user_attribute_deprecation_warnings: false otp_min_attempts_remaining_warning_count: 3 system_demand_report_email: 'foo@bar.com' -team_ursula_email: '' test_ssn_allowed_list: '' totp_code_interval: 30 unauthorized_scope_enabled: false diff --git a/lib/identity_config.rb b/lib/identity_config.rb index ec969489b49..239a5960f2b 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -428,7 +428,6 @@ def self.build_store(config_map) config.add(:sp_handoff_bounce_max_seconds, type: :integer) config.add(:state_tracking_enabled, type: :boolean) config.add(:system_demand_report_email, type: :string) - config.add(:team_ursula_email, type: :string) config.add(:telephony_adapter, type: :string) config.add(:test_ssn_allowed_list, type: :comma_separated_string_list) config.add(:totp_code_interval, type: :integer) diff --git a/spec/mailers/previews/report_mailer_preview.rb b/spec/mailers/previews/report_mailer_preview.rb deleted file mode 100644 index f3c71460244..00000000000 --- a/spec/mailers/previews/report_mailer_preview.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ReportMailerPreview < ActionMailer::Preview - def warn_error - ReportMailer.warn_error( - email: 'test@example.com', - error: ServiceProviderSeeder::ExtraServiceProviderError.new( - 'Extra service providers found in DB: a, b, c', - ), - ) - end -end diff --git a/spec/mailers/previews/report_mailer_preview_spec.rb b/spec/mailers/previews/report_mailer_preview_spec.rb deleted file mode 100644 index fb1fc38697f..00000000000 --- a/spec/mailers/previews/report_mailer_preview_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'rails_helper' -require_relative './report_mailer_preview' - -RSpec.describe ReportMailerPreview do - subject(:mailer_preview) { ReportMailerPreview.new } - - describe '#warn_error' do - it 'generates a warn_error email' do - expect { mailer_preview.warn_error }.to_not raise_error - end - end -end diff --git a/spec/mailers/report_mailer_spec.rb b/spec/mailers/report_mailer_spec.rb index 9a7f076c638..51710c91bcb 100644 --- a/spec/mailers/report_mailer_spec.rb +++ b/spec/mailers/report_mailer_spec.rb @@ -4,7 +4,7 @@ let(:user) { build(:user) } let(:email_address) { user.email_addresses.first } - describe '#deleted_user_accounts_report' do + describe 'deleted_user_accounts_report' do let(:mail) do ReportMailer.deleted_user_accounts_report( email: email_address.email, @@ -30,26 +30,4 @@ expect(mail.html_part.body).to have_content('issuer2') end end - - describe '#warn_error' do - let(:error) { RuntimeError.new('this is my test message') } - let(:env) { ActiveSupport::StringInquirer.new('prod') } - - let(:mail) do - ReportMailer.warn_error( - email: 'test@example.com', - error: error, - env: env, - ) - end - - it 'puts the rails env and error in a plaintext email', aggregate_failures: true do - expect(mail.html_part).to be_nil - - expect(mail.subject).to include('prod') - expect(mail.subject).to include('RuntimeError') - - expect(mail.text_part.body).to include('this is my test') - end - end end diff --git a/spec/services/service_provider_seeder_spec.rb b/spec/services/service_provider_seeder_spec.rb index 3151b056fd9..ab1e7852f16 100644 --- a/spec/services/service_provider_seeder_spec.rb +++ b/spec/services/service_provider_seeder_spec.rb @@ -83,10 +83,6 @@ let(:prod_issuer) { 'urn:gov:login:test-providers:fake-prod-sp' } let(:unrestricted_issuer) { 'urn:gov:login:test-providers:fake-unrestricted-sp' } - before do - allow(IdentityConfig.store).to receive(:team_ursula_email).and_return('team@example.com') - end - context 'when %{env} is present in the config file' do let(:deploy_env) { 'dev' } @@ -110,10 +106,12 @@ expect(ServiceProvider.find_by(issuer: unrestricted_issuer)).not_to be_present end - it 'sends an email an error if the DB has an SP not in the config' do + it 'sends New Relic an error if the DB has an SP not in the config' do + allow(NewRelic::Agent).to receive(:notice_error) create(:service_provider, issuer: 'missing_issuer') + run - expect { run }.to change { ActionMailer::Base.deliveries.count }.by(1) + expect(NewRelic::Agent).to have_received(:notice_error) end end @@ -130,9 +128,11 @@ end it 'sends New Relic an error if the DB has an SP not in the config' do + allow(NewRelic::Agent).to receive(:notice_error) create(:service_provider, issuer: 'missing_issuer') + run - expect { run }.to change { ActionMailer::Base.deliveries.count }.by(1) + expect(NewRelic::Agent).to have_received(:notice_error) end end