From 1118b4e8f710dcef4d83e241ba89f66a2a51ea6e Mon Sep 17 00:00:00 2001 From: ashukla Date: Tue, 19 Nov 2024 13:13:43 -0600 Subject: [PATCH 01/11] Adding functionality and test for standard controller --- .../idv/socure/document_capture_controller.rb | 14 +++++--- .../document_capture_controller_spec.rb | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/app/controllers/idv/socure/document_capture_controller.rb b/app/controllers/idv/socure/document_capture_controller.rb index 8beee4f8a92..c2ba79ebc31 100644 --- a/app/controllers/idv/socure/document_capture_controller.rb +++ b/app/controllers/idv/socure/document_capture_controller.rb @@ -30,6 +30,16 @@ def show Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]). call('socure_document_capture', :view, true) + document_capture_session = DocumentCaptureSession.find_by( + uuid: document_capture_session_uuid, + ) + + if document_capture_session.socure_docv_capture_app_url.present? + @url = document_capture_session.socure_docv_capture_app_url + # TODO see if we need to set document_request, document_response, msg, and reference_id + return + end + # document request document_request = DocAuth::Socure::Requests::DocumentRequest.new( redirect_url: idv_socure_document_capture_update_url, @@ -50,10 +60,6 @@ def show return end - document_capture_session = DocumentCaptureSession.find_by( - uuid: document_capture_session_uuid, - ) - document_capture_session.socure_docv_transaction_token = document_response.dig( :data, :docvTransactionToken, diff --git a/spec/controllers/idv/socure/document_capture_controller_spec.rb b/spec/controllers/idv/socure/document_capture_controller_spec.rb index 7d494be9516..1eb32164509 100644 --- a/spec/controllers/idv/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/socure/document_capture_controller_spec.rb @@ -313,6 +313,41 @@ expect(response).to redirect_to(idv_socure_document_capture_errors_url) end end + + context 'reuse of valid capture app urls when appropriate' do + let(:fake_capture_app_url) { 'https://verify.socure.test/fake_capture_app' } + let(:socure_capture_app_url) { 'https://verify.socure.test/' } + let(:docv_transaction_token) { '176dnc45d-2e34-46f3-82217-6f540ae90673' } + let(:response_body) do + { + referenceId: '123ab45d-2e34-46f3-8d17-6f540ae90303', + data: { + eventId: 'zoYgIxEZUbXBoocYAnbb5DrT', + docvTransactionToken: docv_transaction_token, + qrCode: 'data:image/png;base64,iVBO......K5CYII=', + url: socure_capture_app_url, + }, + } + end + + before do + allow(request_class).to receive(:new).and_call_original + allow(I18n).to receive(:locale).and_return(expected_language) + allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session) + end + + it 'does not create a DocumentRequest when valid capture app exists' do + document_capture_session.socure_docv_capture_app_url = fake_capture_app_url + document_capture_session.save + get(:show) + expect(request_class).not_to have_received(:new). + with( + redirect_url: idv_socure_document_capture_update_url, + language: expected_language, + ) + expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) + end + end end describe '#update' do From e7ebbb48084f5601e25348488b2bfbbb0a8f1e9b Mon Sep 17 00:00:00 2001 From: ashukla Date: Thu, 21 Nov 2024 09:23:43 -0600 Subject: [PATCH 02/11] Adding logic to hybrid controller, pausing to wait for feature test infastructure --- .../socure/document_capture_controller.rb | 11 ++++-- .../idv/socure/document_capture_controller.rb | 1 - .../document_capture_controller_spec.rb | 34 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb b/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb index 5fa8e17c763..2a67c6641a6 100644 --- a/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb +++ b/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb @@ -20,6 +20,14 @@ def show Funnel::DocAuth::RegisterStep.new(document_capture_user.id, sp_session[:issuer]). call('hybrid_mobile_socure_document_capture', :view, true) + document_capture_session = DocumentCaptureSession.find_by( + uuid: document_capture_session_uuid, + ) + if document_capture_session.socure_docv_capture_app_url.present? + @url = document_capture_session.socure_docv_capture_app_url + return + end + # document request document_request = DocAuth::Socure::Requests::DocumentRequest.new( redirect_url: idv_hybrid_mobile_socure_document_capture_update_url, @@ -40,9 +48,6 @@ def show return end - document_capture_session = DocumentCaptureSession.find_by( - uuid: document_capture_session_uuid, - ) document_capture_session.socure_docv_transaction_token = document_response.dig( :data, :docvTransactionToken, diff --git a/app/controllers/idv/socure/document_capture_controller.rb b/app/controllers/idv/socure/document_capture_controller.rb index c2ba79ebc31..2583114ecaf 100644 --- a/app/controllers/idv/socure/document_capture_controller.rb +++ b/app/controllers/idv/socure/document_capture_controller.rb @@ -36,7 +36,6 @@ def show if document_capture_session.socure_docv_capture_app_url.present? @url = document_capture_session.socure_docv_capture_app_url - # TODO see if we need to set document_request, document_response, msg, and reference_id return end diff --git a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb index c9cfce2b570..aa5494c3001 100644 --- a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb @@ -304,6 +304,40 @@ expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url) end end + context 'reuse of valid capture app urls when appropriate' do + let(:fake_capture_app_url) { 'https://verify.socure.test/fake_capture_app' } + let(:socure_capture_app_url) { 'https://verify.socure.test/' } + let(:docv_transaction_token) { '176dnc45d-2e34-46f3-82217-6f540ae90673' } + let(:response_body) do + { + referenceId: '123ab45d-2e34-46f3-8d17-6f540ae90303', + data: { + eventId: 'zoYgIxEZUbXBoocYAnbb5DrT', + docvTransactionToken: docv_transaction_token, + qrCode: 'data:image/png;base64,iVBO......K5CYII=', + url: socure_capture_app_url, + }, + } + end + + before do + allow(request_class).to receive(:new).and_call_original + allow(I18n).to receive(:locale).and_return(expected_language) + allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session) + end + + it 'does not create a DocumentRequest when valid capture app exists' do + document_capture_session.socure_docv_capture_app_url = fake_capture_app_url + document_capture_session.save + get(:show) + expect(request_class).not_to have_received(:new). + with( + redirect_url: idv_socure_document_capture_update_url, + language: expected_language, + ) + expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) + end + end end describe '#update' do From 403c4e516ae1c547a48713cdc2c716957ddee959 Mon Sep 17 00:00:00 2001 From: ashukla Date: Mon, 2 Dec 2024 09:09:21 -0600 Subject: [PATCH 03/11] Resolving PR comments, spec test fails due to capture app reset error --- .../idv/hybrid_mobile/socure/document_capture_controller.rb | 3 --- app/controllers/idv/socure/document_capture_controller.rb | 4 ---- .../socure/document_capture_controller_spec.rb | 6 +----- .../idv/socure/document_capture_controller_spec.rb | 6 +----- spec/support/features/idv_helper.rb | 4 ++++ 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb b/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb index 2a67c6641a6..163c4d438d8 100644 --- a/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb +++ b/app/controllers/idv/hybrid_mobile/socure/document_capture_controller.rb @@ -20,9 +20,6 @@ def show Funnel::DocAuth::RegisterStep.new(document_capture_user.id, sp_session[:issuer]). call('hybrid_mobile_socure_document_capture', :view, true) - document_capture_session = DocumentCaptureSession.find_by( - uuid: document_capture_session_uuid, - ) if document_capture_session.socure_docv_capture_app_url.present? @url = document_capture_session.socure_docv_capture_app_url return diff --git a/app/controllers/idv/socure/document_capture_controller.rb b/app/controllers/idv/socure/document_capture_controller.rb index 2583114ecaf..ed4c8f94820 100644 --- a/app/controllers/idv/socure/document_capture_controller.rb +++ b/app/controllers/idv/socure/document_capture_controller.rb @@ -30,10 +30,6 @@ def show Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]). call('socure_document_capture', :view, true) - document_capture_session = DocumentCaptureSession.find_by( - uuid: document_capture_session_uuid, - ) - if document_capture_session.socure_docv_capture_app_url.present? @url = document_capture_session.socure_docv_capture_app_url return diff --git a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb index aa5494c3001..7097ad95ed6 100644 --- a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb @@ -330,11 +330,7 @@ document_capture_session.socure_docv_capture_app_url = fake_capture_app_url document_capture_session.save get(:show) - expect(request_class).not_to have_received(:new). - with( - redirect_url: idv_socure_document_capture_update_url, - language: expected_language, - ) + expect(request_class).not_to have_received(:new) expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) end end diff --git a/spec/controllers/idv/socure/document_capture_controller_spec.rb b/spec/controllers/idv/socure/document_capture_controller_spec.rb index 1eb32164509..110db695738 100644 --- a/spec/controllers/idv/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/socure/document_capture_controller_spec.rb @@ -340,11 +340,7 @@ document_capture_session.socure_docv_capture_app_url = fake_capture_app_url document_capture_session.save get(:show) - expect(request_class).not_to have_received(:new). - with( - redirect_url: idv_socure_document_capture_update_url, - language: expected_language, - ) + expect(request_class).not_to have_received(:new) expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) end end diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 54960c5bfdd..310c22d20c4 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -47,6 +47,10 @@ def click_idv_update click_on t('forms.buttons.submit.update') end + def click_idv_cancel + click_on 'Cancel' + end + def click_idv_exit click_spinner_button_and_wait t('idv.cancel.actions.exit', app_name: APP_NAME) end From 426a165836f8205a2b4c98a77e97a2a2ebb33ef6 Mon Sep 17 00:00:00 2001 From: ashukla Date: Mon, 2 Dec 2024 11:58:17 -0600 Subject: [PATCH 04/11] Resolving PR comments --- spec/support/features/idv_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 310c22d20c4..83487bcf37a 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -49,6 +49,7 @@ def click_idv_update def click_idv_cancel click_on 'Cancel' + click_on 'Exit Login.gov' end def click_idv_exit From a034a7b0d91c8aa59b9864fda6f47c82fae6038a Mon Sep 17 00:00:00 2001 From: ashukla Date: Tue, 3 Dec 2024 09:32:39 -0600 Subject: [PATCH 05/11] Resolving PR comments --- .../idv/socure/document_capture_controller_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/controllers/idv/socure/document_capture_controller_spec.rb b/spec/controllers/idv/socure/document_capture_controller_spec.rb index 110db695738..abda8838bc9 100644 --- a/spec/controllers/idv/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/socure/document_capture_controller_spec.rb @@ -333,15 +333,16 @@ before do allow(request_class).to receive(:new).and_call_original allow(I18n).to receive(:locale).and_return(expected_language) - allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session) end it 'does not create a DocumentRequest when valid capture app exists' do - document_capture_session.socure_docv_capture_app_url = fake_capture_app_url - document_capture_session.save + dcs = create(:document_capture_session, uuid: user.id) + dcs.socure_docv_capture_app_url = fake_capture_app_url + dcs.save + allow(DocumentCaptureSession).to receive(:find_by).and_return(dcs) get(:show) expect(request_class).not_to have_received(:new) - expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) + expect(dcs.socure_docv_capture_app_url).to eq(fake_capture_app_url) end end end From 2c0bd80681b472d9b3844f27aab246d2a5c1c36b Mon Sep 17 00:00:00 2001 From: ashukla Date: Wed, 4 Dec 2024 13:10:04 -0600 Subject: [PATCH 06/11] Fixing rebase --- .../doc_auth/socure_document_capture_spec.rb | 95 ++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/spec/features/idv/doc_auth/socure_document_capture_spec.rb b/spec/features/idv/doc_auth/socure_document_capture_spec.rb index 7b49d706609..07cae0e804b 100644 --- a/spec/features/idv/doc_auth/socure_document_capture_spec.rb +++ b/spec/features/idv/doc_auth/socure_document_capture_spec.rb @@ -91,7 +91,100 @@ end end - context 'network connection errors', allow_browser_log: true do + context 'reuses valid capture app urls when appropriate', allow_browser_log: true do + before do + allow(IdentityConfig.store).to receive(:doc_auth_max_attempts).and_return(max_attempts) + (max_attempts - 1).times do + socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token) + end + end + + context 'successfully erases capture app url when flow is complete' do + before do + DocAuth::Mock::DocAuthMockClient.reset! + end + + it 'proceeds to the next page with valid info' do + document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(page).to have_current_path(fake_socure_document_capture_app_url) + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + socure_docv_upload_documents( + docv_transaction_token: @docv_transaction_token, + ) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url).to be_nil + end + + it 'submits front ID, exits app, reuse capture app url' do + document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(page).to have_current_path(fake_socure_document_capture_app_url) + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + socure_docv_send_webhook( + docv_transaction_token: @docv_transaction_token, + event_type: 'DOCUMENT_FRONT_UPLOADED', + ) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + end + + it 'decline TOS making session expire, generates new capture app' do + document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(page).to have_current_path(fake_socure_document_capture_app_url) + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + socure_docv_send_webhook( + docv_transaction_token: @docv_transaction_token, + event_type: 'SESSION_EXPIRED', + ) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url).to be_nil + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + end + it 'cancel idv making session complete, generates new capture app' do + document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(page).to have_current_path(fake_socure_document_capture_app_url) + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + socure_docv_send_webhook( + docv_transaction_token: @docv_transaction_token, + event_type: 'SESSION_COMPLETE', + ) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url).to be_nil + visit idv_socure_document_capture_path + expect(page).to have_current_path(idv_socure_document_capture_path) + document_capture_session.reload + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) + end + end + end + + context 'network connection errors' do context 'getting the capture path' do before do allow_any_instance_of(Faraday::Connection).to receive(:post). From fdce7b5594d2e257934e8fa5c578c27544bb6498 Mon Sep 17 00:00:00 2001 From: ashukla Date: Wed, 4 Dec 2024 13:29:39 -0600 Subject: [PATCH 07/11] changelog: Upcoming Features, socure, reuse socure valid urls --- .../features/idv/doc_auth/socure_document_capture_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/idv/doc_auth/socure_document_capture_spec.rb b/spec/features/idv/doc_auth/socure_document_capture_spec.rb index 07cae0e804b..7beb9fd975b 100644 --- a/spec/features/idv/doc_auth/socure_document_capture_spec.rb +++ b/spec/features/idv/doc_auth/socure_document_capture_spec.rb @@ -98,12 +98,12 @@ socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token) end end - + context 'successfully erases capture app url when flow is complete' do before do DocAuth::Mock::DocAuthMockClient.reset! end - + it 'proceeds to the next page with valid info' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) expect(page).to have_current_path(fake_socure_document_capture_app_url) @@ -118,7 +118,7 @@ document_capture_session.reload expect(document_capture_session.socure_docv_capture_app_url).to be_nil end - + it 'submits front ID, exits app, reuse capture app url' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) expect(page).to have_current_path(fake_socure_document_capture_app_url) @@ -140,7 +140,7 @@ expect(document_capture_session.socure_docv_capture_app_url). to eq(fake_socure_document_capture_app_url) end - + it 'decline TOS making session expire, generates new capture app' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) expect(page).to have_current_path(fake_socure_document_capture_app_url) From de8643ee1df89c88d863e90dbd138831559f80a0 Mon Sep 17 00:00:00 2001 From: ashukla Date: Thu, 5 Dec 2024 14:34:58 -0600 Subject: [PATCH 08/11] Resolving PR comments --- .../socure/document_capture_controller_spec.rb | 9 ++++++--- .../idv/socure/document_capture_controller_spec.rb | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb index 7097ad95ed6..473d858d52c 100644 --- a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb @@ -323,12 +323,15 @@ before do allow(request_class).to receive(:new).and_call_original allow(I18n).to receive(:locale).and_return(expected_language) - allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session) end it 'does not create a DocumentRequest when valid capture app exists' do - document_capture_session.socure_docv_capture_app_url = fake_capture_app_url - document_capture_session.save + dcs = create( + :document_capture_session, + uuid: user.id, + socure_docv_capture_app_url: fake_capture_app_url, + ) + allow(DocumentCaptureSession).to receive(:find_by).and_return(dcs) get(:show) expect(request_class).not_to have_received(:new) expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) diff --git a/spec/controllers/idv/socure/document_capture_controller_spec.rb b/spec/controllers/idv/socure/document_capture_controller_spec.rb index abda8838bc9..1e1f1eef25b 100644 --- a/spec/controllers/idv/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/socure/document_capture_controller_spec.rb @@ -336,9 +336,11 @@ end it 'does not create a DocumentRequest when valid capture app exists' do - dcs = create(:document_capture_session, uuid: user.id) - dcs.socure_docv_capture_app_url = fake_capture_app_url - dcs.save + dcs = create( + :document_capture_session, + uuid: user.id, + socure_docv_capture_app_url: fake_capture_app_url, + ) allow(DocumentCaptureSession).to receive(:find_by).and_return(dcs) get(:show) expect(request_class).not_to have_received(:new) From b364ccd982272adb5b7ba60000bbe6d4009436cf Mon Sep 17 00:00:00 2001 From: ashukla Date: Thu, 5 Dec 2024 14:52:49 -0600 Subject: [PATCH 09/11] Fixing test --- .../hybrid_mobile/socure/document_capture_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb index 473d858d52c..380e2a7853a 100644 --- a/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb +++ b/spec/controllers/idv/hybrid_mobile/socure/document_capture_controller_spec.rb @@ -334,7 +334,7 @@ allow(DocumentCaptureSession).to receive(:find_by).and_return(dcs) get(:show) expect(request_class).not_to have_received(:new) - expect(document_capture_session.socure_docv_capture_app_url).to eq(fake_capture_app_url) + expect(dcs.socure_docv_capture_app_url).to eq(fake_capture_app_url) end end end From 0dd9e7e39ea0dc23e1540a49e8534fc77c252d0b Mon Sep 17 00:00:00 2001 From: ashukla Date: Thu, 5 Dec 2024 15:32:29 -0600 Subject: [PATCH 10/11] Resolving pr comments --- .../doc_auth/socure_document_capture_spec.rb | 53 ++----------------- spec/support/features/idv_helper.rb | 5 -- 2 files changed, 5 insertions(+), 53 deletions(-) diff --git a/spec/features/idv/doc_auth/socure_document_capture_spec.rb b/spec/features/idv/doc_auth/socure_document_capture_spec.rb index 7beb9fd975b..17aa07ad376 100644 --- a/spec/features/idv/doc_auth/socure_document_capture_spec.rb +++ b/spec/features/idv/doc_auth/socure_document_capture_spec.rb @@ -92,18 +92,7 @@ end context 'reuses valid capture app urls when appropriate', allow_browser_log: true do - before do - allow(IdentityConfig.store).to receive(:doc_auth_max_attempts).and_return(max_attempts) - (max_attempts - 1).times do - socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token) - end - end - context 'successfully erases capture app url when flow is complete' do - before do - DocAuth::Mock::DocAuthMockClient.reset! - end - it 'proceeds to the next page with valid info' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) expect(page).to have_current_path(fake_socure_document_capture_app_url) @@ -119,7 +108,7 @@ expect(document_capture_session.socure_docv_capture_app_url).to be_nil end - it 'submits front ID, exits app, reuse capture app url' do + it 'reuse capture app url when appropriate and creates new when not' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) expect(page).to have_current_path(fake_socure_document_capture_app_url) visit idv_socure_document_capture_path @@ -127,28 +116,16 @@ document_capture_session.reload expect(document_capture_session.socure_docv_capture_app_url). to eq(fake_socure_document_capture_app_url) + fake_capture_app2 = 'https://verify.fake-socure.test/capture2' + document_capture_session.socure_docv_capture_app_url = fake_capture_app2 + document_capture_session.save socure_docv_send_webhook( docv_transaction_token: @docv_transaction_token, event_type: 'DOCUMENT_FRONT_UPLOADED', ) document_capture_session.reload expect(document_capture_session.socure_docv_capture_app_url). - to eq(fake_socure_document_capture_app_url) - visit idv_socure_document_capture_path - expect(page).to have_current_path(idv_socure_document_capture_path) - document_capture_session.reload - expect(document_capture_session.socure_docv_capture_app_url). - to eq(fake_socure_document_capture_app_url) - end - - it 'decline TOS making session expire, generates new capture app' do - document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) - expect(page).to have_current_path(fake_socure_document_capture_app_url) - visit idv_socure_document_capture_path - expect(page).to have_current_path(idv_socure_document_capture_path) - document_capture_session.reload - expect(document_capture_session.socure_docv_capture_app_url). - to eq(fake_socure_document_capture_app_url) + to eq(fake_capture_app2) socure_docv_send_webhook( docv_transaction_token: @docv_transaction_token, event_type: 'SESSION_EXPIRED', @@ -161,26 +138,6 @@ expect(document_capture_session.socure_docv_capture_app_url). to eq(fake_socure_document_capture_app_url) end - it 'cancel idv making session complete, generates new capture app' do - document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) - expect(page).to have_current_path(fake_socure_document_capture_app_url) - visit idv_socure_document_capture_path - expect(page).to have_current_path(idv_socure_document_capture_path) - document_capture_session.reload - expect(document_capture_session.socure_docv_capture_app_url). - to eq(fake_socure_document_capture_app_url) - socure_docv_send_webhook( - docv_transaction_token: @docv_transaction_token, - event_type: 'SESSION_COMPLETE', - ) - document_capture_session.reload - expect(document_capture_session.socure_docv_capture_app_url).to be_nil - visit idv_socure_document_capture_path - expect(page).to have_current_path(idv_socure_document_capture_path) - document_capture_session.reload - expect(document_capture_session.socure_docv_capture_app_url). - to eq(fake_socure_document_capture_app_url) - end end end diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 83487bcf37a..54960c5bfdd 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -47,11 +47,6 @@ def click_idv_update click_on t('forms.buttons.submit.update') end - def click_idv_cancel - click_on 'Cancel' - click_on 'Exit Login.gov' - end - def click_idv_exit click_spinner_button_and_wait t('idv.cancel.actions.exit', app_name: APP_NAME) end From 8d3265fa53434ca83a324a94326f8f129dd9a3aa Mon Sep 17 00:00:00 2001 From: ashukla Date: Mon, 9 Dec 2024 09:49:03 -0600 Subject: [PATCH 11/11] Resolving PR additions --- spec/features/idv/doc_auth/socure_document_capture_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/idv/doc_auth/socure_document_capture_spec.rb b/spec/features/idv/doc_auth/socure_document_capture_spec.rb index 17aa07ad376..e78605c8546 100644 --- a/spec/features/idv/doc_auth/socure_document_capture_spec.rb +++ b/spec/features/idv/doc_auth/socure_document_capture_spec.rb @@ -95,6 +95,8 @@ context 'successfully erases capture app url when flow is complete' do it 'proceeds to the next page with valid info' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) expect(page).to have_current_path(fake_socure_document_capture_app_url) visit idv_socure_document_capture_path expect(page).to have_current_path(idv_socure_document_capture_path) @@ -110,6 +112,8 @@ it 'reuse capture app url when appropriate and creates new when not' do document_capture_session = DocumentCaptureSession.find_by(user_id: @user.id) + expect(document_capture_session.socure_docv_capture_app_url). + to eq(fake_socure_document_capture_app_url) expect(page).to have_current_path(fake_socure_document_capture_app_url) visit idv_socure_document_capture_path expect(page).to have_current_path(idv_socure_document_capture_path)