diff --git a/app/controllers/health/health_controller.rb b/app/controllers/health/health_controller.rb index 99927729aca..457bc7e05a2 100644 --- a/app/controllers/health/health_controller.rb +++ b/app/controllers/health/health_controller.rb @@ -5,7 +5,6 @@ class HealthController < AbstractHealthController def health_checker checkers = { database: DatabaseHealthChecker, - account_reset: AccountResetHealthChecker, } MultiHealthChecker.new(**checkers) end diff --git a/app/services/account_reset_health_checker.rb b/app/services/account_reset_health_checker.rb deleted file mode 100644 index b0acb37362c..00000000000 --- a/app/services/account_reset_health_checker.rb +++ /dev/null @@ -1,29 +0,0 @@ -module AccountResetHealthChecker - module_function - - # @return [HealthCheckSummary] - def check - unserviced_request_exists = request_not_serviced_within_wait_period_plus_2_hours? - HealthCheckSummary.new(healthy: !unserviced_request_exists, result: unserviced_request_exists) - end - - # @api private - def request_not_serviced_within_wait_period_plus_2_hours? - AccountResetRequest.exists?( - [ - sql, - tvalue: Time.zone.now - IdentityConfig.store.account_reset_wait_period_days.days - 2.hours, - ], - ) - end - - def sql - <<~SQL - cancelled_at IS NULL AND - granted_at IS NULL AND - requested_at < :tvalue AND - request_token IS NOT NULL AND - granted_token IS NULL - SQL - end -end diff --git a/spec/controllers/health/health_controller_spec.rb b/spec/controllers/health/health_controller_spec.rb index c15bf85e7d1..8363c12ae6f 100644 --- a/spec/controllers/health/health_controller_spec.rb +++ b/spec/controllers/health/health_controller_spec.rb @@ -5,8 +5,6 @@ context 'when all checked resources are healthy' do it 'returns a successful JSON response' do allow(DatabaseHealthChecker).to receive(:simple_query).and_return('foo') - allow(AccountResetHealthChecker).to receive(:check). - and_return(HealthCheckSummary.new(healthy: true, result: 'foo')) get :index json = JSON.parse(response.body, symbolize_names: true) @@ -14,7 +12,6 @@ expect(response.status).to eq(200) expect(json[:healthy]).to eq(true) expect(json[:statuses][:database][:healthy]).to eq(true) - expect(json[:statuses][:account_reset][:healthy]).to eq(true) end end @@ -22,8 +19,6 @@ it 'returns an unsuccessful JSON response' do allow(DatabaseHealthChecker).to receive(:simple_query). and_raise(RuntimeError.new('canceling statement due to statement timeout')) - allow(AccountResetHealthChecker).to receive(:check). - and_return(HealthCheckSummary.new(healthy: true, result: 'foo')) get :index json = JSON.parse(response.body, symbolize_names: true) @@ -31,7 +26,6 @@ expect(json[:healthy]).to eq(false) expect(json[:statuses][:database][:result]). to include('canceling statement due to statement timeout') - expect(json[:statuses][:account_reset][:healthy]).to eq(true) expect(response.status).to eq(500) end end @@ -40,8 +34,6 @@ it 'returns an unsuccessful JSON response' do allow(DatabaseHealthChecker).to receive(:simple_query). and_raise(RuntimeError.new('canceling statement due to statement timeout')) - allow(AccountResetHealthChecker).to receive(:check). - and_return(HealthCheckSummary.new(healthy: false, result: 'foo')) get :index json = JSON.parse(response.body, symbolize_names: true) @@ -49,7 +41,6 @@ expect(json[:healthy]).to eq(false) expect(json[:statuses][:database][:result]). to include('canceling statement due to statement timeout') - expect(json[:statuses][:account_reset][:healthy]).to eq(false) expect(response.status).to eq(500) end end diff --git a/spec/services/account_reset_health_checker_spec.rb b/spec/services/account_reset_health_checker_spec.rb deleted file mode 100644 index c2a6ccf47f2..00000000000 --- a/spec/services/account_reset_health_checker_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'rails_helper' - -RSpec.describe AccountResetHealthChecker do - let(:wait_period) { IdentityConfig.store.account_reset_wait_period_days.days } - let(:buffer_period) { 2.hours } # window buffer to allow servicing requests after 24 hours - describe '.check' do - subject(:summary) { AccountResetHealthChecker.check } - - context 'when there are no requests' do - it 'returns a healthy check' do - expect(summary.result).to eq(false) - expect(summary.healthy).to eq(true) - end - end - - context 'when a request is not serviced on time' do - before do - AccountResetRequest.create( - id: 1, - user_id: 2, - requested_at: Time.zone.now - wait_period - buffer_period, - request_token: 'foo', - ) - end - - it 'returns an unhealthy check' do - expect(summary.healthy).to eq(false) - end - end - - context 'when an old request was cancelled' do - before do - AccountResetRequest.create( - id: 1, - user_id: 2, - requested_at: Time.zone.now - wait_period - buffer_period, - request_token: 'foo', - cancelled_at: Time.zone.now, - ) - end - - it 'returns an unhealthy check' do - expect(summary.healthy).to eq(true) - end - end - - context 'when all requests are serviced on time' do - before do - AccountResetRequest.create( - id: 1, - user_id: 2, - requested_at: Time.zone.now - wait_period - buffer_period, - request_token: 'foo', - granted_at: Time.zone.now - buffer_period, - granted_token: 'bar', - ) - end - - it 'returns a healthy check' do - expect(summary.healthy).to eq(true) - end - end - end -end