From c0dac15412ad2dd62a0fa7a72d9506fbcd6fa375 Mon Sep 17 00:00:00 2001 From: Nathan Burgess Date: Mon, 25 Mar 2024 16:53:44 -0400 Subject: [PATCH] Complete e2e testing and debugging Adds live VCR tests with the status polling endpoint using documents provided by Lighthouse in their QA environment. Makes necessary changes across service components and in tests to reflect bugs that were found when testing with the actual endpoint --- .../form_526_document_upload_polling_job.rb | 10 +- .../benefits_documents/configuration.rb | 23 +- .../update_documents_status_service.rb | 2 +- .../form526/upload_status_updater.rb | 13 +- .../update_documents_status_service_spec.rb | 22 +- .../form526/upload_status_updater_spec.rb | 64 +++-- .../lighthouse526_document_upload_spec.rb | 49 ++-- ...orm526_document_upload_polling_job_spec.rb | 221 +++++++++--------- ...rm_526_document_upload_status_complete.yml | 58 +++-- ...form_526_document_upload_status_failed.yml | 55 +++-- 10 files changed, 289 insertions(+), 228 deletions(-) diff --git a/app/sidekiq/lighthouse/form_526_document_upload_polling_job.rb b/app/sidekiq/lighthouse/form_526_document_upload_polling_job.rb index a8ce86a6a4e..5419edd2582 100644 --- a/app/sidekiq/lighthouse/form_526_document_upload_polling_job.rb +++ b/app/sidekiq/lighthouse/form_526_document_upload_polling_job.rb @@ -36,16 +36,8 @@ def perform ) do |document_batch| lighthouse_document_request_ids = document_batch.pluck(:lighthouse_document_request_id) response = BenefitsDocuments::Form526::DocumentsStatusPollingService.call(lighthouse_document_request_ids) - # TODO: CATCH POLLING SERVICE TIMEOUT AND FAILURE RESPONSES - # TODO: RESOLVING ISSUES WITH QA ENDPOINT WITH LIGHTHOUSE, - # NEED TO ADDRESS BEFORE WE CAN RECORD VCR CASSETES FOR THESE TESTS, - # CALLER MAY BE DIFFERENT HERE - BenefitsDocuments::Form526::UpdateDocumentsStatusService.call(document_batch, response) - - document_batch.update_all( - status_last_polled_at: DateTime.now - ) + BenefitsDocuments::Form526::UpdateDocumentsStatusService.call(document_batch, response.body) end end end diff --git a/lib/lighthouse/benefits_documents/configuration.rb b/lib/lighthouse/benefits_documents/configuration.rb index 7970e574119..1301fc86941 100644 --- a/lib/lighthouse/benefits_documents/configuration.rb +++ b/lib/lighthouse/benefits_documents/configuration.rb @@ -18,6 +18,7 @@ class Configuration < Common::Client::Configuration::REST DOCUMENTS_PATH = 'services/benefits-documents/v1/documents' DOCUMENTS_STATUS_PATH = 'services/benefits-documents/v1/uploads/status' TOKEN_PATH = 'oauth2/benefits-documents/system/v1/token' + QA_TESTING_DOMAIN = 'https://dev-api.va.gov' ## # @return [Config::Options] Settings for benefits_claims API. @@ -96,8 +97,10 @@ def generate_upload_body(document_data, file_body) end def get_documents_status(lighthouse_document_request_ids) - headers = { 'Authorization' => "Bearer #{access_token}", - 'Content-Type' => 'Content-Type: application/json' } + headers = { + 'Authorization' => "Bearer #{documents_status_access_token}", + 'Content-Type' => 'application/json', + } body = { data: { @@ -105,7 +108,17 @@ def get_documents_status(lighthouse_document_request_ids) } }.to_json - connection.post(DOCUMENTS_STATUS_PATH, body, headers) + document_status_api_connection.post(DOCUMENTS_STATUS_PATH, body, headers) + end + + def documents_status_access_token + # Lighthouse is having us test the documents status endpoint on the QA testing domain + ENV['RAILS_ENV'] == 'test' ? access_token(nil, nil, { host: QA_TESTING_DOMAIN }) : access_token + end + + def document_status_api_connection + # Lighthouse is having us test the documents status endpoint on the QA testing domain + ENV['RAILS_ENV'] == 'test' ? connection(QA_TESTING_DOMAIN) : connection end ## @@ -113,8 +126,8 @@ def get_documents_status(lighthouse_document_request_ids) # # @return [Faraday::Connection] a Faraday connection instance. # - def connection - @conn ||= Faraday.new(base_api_path, headers: base_request_headers, request: request_options) do |faraday| + def connection(api_path = base_api_path) + @conn ||= Faraday.new(api_path, headers: base_request_headers, request: request_options) do |faraday| faraday.use :breakers faraday.use Faraday::Response::RaiseError diff --git a/lib/lighthouse/benefits_documents/form526/update_documents_status_service.rb b/lib/lighthouse/benefits_documents/form526/update_documents_status_service.rb index 24a695a3921..b4828e927b6 100644 --- a/lib/lighthouse/benefits_documents/form526/update_documents_status_service.rb +++ b/lib/lighthouse/benefits_documents/form526/update_documents_status_service.rb @@ -54,7 +54,7 @@ def call private def update_documents_status - JSON.parse(@lighthouse_status_response).dig('data', 'statuses').each do |document_progress| + @lighthouse_status_response.dig('data', 'statuses').each do |document_progress| update_document_status(document_progress) end end diff --git a/lib/lighthouse/benefits_documents/form526/upload_status_updater.rb b/lib/lighthouse/benefits_documents/form526/upload_status_updater.rb index 847b36db535..8d08c85a0d6 100644 --- a/lib/lighthouse/benefits_documents/form526/upload_status_updater.rb +++ b/lib/lighthouse/benefits_documents/form526/upload_status_updater.rb @@ -72,7 +72,7 @@ def update_status 'BenefitsDocuments::Form526::UploadStatusUpdater', status: @lighthouse526_document_status['status'], status_response: @lighthouse526_document_status, - updated_at: DateTime.now + updated_at: DateTime.now.utc ) if completed? || failed? @@ -85,6 +85,8 @@ def update_status @lighthouse526_document_upload.fail! end end + + @lighthouse526_document_upload.update!(status_last_polled_at: DateTime.now.utc) end def get_failure_step @@ -98,7 +100,7 @@ def get_failure_step def processing_timeout? return false if @lighthouse526_document_status.dig('time', 'endTime') - start_time < PROCESSING_TIMEOUT_WINDOW_IN_HOURS.hours.ago + start_time < PROCESSING_TIMEOUT_WINDOW_IN_HOURS.hours.ago.utc end private @@ -107,16 +109,15 @@ def status_changed? @lighthouse526_document_status != @lighthouse526_document_upload.last_status_response end + # Lighthouse returns date times as UNIX timestamps in milliseconds def start_time - # Lighthouse returns date times as UNIX timestamps unix_start_time = @lighthouse526_document_status.dig('time', 'startTime') - DateTime.strptime(unix_start_time, '%s') + Time.at(unix_start_time).utc.to_datetime end def end_time - # Lighthouse returns date times as UNIX timestamps unix_end_time = @lighthouse526_document_status.dig('time', 'endTime') - DateTime.strptime(unix_end_time, '%s') + Time.at(unix_end_time).utc.to_datetime end def failed? diff --git a/spec/lib/lighthouse/benefits_documents/form526/update_documents_status_service_spec.rb b/spec/lib/lighthouse/benefits_documents/form526/update_documents_status_service_spec.rb index cfe32439fd6..a46007d28d8 100644 --- a/spec/lib/lighthouse/benefits_documents/form526/update_documents_status_service_spec.rb +++ b/spec/lib/lighthouse/benefits_documents/form526/update_documents_status_service_spec.rb @@ -19,8 +19,8 @@ 'requestId' => pending_document_upload.lighthouse_document_request_id, 'status' => 'SUCCESS', 'time' => { - 'startTime' => '499152030', - 'endTime' => '499152060' + 'startTime' => 499152030, + 'endTime' => 499152060 }, 'steps' => [ { @@ -35,7 +35,7 @@ } ] } - }.to_json + } end it 'transitions that document to the complete state' do @@ -62,8 +62,8 @@ 'requestId' => pending_document_upload.lighthouse_document_request_id, 'status' => 'FAILED', 'time' => { - 'startTime' => '499152030', - 'endTime' => '499152060' + 'startTime' => 499152030, + 'endTime' => 499152060 }, 'steps' => [ { @@ -82,7 +82,7 @@ } ] } - }.to_json + } end it 'transitions the document to the failed state' do @@ -110,7 +110,7 @@ 'requestId' => pending_document_upload.lighthouse_document_request_id, 'status' => 'IN_PROGRESS', 'time' => { - 'startTime' => lighthouse_processing_start_time.to_time.to_i.to_s, + 'startTime' => lighthouse_processing_start_time.to_time.to_i, 'endTime' => nil }, 'steps' => [ @@ -126,7 +126,7 @@ } ] } - }.to_json + } end context 'when it has been more than 24 hours since Lighthouse started processing the document' do @@ -164,13 +164,13 @@ def mock_success_response(request_id) 'requestId' => request_id, 'status' => 'SUCCESS', 'time' => { - 'startTime' => '499152030', - 'endTime' => '499152060' + 'startTime' => 499152030, + 'endTime' => 499152060 } } ] } - }.to_json + } end before do diff --git a/spec/lib/lighthouse/benefits_documents/form526/upload_status_updater_spec.rb b/spec/lib/lighthouse/benefits_documents/form526/upload_status_updater_spec.rb index 31b7ac00da6..a1badac98f9 100644 --- a/spec/lib/lighthouse/benefits_documents/form526/upload_status_updater_spec.rb +++ b/spec/lib/lighthouse/benefits_documents/form526/upload_status_updater_spec.rb @@ -13,15 +13,15 @@ context 'when the document is completed' do # Lighthouse returns datetimes as UNIX timestamps - let(:start_time) { '499152060' } - let(:end_time) { '499153000' } + let(:unix_start_time) { 499152060 } + let(:unix_end_time) { 499153000 } let(:completed_document_status) do { 'status' => 'SUCCESS', 'time' => { - 'startTime' => start_time, - 'endTime' => end_time + 'startTime' => unix_start_time, + 'endTime' => unix_end_time }, 'steps' => [ { @@ -41,7 +41,7 @@ expect { status_updater.update_status }.to change( lighthouse526_document_upload, :lighthouse_processing_started_at - ).to(DateTime.strptime(start_time, '%s')) + ).to(Time.at(unix_start_time).utc.to_datetime) end it 'saves a lighthouse_processing_ended_at time' do @@ -49,7 +49,7 @@ expect { status_updater.update_status }.to change( lighthouse526_document_upload, :lighthouse_processing_ended_at - ).to(DateTime.strptime(end_time, '%s')) + ).to(Time.at(unix_end_time).utc.to_datetime) end it 'transitions the document to a complete state' do @@ -79,19 +79,28 @@ status_updater.update_status end end + + it 'updates the status_last_polled_at time on the document' do + Timecop.freeze(DateTime.new(1985, 10, 26)) do + status_updater = described_class.new(completed_document_status, lighthouse526_document_upload) + status_updater.update_status + + expect(lighthouse526_document_upload.status_last_polled_at).to eq(DateTime.new(1985, 10, 26)) + end + end end context 'when the document has failed' do # Lighthouse returns datetimes as UNIX timestamps - let(:start_time) { '499152060' } - let(:end_time) { '499153000' } + let(:unix_start_time) { 499152060 } + let(:unix_end_time) { 499153000 } let(:failed_document_status) do { 'status' => 'FAILED', 'time' => { - 'startTime' => start_time, - 'endTime' => end_time + 'startTime' => unix_start_time, + 'endTime' => unix_end_time }, 'steps' => [ { @@ -115,7 +124,7 @@ expect { status_updater.update_status }.to change( lighthouse526_document_upload, :lighthouse_processing_started_at - ).to(DateTime.strptime(start_time, '%s')) + ).to(Time.at(unix_start_time).utc.to_datetime) end it 'saves a lighthouse_processing_ended_at time' do @@ -123,7 +132,7 @@ expect { status_updater.update_status }.to change( lighthouse526_document_upload, :lighthouse_processing_ended_at - ).to(DateTime.strptime(end_time, '%s')) + ).to(Time.at(unix_end_time).utc.to_datetime) end it 'transitions the document to a failed state' do @@ -165,6 +174,15 @@ status_updater.update_status end end + + it 'updates the status_last_polled_at time on the document' do + Timecop.freeze(DateTime.new(1985, 10, 26)) do + status_updater = described_class.new(failed_document_status, lighthouse526_document_upload) + status_updater.update_status + + expect(lighthouse526_document_upload.status_last_polled_at).to eq(DateTime.new(1985, 10, 26)) + end + end end context 'when the document is in progress' do @@ -177,13 +195,13 @@ end # Lighthouse returns datetimes as UNIX timestamps - let(:start_time) { '499152060' } + let(:unix_start_time) { 499152060 } let(:in_progress_document_status) do { 'status' => 'IN_PROGRESS', 'time' => { - 'startTime' => start_time, + 'startTime' => unix_start_time, 'endTime' => nil }, 'steps' => [ @@ -212,7 +230,7 @@ expect { status_updater.update_status }.to change( lighthouse526_new_document_upload, :lighthouse_processing_started_at - ).to(DateTime.strptime(start_time, '%s')) + ).to(Time.at(unix_start_time).utc.to_datetime) end it 'saves the last_status_response' do @@ -243,8 +261,8 @@ { 'status' => 'FAILED', 'time' => { - 'startTime' => '499152060', - 'endTime' => '499153000' + 'startTime' => 499152060, + 'endTime' => 499153000 }, 'steps' => [ { @@ -272,14 +290,14 @@ describe '#processing_timeout?' do context 'when the document has been in progress for more than 24 hours' do it 'returns true' do - Timecop.freeze(DateTime.new(1985, 10, 26)) do + Timecop.freeze(DateTime.new(1985, 10, 26).utc) do # Lighthouse returns datetimes as UNIX timestamps - start_time = DateTime.new(1985, 10, 23).to_time.to_i.to_s + unix_start_time = DateTime.new(1985, 10, 23).to_time.to_i delayed_document_status = { 'status' => 'IN_PROGRESS', 'time' => { - 'startTime' => start_time, + 'startTime' => unix_start_time, 'endTime' => nil }, 'steps' => [ @@ -302,14 +320,14 @@ context 'when the document has been in progress for less than 24 hours' do it 'returns false' do - Timecop.freeze(DateTime.new(1985, 10, 26)) do + Timecop.freeze(DateTime.new(1985, 10, 26).utc) do # Lighthouse returns datetimes as UNIX timestamps - start_time = DateTime.new(1985, 10, 25, 20).to_time.to_i.to_s + unix_start_time = DateTime.new(1985, 10, 25, 20).utc.to_time.to_i in_progress_document_status = { 'status' => 'IN_PROGRESS', 'time' => { - 'startTime' => start_time, + 'startTime' => unix_start_time, 'endTime' => nil }, 'steps' => [ diff --git a/spec/models/lighthouse526_document_upload_spec.rb b/spec/models/lighthouse526_document_upload_spec.rb index 1c6efc1ba0a..4650b8531b3 100644 --- a/spec/models/lighthouse526_document_upload_spec.rb +++ b/spec/models/lighthouse526_document_upload_spec.rb @@ -7,26 +7,26 @@ # https://dev-developer.va.gov/explore/api/benefits-documents/docs?version=current let(:lighthouse_status_response) do { - data: { - statuses: [ + 'data' => { + 'statuses' => [ { - requestId: '600000001', - time: { - startTime: '1502199000', - endTime: '1502199000' + 'requestId' => 600000001, + 'time' => { + 'startTime' => 1502199000, + 'endTime' => nil }, - status: 'IN_PROGRESS', - steps: [ + 'status' => 'IN_PROGRESS', + 'steps' => [ { - name: 'BENEFITS_GATEWAY_SERVICE', - nextStepName: 'BENEFITS_GATEWAY_SERVICE', - description: 'string', - status: 'NOT_STARTED' + 'name' => 'BENEFITS_GATEWAY_SERVICE', + 'nextStepName' => 'BENEFITS_GATEWAY_SERVICE', + 'description' => 'string', + 'status' => 'NOT_STARTED' } ], - error: { - detail: 'string', - step: 'BENEFITS_GATEWAY_SERVICE' + 'error' => { + 'detail' => 'string', + 'step' => 'BENEFITS_GATEWAY_SERVICE' } } ] @@ -80,15 +80,21 @@ end describe 'state transtions' do - let(:lighthouse526_document_upload) { create(:lighthouse526_document_upload) } + # Both completed and failed uploads have an end time in Lighthouse + let(:finished_lighthouse526_document_upload) do + create( + :lighthouse526_document_upload, + lighthouse_processing_ended_at: DateTime.now + ) + end it 'transitions to a completed state' do - expect(lighthouse526_document_upload) + expect(finished_lighthouse526_document_upload) .to transition_from(:pending).to(:completed).on_event(:complete!) end it 'transitions to a failed state' do - expect(lighthouse526_document_upload) + expect(finished_lighthouse526_document_upload) .to transition_from(:pending).to(:failed).on_event(:fail!) end @@ -117,7 +123,12 @@ end it 'transitions if an error message is saved' do - upload = create(:lighthouse526_document_upload, error_message: {status: 'Something broke'}.to_json) + upload = create( + :lighthouse526_document_upload, + lighthouse_processing_ended_at: DateTime.now, + error_message: { status: 'Something broke' }.to_json + ) + expect { upload.fail! }.not_to raise_error(AASM::InvalidTransition) end diff --git a/spec/sidekiq/lighthouse/form526_document_upload_polling_job_spec.rb b/spec/sidekiq/lighthouse/form526_document_upload_polling_job_spec.rb index 54ef529aeec..c8f83eb8af4 100644 --- a/spec/sidekiq/lighthouse/form526_document_upload_polling_job_spec.rb +++ b/spec/sidekiq/lighthouse/form526_document_upload_polling_job_spec.rb @@ -19,110 +19,110 @@ end describe '#perform' do - # TODO: RESOLVING ISSUES WITH QA ENDPOINT WITH LIGHTHOUSE, - # NEED TO ADDRESS BEFORE WE CAN RECORD VCR CASSETES FOR THESE TESTS - # End-to-end integration test - completion - # context 'for a document that has completed' do - # around do |example| - # VCR.use_cassette('lighthouse/benefits_claims/documents/form_526_document_upload_status_complete') do - # example.run - # end - # end - - # let!(:lighthouse_complete_document) do - # create( - # :lighthouse526_document_upload, - # document_type: 'Veteran Upload', - # aasm_state: 'pending', - # # Completed Lighthouse QA environment document requestId provided to us by Lighthouse for end-to-end testing - # lighthouse_document_request_id: '18559', - # lighthouse_processing_ended_at: nil, - # last_status_response: nil, - # status_last_polled_at: nil - # ) - # end - - # it 'marks the document as completed' do - # expect { described_class.new.perform }.to change(lighthouse_complete_document, :aasm_state).to('completed') - # end - - # it 'increments a StatsD completion counter for the document type' do - # expect { described_class.new.perform }.to trigger_statsd_increment( - # 'api.form_526.lighthouse_document_upload_processing_status.veteran_upload.complete' - # ) - # end - - # it 'updates the completion time on the document' do - # described_class.new.perform - # expect(lighthouse_complete_document.lighthouse_processing_ended_at).not_to be_nil - # end - - # it 'saves the last_status_response' do - # described_class.new.perform - # expect(lighthouse_complete_document.last_status_response).not_to be_nil - # end - - # it 'saves the status_last_polled_at time' do - # polling_time = DateTime.new(1985, 10, 26).utc - - # Timecop.freeze(polling_time) do - # described_class.new.perform - # expect(lighthouse_complete_document.status_last_polled_at).to eq(polling_time) - # end - # end - # end - - # context 'for a document that has failed' do - # let!(:lighthouse_failed_document) do - # create( - # :lighthouse526_document_upload, - # document_type: 'Veteran Upload', - # aasm_state: 'pending', - # # Failed Lighthouse QA environment document requestId provided to us by Lighthouse for end-to-end testing - # lighthouse_document_request_id: '16819', - # lighthouse_processing_ended_at: nil, - # last_status_response: nil, - # status_last_polled_at: nil - # ) - # end - - # around do |example| - # VCR.use_cassette('lighthouse/benefits_claims/documents/form_526_document_upload_status_failed') do - # example.run - # end - # end - - # it 'marks the document as failed' do - # expect { described_class.new.perform }.to change(lighthouse_failed_document, :aasm_state).to('failed') - # end - - # it 'increments a StatsD completion counter for the document type' do - # # TODO: STATUS KEY MUST MATCH STEP THAT FAILED IN LIGHTHOUSE; NEED TO GET ENDPOINT WORKING FIRST - # expect { described_class.new.perform }.to trigger_statsd_increment( - # 'api.form_526.lighthouse_document_upload_processing_status.veteran_upload.failed.' - # ) - # end - - # it 'updates the completion time on the document' do - # described_class.new.perform - # expect(lighthouse_failed_document.lighthouse_processing_ended_at).not_to be_nil - # end - - # it 'saves the last_status_response' do - # described_class.new.perform - # expect(lighthouse_failed_document.last_status_response).not_to be_nil - # end - - # it 'saves the status_last_polled_at time' do - # polling_time = DateTime.new(1985, 10, 26).utc - - # Timecop.freeze(polling_time) do - # described_class.new.perform - # expect(lighthouse_failed_document.status_last_polled_at).to eq(polling_time) - # end - # end - # end + context 'for a document that has completed' do + around do |example| + VCR.use_cassette('lighthouse/benefits_claims/documents/form_526_document_upload_status_complete') do + example.run + end + end + + let!(:lighthouse_complete_document) do + create( + :lighthouse526_document_upload, + document_type: 'Veteran Upload', + aasm_state: 'pending', + # Completed Lighthouse QA environment document requestId provided to us by Lighthouse for end-to-end testing + lighthouse_document_request_id: '18559', + lighthouse_processing_ended_at: nil, + last_status_response: nil, + status_last_polled_at: nil + ) + end + + it 'marks the document as completed' do + described_class.new.perform + expect(lighthouse_complete_document.reload.aasm_state).to eq('completed') + end + + it 'increments a StatsD completion counter for the document type' do + expect { described_class.new.perform }.to trigger_statsd_increment( + 'api.form_526.lighthouse_document_upload_processing_status.veteran_upload.complete' + ) + end + + it 'updates the completion time on the document' do + described_class.new.perform + expect(lighthouse_complete_document.reload.lighthouse_processing_ended_at).not_to be_nil + end + + it 'saves the last_status_response' do + described_class.new.perform + expect(lighthouse_complete_document.reload.last_status_response).not_to be_nil + end + + it 'saves the status_last_polled_at time' do + polling_time = DateTime.new(1985, 10, 26).utc + + Timecop.freeze(polling_time) do + described_class.new.perform + expect(lighthouse_complete_document.reload.status_last_polled_at).to eq(polling_time) + end + end + end + + context 'for a document that has failed' do + let!(:lighthouse_failed_document) do + create( + :lighthouse526_document_upload, + document_type: 'Veteran Upload', + aasm_state: 'pending', + # Failed Lighthouse QA environment document requestId provided to us by Lighthouse for end-to-end testing + lighthouse_document_request_id: '16819', + lighthouse_processing_ended_at: nil, + last_status_response: nil, + status_last_polled_at: nil + ) + end + + around do |example| + VCR.use_cassette('lighthouse/benefits_claims/documents/form_526_document_upload_status_failed') do + example.run + end + end + + it 'marks the document as failed' do + described_class.new.perform + expect(lighthouse_failed_document.reload.aasm_state).to eq('failed') + end + + it 'increments a StatsD completion counter for the document type' do + expect { described_class.new.perform }.to trigger_statsd_increment( + # NOTE: end of key should be .claims_evidence because 16819 failed document + # provided by Lighthouse failed on that step + 'api.form_526.lighthouse_document_upload_processing_status.veteran_upload.failed.claims_evidence' + ) + end + + it 'updates the completion time on the document' do + described_class.new.perform + expect(lighthouse_failed_document.reload.lighthouse_processing_ended_at).not_to be_nil + end + + it 'saves the last_status_response' do + described_class.new.perform + expect(lighthouse_failed_document.reload.last_status_response).not_to be_nil + end + + it 'saves the status_last_polled_at time' do + polling_time = DateTime.new(1985, 10, 26).utc + + Timecop.freeze(polling_time) do + described_class.new.perform + expect(lighthouse_failed_document.reload.status_last_polled_at).to eq(polling_time) + end + end + end context 'retries exhausted' do it 'updates the exhaustion StatsD counter' do @@ -157,9 +157,12 @@ end describe 'Documents Polling' do + let(:faraday_response) { instance_double(Faraday::Response) } + before do + allow(faraday_response).to receive(:body).and_return({}) # We aren't stressing either of these services, just verifying we pass the right info to them - allow(BenefitsDocuments::Form526::DocumentsStatusPollingService).to receive(:call) + allow(BenefitsDocuments::Form526::DocumentsStatusPollingService).to receive(:call).and_return(faraday_response) allow(BenefitsDocuments::Form526::UpdateDocumentsStatusService).to receive(:call) end @@ -188,11 +191,6 @@ described_class.new.perform end - - it 'updates the status_last_polled_at time on the document' do - described_class.new.perform - expect(unpolled_document.reload.status_last_polled_at).to eq(polling_time) - end end context 'For a document that has not been polled in the last 24 hours' do @@ -211,11 +209,6 @@ described_class.new.perform end - - it 'updates the status_last_polled_at time on the document' do - described_class.new.perform - expect(pending_repoll_document.reload.status_last_polled_at).to eq(polling_time) - end end context 'for a document that has been polled in the last 24 hours' do diff --git a/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_complete.yml b/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_complete.yml index cbdf1a44b15..776c3dddaf2 100644 --- a/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_complete.yml +++ b/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_complete.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://dev-api.va.gov/oauth2/benefits-documents/system/v1/token body: encoding: US-ASCII - string: grant_type=client_credentials&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInN1YiI6IjBvYXAxOHFvZnVjY2FXUVVSMnA3IiwiYXVkIjoiaHR0cHM6Ly9kZXB0dmEtZXZhbC5va3RhLmNvbS9vYXV0aDIvYXVzaTN1aTgzZkxhNjhJSnYycDcvdjEvdG9rZW4iLCJpYXQiOjE3MTAzNjcwMTMsImV4cCI6MTcxMDM2NzMxM30.X-f3YkYfz0oLGKGly-_HgOTZDivDvjStBlF77zjhonwo9SpSuoojz1BhO0vALmyR5rwdWX31bqpcN2xeQrcd40czrhzbp2-Ju-HHoQ6Io8Dw0cP0Uwk6FLP8QqVlex0koXwTFjOX6U9aLbRsznk8Wufe3FBLYYpOhNfqqnLuhA1LEjOQ6f_1xQyUoEWYDZ3WaKvDZNOBzmoqr8gRFobKzX-MFz9SwVqNbqDgudhXRGXF8lWs50wSWHtda4cbWYXEIBy3yUQYxSbAlRrH_-kwGbjkt-dG0jz7UwgFEq2C1g7oxDuvA2UETiGa4dBnH-YuPOWSHvbAHy_MTCjJYN5jdw&scope=documents.read+documents.write + string: grant_type=client_credentials&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInN1YiI6IjBvYXAxOHFvZnVjY2FXUVVSMnA3IiwiYXVkIjoiaHR0cHM6Ly9kZXB0dmEtZXZhbC5va3RhLmNvbS9vYXV0aDIvYXVzaTN1aTgzZkxhNjhJSnYycDcvdjEvdG9rZW4iLCJpYXQiOjE3MTEzOTMwNjIsImV4cCI6MTcxMTM5MzM2Mn0.mTYpXCJqEOmqQ6J-BE25kY_a80_mj-TlXsmyuFk_cDEG4T2__VSOkZ__Z2B_E03Cky42KiZ4fegmEOucq7HPT9FbwODYdWQIXYLYAV8-RdsoZUAIGtPKi3J63_ZfapwS9psh0SpI46Jc9rS4LuV4fSSRtBTHwgTyZBGoqQJN_DMIoVjvmvxruoqLrL_BoacIOfx24i7Ty5AUz1qmuUw2hr3UvFbhhQEgw_RIlQlT0swIPSvOBFOQG8vPq_gjy0d6GfK7MMHsNjt6S0UqMYKj3LRPJorGeYH8nA9Q1uFjaf2L9BWepV1H9qlvTRM2Nluh-Z4zpxdluChvYcw5CUpz_w&scope=documents.read+documents.write headers: Accept: - application/json @@ -21,21 +21,21 @@ http_interactions: message: OK headers: Date: - - Wed, 13 Mar 2024 21:56:54 GMT + - Mon, 25 Mar 2024 18:57:43 GMT Content-Type: - application/json; charset=utf-8 Connection: - keep-alive - Ratelimit-Reset: - - '7' - X-Ratelimit-Limit-Minute: - - '60' X-Ratelimit-Remaining-Minute: - - '59' + - '56' Ratelimit-Limit: - '60' Ratelimit-Remaining: - - '59' + - '56' + Ratelimit-Reset: + - '17' + X-Ratelimit-Limit-Minute: + - '60' Vary: - Origin Cache-Control: @@ -43,19 +43,19 @@ http_interactions: Pragma: - no-cache Etag: - - W/"406-LuO8TljdH/cgynlxi6tMmjUOqJw" + - W/"406-4Qz4UveJtQlT86H1Qda91rrNIXw" Access-Control-Allow-Origin: - "*" Transfer-Encoding: - chunked body: encoding: ASCII-8BIT - string: '{"access_token":"eyJraWQiOiJ5c3RTeC0xTmFRRTY2em5hNGNHb1ptQTVWV3R2TzdkQS11U3ZQV3QzaXFvIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULm8zSWZNRk1uWTBtUC1FTVUzMklwcGtMcFJJQnBQeDJQa0tubEtZcng3c0EiLCJpc3MiOiJodHRwczovL2RlcHR2YS1ldmFsLm9rdGEuY29tL29hdXRoMi9hdXNpM3VpODNmTGE2OElKdjJwNyIsImF1ZCI6Imh0dHBzOi8vc2FuZGJveC1hcGkudmEuZ292L3NlcnZpY2VzL2JlbmVmaXRzLWRvY3VtZW50cyIsImlhdCI6MTcxMDM2NzAxNCwiZXhwIjoxNzEwMzY3NjE0LCJjaWQiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInNjcCI6WyJkb2N1bWVudHMud3JpdGUiLCJkb2N1bWVudHMucmVhZCJdLCJzdWIiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsImxhYmVsIjoiQ29mb3JtYUJ1cmdlc3MtMTY5NTgzMjQ0NyJ9.OCJAx6wbxyY7lcgL9bj1AqIoePACMt762-cXM-Z9aZgm36sp5VS62c-Aqwa7C2WWoUyirQtuMpmsfYmfHFIqVPNF8nprLaKmgAQdFbnn36H0_R15GurnmwyPNNe-Cqatx5nLy-zH-oTyM20HryTH4riTL20kO7t34NLM7Rn6_elXCUapOH3k3Wu5rm_ZoN8_EBuM0YJLSIK8jgYUyeLe3IaG-eJt5U4MGmZnGvSt1EFKDO3sHawowRO_ICD0eiY__Fh8XMXD5gkr1t_56T3VFQHFWMC4snaaNXQEuiP_xSdQ42Dl9hu-JKWzKA37xxuvdmAzOCWA6dcLlxev-579_g","token_type":"Bearer","scope":"documents.write + string: '{"access_token":"eyJraWQiOiJ5c3RTeC0xTmFRRTY2em5hNGNHb1ptQTVWV3R2TzdkQS11U3ZQV3QzaXFvIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULmZGa0RXRG5LbEpHWjVLQmx3TVhoX2VIWWNRQ1A0UnppcTdHZXVOLXFCZ2ciLCJpc3MiOiJodHRwczovL2RlcHR2YS1ldmFsLm9rdGEuY29tL29hdXRoMi9hdXNpM3VpODNmTGE2OElKdjJwNyIsImF1ZCI6Imh0dHBzOi8vc2FuZGJveC1hcGkudmEuZ292L3NlcnZpY2VzL2JlbmVmaXRzLWRvY3VtZW50cyIsImlhdCI6MTcxMTM5MzA2MywiZXhwIjoxNzExMzkzNjYzLCJjaWQiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInNjcCI6WyJkb2N1bWVudHMud3JpdGUiLCJkb2N1bWVudHMucmVhZCJdLCJzdWIiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsImxhYmVsIjoiQ29mb3JtYUJ1cmdlc3MtMTY5NTgzMjQ0NyJ9.lKTMv_JuUFj137vfk0Dy2PsRaknfAa1ZrYjaRTGPpz_HQ1dPF9NJn9bspWLl9aUCtTn6wiqz5el5TItWsk-PifsN2t60bn-vJ3YDUkGCFCkC12hal2OdYbBIJLMvq9-YEGlOw7BRHuqafDB48mq5IUpPxqyzYQep0ZuMc52pL_ihmp4_DtJCNqIA5rHVeLlM7gIJQ7S9xO73BNgRmm9SFCa8CIsABdgZirD4aa7sYjnj012-vbesnQm9FEMFrpRCc86yG6FVc08PLAYlKhXkERpcZoXEWKEVvhYAIij7I7MduCvhsyxo_RpqTIrCiK76Ii0oMqg8oBrqH3SrBgJP6A","token_type":"Bearer","scope":"documents.write documents.read","expires_in":600,"state":null}' - recorded_at: Wed, 13 Mar 2024 21:56:54 GMT + recorded_at: Mon, 25 Mar 2024 18:57:43 GMT - request: method: post - uri: https://dev-api.va.gov/services/benefits-documents/uploads/status + uri: https://dev-api.va.gov/services/benefits-documents/v1/uploads/status body: encoding: UTF-8 string: '{"data":{"requestIds":["18559"]}}' @@ -63,7 +63,7 @@ http_interactions: Accept: - application/json Content-Type: - - 'Content-Type: application/json' + - application/json User-Agent: - Vets.gov Agent Authorization: Bearer @@ -71,27 +71,43 @@ http_interactions: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 response: status: - code: 404 - message: Not Found + code: 200 + message: '' headers: Date: - - Wed, 13 Mar 2024 21:56:54 GMT + - Mon, 25 Mar 2024 18:57:43 GMT Content-Type: - - application/json; charset=utf-8 + - application/json Connection: - keep-alive + X-Ratelimit-Remaining-Minute: + - '58' + Ratelimit-Limit: + - '60' + Ratelimit-Remaining: + - '58' + Ratelimit-Reset: + - '17' + X-Ratelimit-Limit-Minute: + - '60' + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + - max-age=31536000; includeSubDomains; preload Access-Control-Allow-Origin: - "*" Cache-Control: - '' - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload + - no-cache, no-store X-Frame-Options: - SAMEORIGIN + Pragma: + - no-cache Transfer-Encoding: - chunked body: encoding: ASCII-8BIT - string: '{"message":"no Route matched with those values"}' - recorded_at: Wed, 13 Mar 2024 21:56:54 GMT + string: '{"data":{"statuses":[{"requestId":18559,"time":{"startTime":1710177589613,"endTime":1710177592131},"status":"SUCCESS","steps":[{"name":"CLAIMS_EVIDENCE","nextStepName":"BENEFITS_GATEWAY_SERVICE","description":"The + workflow step that uploads the document to Claims Evidence","status":"SUCCESS"},{"name":"BENEFITS_GATEWAY_SERVICE","description":"The + workflow step that uploads the document to Benefits Gateway Service","status":"SUCCESS"}]}]}}' + recorded_at: Mon, 25 Mar 2024 18:57:43 GMT recorded_with: VCR 6.2.0 diff --git a/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_failed.yml b/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_failed.yml index 8da8b2477c9..0477d79f99f 100644 --- a/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_failed.yml +++ b/spec/support/vcr_cassettes/lighthouse/benefits_claims/documents/form_526_document_upload_status_failed.yml @@ -5,7 +5,7 @@ http_interactions: uri: https://dev-api.va.gov/oauth2/benefits-documents/system/v1/token body: encoding: US-ASCII - string: grant_type=client_credentials&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInN1YiI6IjBvYXAxOHFvZnVjY2FXUVVSMnA3IiwiYXVkIjoiaHR0cHM6Ly9kZXB0dmEtZXZhbC5va3RhLmNvbS9vYXV0aDIvYXVzaTN1aTgzZkxhNjhJSnYycDcvdjEvdG9rZW4iLCJpYXQiOjE3MTAzNjcyNDQsImV4cCI6MTcxMDM2NzU0NH0.dOrrAwaW-mWzKKbPVX6ozsq-GUu7Hyaz0Z_j_dc3JLeXIQuhx4DizcXFQicAsf4mJgHJSvqWZLzZUBG52zzT23zrOukkXkRMb945TJ9RIi0rMj7WU1hQ_P_XZcEM5CZtelUcsy8hmsFJb0mxL1Ws79mQW_o1vWcTUq5O4q9_9jA1pvUbXnMBJ2YrQCg_il40BH8JbXmHcdzMM86V3s4xruzdZKF62fzeOSrrlhnj9s-unJZbx-z-Am_1bVhefkYD9uVOQlZqX3oIRluGnbIJOe9Th7QIwbzifZctel-9I8K_-L5tR5ocbdJjrLevweKIfaM8-OLi1-zIFuJGcJNFAg&scope=documents.read+documents.write + string: grant_type=client_credentials&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer&client_assertion=eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInN1YiI6IjBvYXAxOHFvZnVjY2FXUVVSMnA3IiwiYXVkIjoiaHR0cHM6Ly9kZXB0dmEtZXZhbC5va3RhLmNvbS9vYXV0aDIvYXVzaTN1aTgzZkxhNjhJSnYycDcvdjEvdG9rZW4iLCJpYXQiOjE3MTEzOTMwNjAsImV4cCI6MTcxMTM5MzM2MH0.bsn5STMs0wg6UthC6wBvJZXl_K8Qb_Mzosu1doVRvAPQYRxUajustj3YQFS_7pCDVtKEBjclYxky4HeWZlGn7shxL5z14wpaJQ3WexbX3IuKGJlR9zYdNqy9WOt6jlYMXVeOOspNefJqG9VIRL7468cTEx70Z4kr14vWG8Q775NZ8Pz-70ycLYjdP3iZwBnv_N6R4JzWP5enJ6v0FgK7JZCURmU9u4Fxbt42yG-0guMkDfVmjHXFbB9vwCLYMtgn-sl3sSNpHl0lpEUn3Z13_gzZw6aSnY16fM78TQaxltOgU_jU1WDvqdgYm7XDUJFoLpeRGq3MnkiwxoiQ7jb4Fg&scope=documents.read+documents.write headers: Accept: - application/json @@ -21,21 +21,21 @@ http_interactions: message: OK headers: Date: - - Wed, 13 Mar 2024 22:00:45 GMT + - Mon, 25 Mar 2024 18:57:41 GMT Content-Type: - application/json; charset=utf-8 Connection: - keep-alive - Ratelimit-Reset: - - '15' - X-Ratelimit-Limit-Minute: - - '60' X-Ratelimit-Remaining-Minute: - '59' Ratelimit-Limit: - '60' Ratelimit-Remaining: - '59' + Ratelimit-Reset: + - '19' + X-Ratelimit-Limit-Minute: + - '60' Vary: - Origin Cache-Control: @@ -43,19 +43,19 @@ http_interactions: Pragma: - no-cache Etag: - - W/"406-TaVOZgzhseoAzVjyHLv87i6nJaM" + - W/"406-LdhZ7Go5KkK8vIUxCwvlAbMIxWg" Access-Control-Allow-Origin: - "*" Transfer-Encoding: - chunked body: encoding: ASCII-8BIT - string: '{"access_token":"eyJraWQiOiJ5c3RTeC0xTmFRRTY2em5hNGNHb1ptQTVWV3R2TzdkQS11U3ZQV3QzaXFvIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULlkxZ2d3cmgxU1VpUWhhdmZ6MkNJdU5OUGdZQXNMcS1EdmFiYXQySlFHWnMiLCJpc3MiOiJodHRwczovL2RlcHR2YS1ldmFsLm9rdGEuY29tL29hdXRoMi9hdXNpM3VpODNmTGE2OElKdjJwNyIsImF1ZCI6Imh0dHBzOi8vc2FuZGJveC1hcGkudmEuZ292L3NlcnZpY2VzL2JlbmVmaXRzLWRvY3VtZW50cyIsImlhdCI6MTcxMDM2NzI0NSwiZXhwIjoxNzEwMzY3ODQ1LCJjaWQiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInNjcCI6WyJkb2N1bWVudHMud3JpdGUiLCJkb2N1bWVudHMucmVhZCJdLCJzdWIiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsImxhYmVsIjoiQ29mb3JtYUJ1cmdlc3MtMTY5NTgzMjQ0NyJ9.I6aFHY8Ma6JKaz2cHwFCLVlBxDQnbKIxxyblzY5NY1mhLJ1bduffM02eCjtuxVNt1a_jpxGaR2zPP3-48rQ0jb3gNPgintzOp1LYqoGChGHVhSd_T6cErbHVU6ad-A1TKHb9fD2_3V2SXLadPMdaERCawjFwcPRlHrP3eL2GmeDIMMn5DErJvFFX_HHHre52CipwD-nizXDx5rI105jr0HVyg2pZ1RDz_RnfjZfuVp3fnFHEWNILhFJPlih-WwenjlIFX0GFBkjnmMdi96X7bHTyhUUglYpoEauOxjbJ0Kf7qXk-My1-2l_A_cguRERz7vVpVt92nzPBnM5laWSJTg","token_type":"Bearer","scope":"documents.write + string: '{"access_token":"eyJraWQiOiJ5c3RTeC0xTmFRRTY2em5hNGNHb1ptQTVWV3R2TzdkQS11U3ZQV3QzaXFvIiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULkhRUkFEQkFpVVpvUDBhRERFVjVNRkJfTWtRYk43SGk3UGtLbWo4UGR6LU0iLCJpc3MiOiJodHRwczovL2RlcHR2YS1ldmFsLm9rdGEuY29tL29hdXRoMi9hdXNpM3VpODNmTGE2OElKdjJwNyIsImF1ZCI6Imh0dHBzOi8vc2FuZGJveC1hcGkudmEuZ292L3NlcnZpY2VzL2JlbmVmaXRzLWRvY3VtZW50cyIsImlhdCI6MTcxMTM5MzA2MSwiZXhwIjoxNzExMzkzNjYxLCJjaWQiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsInNjcCI6WyJkb2N1bWVudHMud3JpdGUiLCJkb2N1bWVudHMucmVhZCJdLCJzdWIiOiIwb2FwMThxb2Z1Y2NhV1FVUjJwNyIsImxhYmVsIjoiQ29mb3JtYUJ1cmdlc3MtMTY5NTgzMjQ0NyJ9.TBdcjhje5Ofu4fh_fjeg816ockS3eXW73hHZKjBelYkajRvP0QN-vBMsWmEXhcU2dNat7MgqjiEm_2XkGpkzU5hOGQ_xl6_4hW7u7IXNtUipups2dx9KZtNmJ6fvITT44fM8mJgyKEmDyU2TCnJl1OeoC3wYGA-H8BeybGb5CbQ-ERWyKRbziyJcaR_rhJhLEg5HOulCypOOWCPrDQ1sKPB3JGAcFOwdsAFN-x5bfnFbwrRi4ADMUA8LmSLfHc2a3C9_KjnE060dC70L--M345JfkPN-1YhIWt-E-dA89Bjer6E2k_riV8fo4NtWc0C76FUKvbss7_SNCxE4PedE5w","token_type":"Bearer","scope":"documents.write documents.read","expires_in":600,"state":null}' - recorded_at: Wed, 13 Mar 2024 22:00:45 GMT + recorded_at: Mon, 25 Mar 2024 18:57:41 GMT - request: method: post - uri: https://dev-api.va.gov/services/benefits-documents/uploads/status + uri: https://dev-api.va.gov/services/benefits-documents/v1/uploads/status body: encoding: UTF-8 string: '{"data":{"requestIds":["16819"]}}' @@ -63,7 +63,7 @@ http_interactions: Accept: - application/json Content-Type: - - 'Content-Type: application/json' + - application/json User-Agent: - Vets.gov Agent Authorization: Bearer @@ -71,27 +71,44 @@ http_interactions: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 response: status: - code: 404 - message: Not Found + code: 200 + message: '' headers: Date: - - Wed, 13 Mar 2024 22:00:46 GMT + - Mon, 25 Mar 2024 18:57:42 GMT Content-Type: - - application/json; charset=utf-8 + - application/json Connection: - keep-alive + X-Ratelimit-Remaining-Minute: + - '59' + Ratelimit-Limit: + - '60' + Ratelimit-Remaining: + - '59' + Ratelimit-Reset: + - '18' + X-Ratelimit-Limit-Minute: + - '60' + Strict-Transport-Security: + - max-age=16000000; includeSubDomains; preload; + - max-age=31536000; includeSubDomains; preload Access-Control-Allow-Origin: - "*" Cache-Control: - '' - Strict-Transport-Security: - - max-age=31536000; includeSubDomains; preload + - no-cache, no-store X-Frame-Options: - SAMEORIGIN + Pragma: + - no-cache Transfer-Encoding: - chunked body: encoding: ASCII-8BIT - string: '{"message":"no Route matched with those values"}' - recorded_at: Wed, 13 Mar 2024 22:00:46 GMT + string: '{"data":{"statuses":[{"requestId":16819,"time":{"startTime":1704824509436,"endTime":1704856371167},"status":"FAILED","steps":[{"name":"CLAIMS_EVIDENCE","nextStepName":"BENEFITS_GATEWAY_SERVICE","description":"The + workflow step that uploads the document to Claims Evidence","status":"FAILED"},{"name":"BENEFITS_GATEWAY_SERVICE","description":"The + workflow step that uploads the document to Benefits Gateway Service","status":"NOT_STARTED"}],"error":{"detail":"Workflow + maximum step attempts exceeded for the current step","step":"CLAIMS_EVIDENCE"}}]}}' + recorded_at: Mon, 25 Mar 2024 18:57:42 GMT recorded_with: VCR 6.2.0