From 197f4f35596d22a5072a7309ec45008403182c6b Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 19 Oct 2022 14:59:44 -0400 Subject: [PATCH 01/22] Add an informative comment changelog: Upcoming Features, Inherited Proofing, LG-7446 Create "Cancel" Links and Supporting Cancellation Code for Identity Proofing Process (4 of 4) --- app/controllers/concerns/inherited_proofing_concern.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/concerns/inherited_proofing_concern.rb b/app/controllers/concerns/inherited_proofing_concern.rb index f7ec92960d1..d9779a2ec3a 100644 --- a/app/controllers/concerns/inherited_proofing_concern.rb +++ b/app/controllers/concerns/inherited_proofing_concern.rb @@ -7,6 +7,7 @@ module InheritedProofingConcern include Idv::InheritedProofing::ServiceProviderForms include Idv::InheritedProofing::ServiceProviderServices + # Returns true if Inherited Proofing is currently underway. def inherited_proofing? inherited_proofing_service_provider.present? end From bae52c86dc2061046fab4909b382ca767a13469e Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 19 Oct 2022 15:05:16 -0400 Subject: [PATCH 02/22] Refactors to allow SessionsController to handle IP Inherited Proofing (IP) session cleanup, analytics logging and redirect to the IP url when the user decides to "start over". --- .../concerns/inherited_proofing_session.rb | 23 ++++++++++ app/controllers/idv/sessions_controller.rb | 42 +++++++++++++------ 2 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 app/controllers/concerns/inherited_proofing_session.rb diff --git a/app/controllers/concerns/inherited_proofing_session.rb b/app/controllers/concerns/inherited_proofing_session.rb new file mode 100644 index 00000000000..db2b0af83f6 --- /dev/null +++ b/app/controllers/concerns/inherited_proofing_session.rb @@ -0,0 +1,23 @@ +module InheritedProofingSession + extend ActiveSupport::Concern + include InheritedProofingConcern + + private + + def destroy_inherited_proofing + inherited_proofing_clear_session + inherited_proofing_log_analytics + end + + def inherited_proofing_clear_session + user_session['idv/inherited_proofing'] = {} + end + + # LG-7128: Implement Inherited Proofing analytics here. + def inherited_proofing_log_analytics + # analytics.inherited_proofing_start_over( + # step: location_params[:step], + # location: location_params[:location], + # ) + end +end diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index 55da89d4182..efcdd30c46b 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -1,25 +1,33 @@ module Idv class SessionsController < ApplicationController include IdvSession + include InheritedProofingSession before_action :confirm_two_factor_authenticated def destroy - cancel_verification_attempt_if_pending_profile - cancel_in_person_enrollment_if_exists - analytics.idv_start_over( - step: location_params[:step], - location: location_params[:location], - ) - user_session['idv/doc_auth'] = {} - user_session['idv/in_person'] = {} - idv_session.clear - Pii::Cacher.new(current_user, user_session).delete + destroy_idv + destroy_inherited_proofing if inherited_proofing? redirect_to idv_url end private + def location_params + params.permit(:step, :location).to_h.symbolize_keys + end + + def destroy_idv + cancel_processing + clear_session + log_analytics + end + + def cancel_processing + cancel_verification_attempt_if_pending_profile + cancel_in_person_enrollment_if_exists + end + def cancel_verification_attempt_if_pending_profile return if current_user.profiles.gpo_verification_pending.blank? Idv::CancelVerificationAttempt.new(user: current_user).call @@ -32,8 +40,18 @@ def cancel_in_person_enrollment_if_exists cancel_stale_establishing_enrollments_for_user(current_user) end - def location_params - params.permit(:step, :location).to_h.symbolize_keys + def clear_session + user_session['idv/doc_auth'] = {} + user_session['idv/in_person'] = {} + idv_session.clear + Pii::Cacher.new(current_user, user_session).delete + end + + def log_analytics + analytics.idv_start_over( + step: location_params[:step], + location: location_params[:location], + ) end end end From 8c3308c827b5b03f9a887c83b698b11a912b3ddd Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 19 Oct 2022 15:06:43 -0400 Subject: [PATCH 03/22] Add a route specific to inherited proofing Not necessary, but for consistency; we're pointing to the existing SessionsController. --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 2e527ceb388..e5544dc37bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -362,6 +362,7 @@ scope '/verify/inherited_proofing', module: 'idv', as: 'idv_inherited_proofing' do # NOTE: cancellation routes need to be before any other IP # routes in this scope. + delete '/session' => 'sessions#destroy' get '/cancel' => 'inherited_proofing_cancellations#new', as: :cancel put '/cancel' => 'inherited_proofing_cancellations#update' delete '/cancel' => 'inherited_proofing_cancellations#destroy' From 31b4a5a2161019d54d63e5e1e4b7a3758bd6d581 Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 19 Oct 2022 15:08:12 -0400 Subject: [PATCH 04/22] Reinstate the "start over" cancellation button --- app/views/idv/inherited_proofing_cancellations/new.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/idv/inherited_proofing_cancellations/new.html.erb b/app/views/idv/inherited_proofing_cancellations/new.html.erb index d8803427e38..159f8363027 100644 --- a/app/views/idv/inherited_proofing_cancellations/new.html.erb +++ b/app/views/idv/inherited_proofing_cancellations/new.html.erb @@ -8,10 +8,9 @@

<%= t('inherited_proofing.cancel.description.start_over') %>

- <%# NOTE: Render "Start Over" button here, but first have to create an IP-specific SessionController. %> - <%#= render ButtonComponent.new( + <%= render ButtonComponent.new( action: ->(**tag_options, &block) do - button_to(idv_session_path(step: @flow_step), **tag_options, &block) + button_to(idv_inherited_proofing_session_path(step: @flow_step), **tag_options, &block) end, method: :delete, big: true, From cdc9e6fefd01128cab1170c494812ae8fd4d61fc Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 26 Oct 2022 10:12:02 -0400 Subject: [PATCH 05/22] Add cancel link on "Retrieving your info" view --- app/views/idv/inherited_proofing/verify_wait.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/idv/inherited_proofing/verify_wait.html.erb b/app/views/idv/inherited_proofing/verify_wait.html.erb index 90cb1a88710..2936142e739 100644 --- a/app/views/idv/inherited_proofing/verify_wait.html.erb +++ b/app/views/idv/inherited_proofing/verify_wait.html.erb @@ -14,3 +14,4 @@

<%= t('inherited_proofing.info.retrieval_time') %>

<%= t('inherited_proofing.info.retrieval_thanks') %>

+<%= render 'idv/inherited_proofing/cancel', step: 'verify_info' %> From decacc1a9039f59b3038da83a0aee56354b45de1 Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 26 Oct 2022 10:53:06 -0400 Subject: [PATCH 06/22] Add devise controller helper to get spec to pass --- spec/views/idv/inherited_proofing/retrieval.html.erb_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/views/idv/inherited_proofing/retrieval.html.erb_spec.rb b/spec/views/idv/inherited_proofing/retrieval.html.erb_spec.rb index 031ae922f0b..7db2ed40eb1 100644 --- a/spec/views/idv/inherited_proofing/retrieval.html.erb_spec.rb +++ b/spec/views/idv/inherited_proofing/retrieval.html.erb_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' describe 'idv/inherited_proofing/verify_wait.html.erb' do + include Devise::Test::ControllerHelpers + it 'renders' do render template: 'idv/inherited_proofing/verify_wait' From a9a560306c37646bfb8794eec945dedc914df529 Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 26 Oct 2022 12:32:16 -0400 Subject: [PATCH 07/22] Remove unnecessary includes --- app/controllers/concerns/inherited_proofing_concern.rb | 2 -- app/jobs/inherited_proofing_job.rb | 1 - 2 files changed, 3 deletions(-) diff --git a/app/controllers/concerns/inherited_proofing_concern.rb b/app/controllers/concerns/inherited_proofing_concern.rb index d9779a2ec3a..3b26d60826b 100644 --- a/app/controllers/concerns/inherited_proofing_concern.rb +++ b/app/controllers/concerns/inherited_proofing_concern.rb @@ -4,8 +4,6 @@ # Login.gov account. module InheritedProofingConcern extend ActiveSupport::Concern - include Idv::InheritedProofing::ServiceProviderForms - include Idv::InheritedProofing::ServiceProviderServices # Returns true if Inherited Proofing is currently underway. def inherited_proofing? diff --git a/app/jobs/inherited_proofing_job.rb b/app/jobs/inherited_proofing_job.rb index 9f0ccb178ed..c4f8d5f79e9 100644 --- a/app/jobs/inherited_proofing_job.rb +++ b/app/jobs/inherited_proofing_job.rb @@ -1,6 +1,5 @@ class InheritedProofingJob < ApplicationJob include Idv::InheritedProofing::ServiceProviderServices - include Idv::InheritedProofing::ServiceProviderForms include JobHelpers::StaleJobHelper queue_as :default From 1eabce125f9992968107f5277f0dc5d6b37ac048 Mon Sep 17 00:00:00 2001 From: gangelo Date: Thu, 27 Oct 2022 07:28:43 -0400 Subject: [PATCH 08/22] Refactor SessionController specs In prep for Inherited Proofing test additions. - Add SessionController specs for Inherited Proofing --- .../idv/sessions_controller_spec.rb | 217 +++++++++++++----- 1 file changed, 156 insertions(+), 61 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 7c0ce97cd73..116fba2a602 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -1,5 +1,62 @@ require 'rails_helper' +shared_examples 'the idv/doc_auth session is cleared' do + it 'clears the session' do + expect(controller.user_session['idv/doc_auth']).to be_blank + end +end + +shared_examples 'the idv/in_person session is cleared' do + it 'clears the session' do + expect(controller.user_session['idv/in_person']).to be_blank + end +end + +shared_examples 'the idv/inherited_proofing session is cleared' do + it 'clears the session' do + expect(controller.user_session['idv/inherited_proofing']).to be_blank + end +end + +shared_examples 'the decrypted_pii session is cleared' do + it 'clears the session' do + expect(controller.user_session[:decrypted_pii]).to be_blank + end +end + +shared_examples 'a redirect occurs to the start of identity verificaton' do + it 'redirects' do + delete :destroy + + expect(response).to redirect_to(idv_url) + end +end + +shared_examples 'logs IDV start over analytics with step and location params' do + it 'logs the analytics' do + delete :destroy, params: { step: 'first', location: 'get_help' } + + expect(@analytics).to have_logged_event( + 'IdV: start over', + step: 'first', + location: 'get_help', + ) + end +end + +# LG-7128: Implement Inherited Proofing analytics here. +shared_examples 'logs Inherited Proofing start over analytics with step and location params' do + xit 'logs the analytics' do + delete :destroy, params: { step: 'first', location: 'get_help' } + + expect(@analytics).to have_logged_event( + 'InheritedProofing: start over', + step: 'first', + location: 'get_help', + ) + end +end + describe Idv::SessionsController do let(:user) { build(:user) } @@ -16,84 +73,122 @@ before do allow(idv_session).to receive(:clear) allow(subject).to receive(:idv_session).and_return(idv_session) - controller.user_session['idv/doc_auth'] = flow_session - controller.user_session['idv/in_person'] = flow_session + controller.user_session['idv/doc_auth'] = { idv_doc_auth_session: true } + controller.user_session['idv/in_person'] = { idv_in_person_session: true } controller.user_session[:decrypted_pii] = pii end - it 'deletes idv session' do - expect(idv_session).to receive(:clear) - - delete :destroy - - expect(controller.user_session['idv/doc_auth']).to be_blank - expect(controller.user_session['idv/in_person']).to be_blank - expect(controller.user_session[:decrypted_pii]).to be_blank - end + context 'when inherited proofing' do + before do + allow(IdentityConfig.store).to receive(:inherited_proofing_enabled).and_return(true) + allow(subject).to receive(:inherited_proofing?).and_return true + end - it 'logs start over with step and location params' do - delete :destroy, params: { step: 'first', location: 'get_help' } + context 'when destroying the session' do + before do + allow(IdentityConfig.store).to receive(:inherited_proofing_enabled).and_return(true) + allow(subject).to receive(:inherited_proofing?).and_return true + controller.user_session['idv/inherited_proofing'] = idv_inherited_proofing_session + + expect(idv_session).to receive(:clear) + + delete :destroy + end + + let(:auth_code) { Idv::InheritedProofing::Va::Mocks::Service::VALID_AUTH_CODE } + let(:payload_hash) { Idv::InheritedProofing::Va::Mocks::Service::PAYLOAD_HASH } + let(:pii) { Idv::InheritedProofing::Va::Form.new(payload_hash: payload_hash).user_pii } + + let(:idv_inherited_proofing_session) do + { + 'pii_from_user' => { + 'uuid' => '5b7a6a09-840a-4139-b1e2-edee2462f8d2', + }, + 'error_message' => nil, + 'Idv::Steps::InheritedProofing::GetStartedStep' => true, + } + end + + it_behaves_like 'the idv/doc_auth session is cleared' + it_behaves_like 'the idv/in_person session is cleared' + it_behaves_like 'the idv/inherited_proofing session is cleared' + it_behaves_like 'the decrypted_pii session is cleared' + end - expect(@analytics).to have_logged_event( - 'IdV: start over', - step: 'first', - location: 'get_help', - ) + # In the case of Inherited Proofing (IP) we will redirect to the + # idv_url, which will pass through the IdvController and eventually + # redirect us to the idv_inherited_proofing_url. This is by design + # so that analytics can be logged, throttling and quotes can be + # properly checked; this could not take place if we simply redirected + # to idv_inherited_proofing_url. + it_behaves_like 'a redirect occurs to the start of identity verificaton' + it_behaves_like 'logs IDV start over analytics with step and location params' + it_behaves_like 'logs Inherited Proofing start over analytics with step and location params' end - it 'redirects to start of identity verificaton' do - delete :destroy - - expect(response).to redirect_to(idv_url) - end + context 'when idv proofing' do + context 'when destroying the session' do + before do + expect(idv_session).to receive(:clear) + delete :destroy + end - context 'pending profile' do - let(:user) do - create( - :user, - profiles: [create(:profile, deactivation_reason: :gpo_verification_pending)], - ) + it_behaves_like 'the idv/doc_auth session is cleared' + it_behaves_like 'the idv/in_person session is cleared' + it_behaves_like 'the decrypted_pii session is cleared' end - it 'cancels verification attempt' do - cancel = double - expect(Idv::CancelVerificationAttempt).to receive(:new).and_return(cancel) - expect(cancel).to receive(:call) - - delete :destroy, params: { step: 'gpo_verify', location: 'clear_and_start_over' } - expect(@analytics).to have_logged_event( - 'IdV: start over', - step: 'gpo_verify', - location: 'clear_and_start_over', - ) + it_behaves_like 'logs IDV start over analytics with step and location params' + it_behaves_like 'a redirect occurs to the start of identity verificaton' + + context 'pending profile' do + let(:user) do + create( + :user, + profiles: [create(:profile, deactivation_reason: :gpo_verification_pending)], + ) + end + + it 'cancels verification attempt' do + cancel = double + expect(Idv::CancelVerificationAttempt).to receive(:new).and_return(cancel) + expect(cancel).to receive(:call) + + delete :destroy, params: { step: 'gpo_verify', location: 'clear_and_start_over' } + expect(@analytics).to have_logged_event( + 'IdV: start over', + step: 'gpo_verify', + location: 'clear_and_start_over', + ) + end end - end - context 'with in person enrollment' do - let(:user) { build(:user, :with_pending_in_person_enrollment) } + context 'with in person enrollment' do + let(:user) { build(:user, :with_pending_in_person_enrollment) } - before do - allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) - end + before do + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end - it 'cancels pending in person enrollment' do - pending_enrollment = user.pending_in_person_enrollment - expect(user.reload.pending_in_person_enrollment).to_not be_blank - delete :destroy + it 'cancels pending in person enrollment' do + pending_enrollment = user.pending_in_person_enrollment + expect(user.reload.pending_in_person_enrollment).to_not be_blank + delete :destroy - pending_enrollment.reload - expect(pending_enrollment.status).to eq('cancelled') - expect(user.reload.pending_in_person_enrollment).to be_blank - end + pending_enrollment.reload + expect(pending_enrollment.status).to eq('cancelled') + expect(user.reload.pending_in_person_enrollment).to be_blank + end - it 'cancels establishing in person enrollment' do - establishing_enrollment = create(:in_person_enrollment, :establishing, user: user) - expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(1) - delete :destroy + it 'cancels establishing in person enrollment' do + establishing_enrollment = create(:in_person_enrollment, :establishing, user: user) + expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(1) + delete :destroy - establishing_enrollment.reload - expect(establishing_enrollment.status).to eq('cancelled') - expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(0) + establishing_enrollment.reload + expect(establishing_enrollment.status).to eq('cancelled') + expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(0) + end end end end From 8e6948c2858f7c7af7011ae3d933f7dfa675b6d6 Mon Sep 17 00:00:00 2001 From: gangelo Date: Mon, 31 Oct 2022 11:28:12 -0400 Subject: [PATCH 09/22] Remove unnecessary return --- .../idv/steps/inherited_proofing/verify_wait_step_show.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/idv/steps/inherited_proofing/verify_wait_step_show.rb b/app/services/idv/steps/inherited_proofing/verify_wait_step_show.rb index f66490c971e..45df7920b8c 100644 --- a/app/services/idv/steps/inherited_proofing/verify_wait_step_show.rb +++ b/app/services/idv/steps/inherited_proofing/verify_wait_step_show.rb @@ -61,7 +61,7 @@ def async_state_done(_current_async_state) mark_step_incomplete(:agreement) end - return form_response + form_response end def dcs_uuid From bf002fcbfc1f68c33eef8ec71ce55a482007f814 Mon Sep 17 00:00:00 2001 From: gangelo Date: Mon, 31 Oct 2022 15:54:37 -0400 Subject: [PATCH 10/22] Add comments for analytics So that when the card gets worked on, these areas can be identified and analytics applied. --- .../idv/inherited_proofing_cancellations_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/idv/inherited_proofing_cancellations_controller.rb b/app/controllers/idv/inherited_proofing_cancellations_controller.rb index c277fd9c9d0..c143c72bcee 100644 --- a/app/controllers/idv/inherited_proofing_cancellations_controller.rb +++ b/app/controllers/idv/inherited_proofing_cancellations_controller.rb @@ -8,7 +8,7 @@ class InheritedProofingCancellationsController < ApplicationController before_action :confirm_idv_needed def new - # NOTE: Uncomment this when analytics are implemented. + # LG-7128: Implement Inherited Proofing analytics here. # properties = ParseControllerFromReferer.new(request.referer).call # analytics.idv_inherited_proofing_cancellation_visited(step: params[:step], **properties) self.session_go_back_path = go_back_path || idv_inherited_proofing_path @@ -19,13 +19,13 @@ def new end def update - # NOTE: Uncomment this when analytics are implemented. + # LG-7128: Implement Inherited Proofing analytics here. # analytics.idv_inherited_proofing_cancellation_go_back(step: params[:step]) redirect_to session_go_back_path || idv_inherited_proofing_path end def destroy - # NOTE: Uncomment this when analytics are implemented. + # LG-7128: Implement Inherited Proofing analytics here. # analytics.idv_inherited_proofing_cancellation_confirmed(step: params[:step]) cancel_session render json: { redirect_url: cancelled_redirect_path } From f5a09571a34e9e55d38cf247b19d813926b7cfa1 Mon Sep 17 00:00:00 2001 From: gangelo Date: Mon, 31 Oct 2022 16:02:03 -0400 Subject: [PATCH 11/22] Add feature specs Test cancel from all Inherited Proofing views, all cancellation scenarios: "Start over" "No, go back" "Exit Login.gov" Need to revisit cancellations from the :verify_waiting step; see notes in the spec file. --- .../inherited_proofing_cancel_spec.rb | 278 ++++++++++++++++++ spec/support/features/idv_helper.rb | 23 ++ 2 files changed, 301 insertions(+) create mode 100644 spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb new file mode 100644 index 00000000000..c952da2a8bd --- /dev/null +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -0,0 +1,278 @@ +require 'rails_helper' + +# rubocop:disable Layout/LineLength +shared_examples 'steps up to "Get started..." are completed' do + it 'should have current path equal to the Getting Started page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + end +end + +shared_examples 'steps up to "How verifying..." are completed' do + it 'should have current path equal to the How Verifying (agreement step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) + end +end + +shared_examples 'steps up to "We are retrieving..." are completed' do + it 'should have current path equal to the We are retrieving (verify_wait step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) + end +end + +shared_examples 'steps up to "Verify your information..." are completed' do + it 'should have current path equal to the Verify your information (verify_info step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) + end +end + +shared_examples 'the user is redirected to the Cancellation View' do + it 'redirects to the Cancellations view' do + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end +end + +# Simulates a user (in this case, a VA inherited proofing-authorized user) +# coming over to login.gov from a service provider, and hitting the +# OpenidConnect::AuthorizationController#index action. +def send_user_from_service_provider_to_login_gov_openid_connect(user) + expect(user).to_not be_nil + # NOTE: VA user. + visit_idp_from_oidc_va_with_ial2 +end + +def complete_idv_steps_up_to_inherited_proofing_get_started_step(user, expect_accessible: false) + unless current_path.match?(/inherited_proofing[?|\/].*get_started/) + complete_idv_steps_before_phone_step(user) + click_link t('links.cancel') + click_button t('idv.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + expect(page).to be_axe_clean.according_to :section508, :"best-practice" if expect_accessible +end + +def complete_idv_steps_up_to_inherited_proofing_how_verifying_step(user, expect_accessible: false) + complete_idv_steps_up_to_inherited_proofing_get_started_step user, + expect_accessible: expect_accessible + unless current_path.match?(/inherited_proofing[?|\/].*agreement/) + click_on t('inherited_proofing.buttons.continue') + end +end + +def complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step(user, + expect_accessible: false) + complete_idv_steps_up_to_inherited_proofing_how_verifying_step user, + expect_accessible: expect_accessible + unless current_path.match?(/inherited_proofing[?|\/].*verify_wait/) + check t('inherited_proofing.instructions.consent', app_name: APP_NAME), allow_label_click: true + click_on t('inherited_proofing.buttons.continue') + end +end + +def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, + expect_accessible: false) + complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step( + user, + expect_accessible: expect_accessible, + ) +end + +feature 'inherited proofing cancel process', :js do + include InheritedProofingHelper + include_context 'va_user_context' + + before do + allow(IdentityConfig.store).to receive(:va_inherited_proofing_mock_enabled).and_return true + send_user_from_service_provider_to_login_gov_openid_connect user + end + + let!(:user) { user_with_2fa } + + context 'when JS is enabled', :js do + context 'from the "Get started verifying your identity" view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_get_started_step user + end + + it_behaves_like 'steps up to "Get started..." are completed' + + context 'when clicking the "Start Over" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end + + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + end + + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end + + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + end + + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end + + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) + end + end + end + + context 'from the "How verifying your identify works" view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_how_verifying_step user + end + + it_behaves_like 'steps up to "How verifying..." are completed' + + context 'when clicking the "Start Over" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) + end + + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + end + + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) + end + + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/agreement") + end + end + + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) + end + + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) + end + end + end + + # Revisit. ATM cannot get around the :verify_wait step as it's an ajax-enabled step that an + # includes ActiveJob to move to the next step. Marking the necessary step as completed below, + # does not seem to do the trick for some reason. This has been manually verified in the + # meantime. + xcontext 'from the "We are retrieving your information..." view, and clicking the "Cancel" link' do + before do + allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep).to receive(:enqueue_job).and_wrap_original do |target, *args| + target.receiver.mark_step_complete(:agreement) + # Omit the original call. + # target.call(*args) + nil + end + complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step user + end + + it_behaves_like 'steps up to "We are retrieving..." are completed' + + context 'when clicking the "Start Over" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) + end + + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + end + + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) + end + + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_wait") + end + end + + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) + end + + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) + end + end + end + + context 'from the "Verify your information..." view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user + end + + it_behaves_like 'steps up to "Verify your information..." are completed' + + context 'when clicking the "Start Over" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) + end + + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + end + end + + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) + end + + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_info") + end + end + + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) + end + + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) + end + end + end + end +end +# rubocop:enable Layout/LineLength diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 7c4713cc2c5..c244ac17b6c 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -120,6 +120,29 @@ def visit_idp_from_oidc_sp_with_ial2( ) end + def visit_idp_from_oidc_va_with_ial2( + client_id: sp_oidc_issuer, + state: SecureRandom.hex, + nonce: SecureRandom.hex, + verified_within: nil + ) + @state = state + @client_id = sp_oidc_issuer + @nonce = nonce + visit openid_connect_authorize_path( + client_id: client_id, + response_type: 'code', + acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, + scope: 'openid email profile:name phone social_security_number', + redirect_uri: sp_oidc_redirect_uri, + state: state, + prompt: 'select_account', + nonce: nonce, + verified_within: verified_within, + inherited_proofing_auth: Idv::InheritedProofing::Va::Mocks::Service::VALID_AUTH_CODE, + ) + end + def visit_idp_from_oidc_sp_with_loa3 visit openid_connect_authorize_path( client_id: sp_oidc_issuer, From 50e53f121f05c4337bd07a09d34073dcf6ce3df0 Mon Sep 17 00:00:00 2001 From: Zach Margolis Date: Wed, 2 Nov 2022 04:29:31 -0700 Subject: [PATCH 12/22] Patch to VAIP sessions controller changes (#7269) * Inline mixins to make the PR diff smaller and easier to understand * Inline shared examples that are only used once (not shared) * Remove unused shared example * Remove line length override and fix errors * fix typo --- .../concerns/inherited_proofing_session.rb | 23 ------- app/controllers/idv/sessions_controller.rb | 50 ++++++-------- .../idv/sessions_controller_spec.rb | 6 +- .../inherited_proofing_cancel_spec.rb | 69 +++++++------------ 4 files changed, 49 insertions(+), 99 deletions(-) delete mode 100644 app/controllers/concerns/inherited_proofing_session.rb diff --git a/app/controllers/concerns/inherited_proofing_session.rb b/app/controllers/concerns/inherited_proofing_session.rb deleted file mode 100644 index db2b0af83f6..00000000000 --- a/app/controllers/concerns/inherited_proofing_session.rb +++ /dev/null @@ -1,23 +0,0 @@ -module InheritedProofingSession - extend ActiveSupport::Concern - include InheritedProofingConcern - - private - - def destroy_inherited_proofing - inherited_proofing_clear_session - inherited_proofing_log_analytics - end - - def inherited_proofing_clear_session - user_session['idv/inherited_proofing'] = {} - end - - # LG-7128: Implement Inherited Proofing analytics here. - def inherited_proofing_log_analytics - # analytics.inherited_proofing_start_over( - # step: location_params[:step], - # location: location_params[:location], - # ) - end -end diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index efcdd30c46b..525fd500539 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -1,33 +1,28 @@ module Idv class SessionsController < ApplicationController include IdvSession - include InheritedProofingSession + include InheritedProofingConcern before_action :confirm_two_factor_authenticated def destroy - destroy_idv - destroy_inherited_proofing if inherited_proofing? + cancel_verification_attempt_if_pending_profile + cancel_in_person_enrollment_if_exists + cancel_inherited_proofing_if_exists + analytics.idv_start_over( + step: location_params[:step], + location: location_params[:location], + ) + user_session['idv/doc_auth'] = {} + user_session['idv/in_person'] = {} + user_session['idv/inherited_proofing'] = {} + idv_session.clear + Pii::Cacher.new(current_user, user_session).delete redirect_to idv_url end private - def location_params - params.permit(:step, :location).to_h.symbolize_keys - end - - def destroy_idv - cancel_processing - clear_session - log_analytics - end - - def cancel_processing - cancel_verification_attempt_if_pending_profile - cancel_in_person_enrollment_if_exists - end - def cancel_verification_attempt_if_pending_profile return if current_user.profiles.gpo_verification_pending.blank? Idv::CancelVerificationAttempt.new(user: current_user).call @@ -40,18 +35,17 @@ def cancel_in_person_enrollment_if_exists cancel_stale_establishing_enrollments_for_user(current_user) end - def clear_session - user_session['idv/doc_auth'] = {} - user_session['idv/in_person'] = {} - idv_session.clear - Pii::Cacher.new(current_user, user_session).delete + def cancel_inherited_proofing_if_exists + return if !inherited_proofing? + # LG-7128: Implement Inherited Proofing analytics here. + # analytics.inherited_proofing_start_over( + # step: location_params[:step], + # location: location_params[:location], + # ) end - def log_analytics - analytics.idv_start_over( - step: location_params[:step], - location: location_params[:location], - ) + def location_params + params.permit(:step, :location).to_h.symbolize_keys end end end diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 116fba2a602..84b31b08878 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -24,7 +24,7 @@ end end -shared_examples 'a redirect occurs to the start of identity verificaton' do +shared_examples 'a redirect occurs to the start of identity verification' do it 'redirects' do delete :destroy @@ -121,7 +121,7 @@ # so that analytics can be logged, throttling and quotes can be # properly checked; this could not take place if we simply redirected # to idv_inherited_proofing_url. - it_behaves_like 'a redirect occurs to the start of identity verificaton' + it_behaves_like 'a redirect occurs to the start of identity verification' it_behaves_like 'logs IDV start over analytics with step and location params' it_behaves_like 'logs Inherited Proofing start over analytics with step and location params' end @@ -139,7 +139,7 @@ end it_behaves_like 'logs IDV start over analytics with step and location params' - it_behaves_like 'a redirect occurs to the start of identity verificaton' + it_behaves_like 'a redirect occurs to the start of identity verification' context 'pending profile' do let(:user) do diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index c952da2a8bd..39b6eb4b715 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -1,36 +1,5 @@ require 'rails_helper' -# rubocop:disable Layout/LineLength -shared_examples 'steps up to "Get started..." are completed' do - it 'should have current path equal to the Getting Started page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) - end -end - -shared_examples 'steps up to "How verifying..." are completed' do - it 'should have current path equal to the How Verifying (agreement step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) - end -end - -shared_examples 'steps up to "We are retrieving..." are completed' do - it 'should have current path equal to the We are retrieving (verify_wait step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) - end -end - -shared_examples 'steps up to "Verify your information..." are completed' do - it 'should have current path equal to the Verify your information (verify_info step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) - end -end - -shared_examples 'the user is redirected to the Cancellation View' do - it 'redirects to the Cancellations view' do - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) - end -end - # Simulates a user (in this case, a VA inherited proofing-authorized user) # coming over to login.gov from a service provider, and hitting the # OpenidConnect::AuthorizationController#index action. @@ -60,8 +29,10 @@ def complete_idv_steps_up_to_inherited_proofing_how_verifying_step(user, expect_ def complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step(user, expect_accessible: false) - complete_idv_steps_up_to_inherited_proofing_how_verifying_step user, - expect_accessible: expect_accessible + complete_idv_steps_up_to_inherited_proofing_how_verifying_step( + user, + expect_accessible: expect_accessible, + ) unless current_path.match?(/inherited_proofing[?|\/].*verify_wait/) check t('inherited_proofing.instructions.consent', app_name: APP_NAME), allow_label_click: true click_on t('inherited_proofing.buttons.continue') @@ -93,7 +64,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_get_started_step user end - it_behaves_like 'steps up to "Get started..." are completed' + it 'should have current path equal to the Getting Started page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -137,7 +110,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_how_verifying_step user end - it_behaves_like 'steps up to "How verifying..." are completed' + it 'should have current path equal to the How Verifying (agreement step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -180,18 +155,21 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, # includes ActiveJob to move to the next step. Marking the necessary step as completed below, # does not seem to do the trick for some reason. This has been manually verified in the # meantime. - xcontext 'from the "We are retrieving your information..." view, and clicking the "Cancel" link' do + xcontext 'from the "We are retrieving your information..." view, and clicking "Cancel"' do before do - allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep).to receive(:enqueue_job).and_wrap_original do |target, *args| - target.receiver.mark_step_complete(:agreement) - # Omit the original call. - # target.call(*args) - nil - end + allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep). + to receive(:enqueue_job).and_wrap_original do |target, *args| + target.receiver.mark_step_complete(:agreement) + # Omit the original call. + # target.call(*args) + nil + end complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step user end - it_behaves_like 'steps up to "We are retrieving..." are completed' + it 'should have current path equal to the We are retrieving (verify_wait step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -235,7 +213,9 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user end - it_behaves_like 'steps up to "Verify your information..." are completed' + it 'should have current path equal to the Verify your information (verify_info step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) + end context 'when clicking the "Start Over" button from the "Cancel" view' do before do @@ -275,4 +255,3 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end end end -# rubocop:enable Layout/LineLength From 6cc7435080d10e148482a0c90c8f33b9e9daf27d Mon Sep 17 00:00:00 2001 From: gangelo Date: Wed, 2 Nov 2022 08:06:34 -0400 Subject: [PATCH 13/22] Reorganize SessionsController clean up code --- app/controllers/idv/sessions_controller.rb | 48 ++++++++++++---------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index 525fd500539..dc969067da1 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -1,28 +1,27 @@ module Idv class SessionsController < ApplicationController include IdvSession - include InheritedProofingConcern before_action :confirm_two_factor_authenticated def destroy - cancel_verification_attempt_if_pending_profile - cancel_in_person_enrollment_if_exists - cancel_inherited_proofing_if_exists - analytics.idv_start_over( - step: location_params[:step], - location: location_params[:location], - ) - user_session['idv/doc_auth'] = {} - user_session['idv/in_person'] = {} - user_session['idv/inherited_proofing'] = {} - idv_session.clear - Pii::Cacher.new(current_user, user_session).delete + cancel_processing + clear_session + log_analytics redirect_to idv_url end private + def location_params + params.permit(:step, :location).to_h.symbolize_keys + end + + def cancel_processing + cancel_verification_attempt_if_pending_profile + cancel_in_person_enrollment_if_exists + end + def cancel_verification_attempt_if_pending_profile return if current_user.profiles.gpo_verification_pending.blank? Idv::CancelVerificationAttempt.new(user: current_user).call @@ -35,17 +34,22 @@ def cancel_in_person_enrollment_if_exists cancel_stale_establishing_enrollments_for_user(current_user) end - def cancel_inherited_proofing_if_exists - return if !inherited_proofing? - # LG-7128: Implement Inherited Proofing analytics here. - # analytics.inherited_proofing_start_over( - # step: location_params[:step], - # location: location_params[:location], - # ) + def clear_session + user_session['idv/doc_auth'] = {} + user_session['idv/in_person'] = {} + user_session['idv/inherited_proofing'] = {} + idv_session.clear + Pii::Cacher.new(current_user, user_session).delete end - def location_params - params.permit(:step, :location).to_h.symbolize_keys + def log_analytics + # LG-7128: Implement Inherited Proofing analytics here. + # include InheritedProofingConcern and if inherited_proofing?, + # pass flow/param/analytics_ids param to the existing idv_start_over event. + analytics.idv_start_over( + step: location_params[:step], + location: location_params[:location], + ) end end end From d9599eb3e1ce173e7807f1b16223f01fc63fec3e Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 08:08:15 -0400 Subject: [PATCH 14/22] Remove skipped specs per PR feedback --- .../idv/sessions_controller_spec.rb | 14 ----- .../inherited_proofing_cancel_spec.rb | 57 ------------------- 2 files changed, 71 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 84b31b08878..c56424c1483 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -44,19 +44,6 @@ end end -# LG-7128: Implement Inherited Proofing analytics here. -shared_examples 'logs Inherited Proofing start over analytics with step and location params' do - xit 'logs the analytics' do - delete :destroy, params: { step: 'first', location: 'get_help' } - - expect(@analytics).to have_logged_event( - 'InheritedProofing: start over', - step: 'first', - location: 'get_help', - ) - end -end - describe Idv::SessionsController do let(:user) { build(:user) } @@ -123,7 +110,6 @@ # to idv_inherited_proofing_url. it_behaves_like 'a redirect occurs to the start of identity verification' it_behaves_like 'logs IDV start over analytics with step and location params' - it_behaves_like 'logs Inherited Proofing start over analytics with step and location params' end context 'when idv proofing' do diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index 39b6eb4b715..087e433cb73 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -151,63 +151,6 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end end - # Revisit. ATM cannot get around the :verify_wait step as it's an ajax-enabled step that an - # includes ActiveJob to move to the next step. Marking the necessary step as completed below, - # does not seem to do the trick for some reason. This has been manually verified in the - # meantime. - xcontext 'from the "We are retrieving your information..." view, and clicking "Cancel"' do - before do - allow_any_instance_of(Idv::Steps::InheritedProofing::AgreementStep). - to receive(:enqueue_job).and_wrap_original do |target, *args| - target.receiver.mark_step_complete(:agreement) - # Omit the original call. - # target.call(*args) - nil - end - complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step user - end - - it 'should have current path equal to the We are retrieving (verify_wait step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_wait/) - end - - context 'when clicking the "Start Over" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) - end - - it 'redirects the user back to the start of the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") - end - end - - context 'when clicking the "No, keep going" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) - end - - it 'redirects the user back to where the user left off in the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_wait") - end - end - - context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_wait)) - end - - it 'redirects the user back to the service provider website' do - click_button t('idv.cancel.actions.exit', app_name: APP_NAME) - expect(page).to have_current_path(/\/auth\/result\?/) - end - end - end - context 'from the "Verify your information..." view, and clicking the "Cancel" link' do before do complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user From 68ea3d7329805ba6eae7e45e1fefbccd4da2709f Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 08:26:51 -0400 Subject: [PATCH 15/22] Clean up sone unnecessary/redundant mocks/vars --- spec/controllers/idv/sessions_controller_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index c56424c1483..be579e5e72d 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -73,16 +73,12 @@ context 'when destroying the session' do before do - allow(IdentityConfig.store).to receive(:inherited_proofing_enabled).and_return(true) - allow(subject).to receive(:inherited_proofing?).and_return true controller.user_session['idv/inherited_proofing'] = idv_inherited_proofing_session - expect(idv_session).to receive(:clear) delete :destroy end - let(:auth_code) { Idv::InheritedProofing::Va::Mocks::Service::VALID_AUTH_CODE } let(:payload_hash) { Idv::InheritedProofing::Va::Mocks::Service::PAYLOAD_HASH } let(:pii) { Idv::InheritedProofing::Va::Form.new(payload_hash: payload_hash).user_pii } From 45d7203d7184bfac1545bd4a578cd044fa1c1665 Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 09:15:25 -0400 Subject: [PATCH 16/22] Remove redundant js enable on tests --- .../inherited_proofing_cancel_spec.rb | 194 +++++++++--------- 1 file changed, 96 insertions(+), 98 deletions(-) diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index 087e433cb73..7d46b43105f 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -58,142 +58,140 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, let!(:user) { user_with_2fa } - context 'when JS is enabled', :js do - context 'from the "Get started verifying your identity" view, and clicking the "Cancel" link' do + context 'from the "Get started verifying your identity" view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_get_started_step user + end + + it 'should have current path equal to the Getting Started page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + end + + context 'when clicking the "Start Over" button from the "Cancel" view' do before do - complete_idv_steps_up_to_inherited_proofing_get_started_step user + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) end - it 'should have current path equal to the Getting Started page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") end + end - context 'when clicking the "Start Over" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) - end + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end - it 'redirects the user back to the start of the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") - end + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") end + end - context 'when clicking the "No, keep going" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) - end + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) + end - it 'redirects the user back to where the user left off in the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") - end + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) end + end + end - context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :get_started)) - end + context 'from the "How verifying your identify works" view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_how_verifying_step user + end - it 'redirects the user back to the service provider website' do - click_button t('idv.cancel.actions.exit', app_name: APP_NAME) - expect(page).to have_current_path(/\/auth\/result\?/) - end - end + it 'should have current path equal to the How Verifying (agreement step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) end - context 'from the "How verifying your identify works" view, and clicking the "Cancel" link' do + context 'when clicking the "Start Over" button from the "Cancel" view' do before do - complete_idv_steps_up_to_inherited_proofing_how_verifying_step user + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) end - it 'should have current path equal to the How Verifying (agreement step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") end + end - context 'when clicking the "Start Over" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) - end + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) + end - it 'redirects the user back to the start of the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") - end + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/agreement") end + end - context 'when clicking the "No, keep going" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) - end + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) + end - it 'redirects the user back to where the user left off in the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/agreement") - end + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) end + end + end - context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :agreement)) - end + context 'from the "Verify your information..." view, and clicking the "Cancel" link' do + before do + complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user + end - it 'redirects the user back to the service provider website' do - click_button t('idv.cancel.actions.exit', app_name: APP_NAME) - expect(page).to have_current_path(/\/auth\/result\?/) - end - end + it 'should have current path equal to the Verify your information (verify_info step) page' do + expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) end - context 'from the "Verify your information..." view, and clicking the "Cancel" link' do + context 'when clicking the "Start Over" button from the "Cancel" view' do before do - complete_idv_steps_up_to_inherited_proofing_verify_your_info_step user + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) end - it 'should have current path equal to the Verify your information (verify_info step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) + it 'redirects the user back to the start of the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.start_over') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") end + end - context 'when clicking the "Start Over" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) - end - - it 'redirects the user back to the start of the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") - end + context 'when clicking the "No, keep going" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) end - context 'when clicking the "No, keep going" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) - end - - it 'redirects the user back to where the user left off in the Inherited Proofing process' do - click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_info") - end + it 'redirects the user back to where the user left off in the Inherited Proofing process' do + click_button t('inherited_proofing.cancel.actions.keep_going') + expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_info") end + end - context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do - before do - click_link t('links.cancel') - expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) - end + context 'when clicking the "Exit Login.gov" button from the "Cancel" view' do + before do + click_link t('links.cancel') + expect(page).to have_current_path(idv_inherited_proofing_cancel_path(step: :verify_info)) + end - it 'redirects the user back to the service provider website' do - click_button t('idv.cancel.actions.exit', app_name: APP_NAME) - expect(page).to have_current_path(/\/auth\/result\?/) - end + it 'redirects the user back to the service provider website' do + click_button t('idv.cancel.actions.exit', app_name: APP_NAME) + expect(page).to have_current_path(/\/auth\/result\?/) end end end From 2a12183f71c417b1e0a4b82f700e52fef806f93f Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 09:39:03 -0400 Subject: [PATCH 17/22] Make regexp to check rails paths more concise --- .../inherited_proofing/inherited_proofing_cancel_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index 7d46b43105f..4896de95787 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -10,7 +10,7 @@ def send_user_from_service_provider_to_login_gov_openid_connect(user) end def complete_idv_steps_up_to_inherited_proofing_get_started_step(user, expect_accessible: false) - unless current_path.match?(/inherited_proofing[?|\/].*get_started/) + unless current_path.match?(/inherited_proofing\/get_started|inherited_proofing\?step=get_started/) complete_idv_steps_before_phone_step(user) click_link t('links.cancel') click_button t('idv.cancel.actions.start_over') @@ -22,7 +22,7 @@ def complete_idv_steps_up_to_inherited_proofing_get_started_step(user, expect_ac def complete_idv_steps_up_to_inherited_proofing_how_verifying_step(user, expect_accessible: false) complete_idv_steps_up_to_inherited_proofing_get_started_step user, expect_accessible: expect_accessible - unless current_path.match?(/inherited_proofing[?|\/].*agreement/) + unless current_path.match?(/inherited_proofing\/agreement|inherited_proofing\?step=agreement/) click_on t('inherited_proofing.buttons.continue') end end @@ -33,7 +33,7 @@ def complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step(user, user, expect_accessible: expect_accessible, ) - unless current_path.match?(/inherited_proofing[?|\/].*verify_wait/) + unless current_path.match?(/inherited_proofing\/verify_wait|inherited_proofing\?step=verify_wait/) check t('inherited_proofing.instructions.consent', app_name: APP_NAME), allow_label_click: true click_on t('inherited_proofing.buttons.continue') end From 19ef733f70af2e53074222f422c8b9a43b87d446 Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 12:12:29 -0400 Subject: [PATCH 18/22] Remove regex when checking current_path --- .../inherited_proofing_cancel_spec.rb | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb index 4896de95787..d3be7768af1 100644 --- a/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb +++ b/spec/features/idv/inherited_proofing/inherited_proofing_cancel_spec.rb @@ -10,11 +10,11 @@ def send_user_from_service_provider_to_login_gov_openid_connect(user) end def complete_idv_steps_up_to_inherited_proofing_get_started_step(user, expect_accessible: false) - unless current_path.match?(/inherited_proofing\/get_started|inherited_proofing\?step=get_started/) + unless current_path == idv_inherited_proofing_step_path(step: :get_started) complete_idv_steps_before_phone_step(user) click_link t('links.cancel') click_button t('idv.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end expect(page).to be_axe_clean.according_to :section508, :"best-practice" if expect_accessible end @@ -22,7 +22,7 @@ def complete_idv_steps_up_to_inherited_proofing_get_started_step(user, expect_ac def complete_idv_steps_up_to_inherited_proofing_how_verifying_step(user, expect_accessible: false) complete_idv_steps_up_to_inherited_proofing_get_started_step user, expect_accessible: expect_accessible - unless current_path.match?(/inherited_proofing\/agreement|inherited_proofing\?step=agreement/) + unless current_path == idv_inherited_proofing_step_path(step: :agreement) click_on t('inherited_proofing.buttons.continue') end end @@ -33,7 +33,7 @@ def complete_idv_steps_up_to_inherited_proofing_we_are_retrieving_step(user, user, expect_accessible: expect_accessible, ) - unless current_path.match?(/inherited_proofing\/verify_wait|inherited_proofing\?step=verify_wait/) + unless current_path == idv_inherited_proofing_step_path(step: :verify_wait) check t('inherited_proofing.instructions.consent', app_name: APP_NAME), allow_label_click: true click_on t('inherited_proofing.buttons.continue') end @@ -64,7 +64,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end it 'should have current path equal to the Getting Started page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*get_started/) + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end context 'when clicking the "Start Over" button from the "Cancel" view' do @@ -75,7 +75,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to the start of the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end end @@ -87,7 +87,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to where the user left off in the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end end @@ -110,7 +110,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end it 'should have current path equal to the How Verifying (agreement step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*agreement/) + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :agreement)) end context 'when clicking the "Start Over" button from the "Cancel" view' do @@ -121,7 +121,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to the start of the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end end @@ -133,7 +133,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to where the user left off in the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/agreement") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :agreement)) end end @@ -156,7 +156,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, end it 'should have current path equal to the Verify your information (verify_info step) page' do - expect(page).to have_current_path(/inherited_proofing[?|\/].*verify_info/) + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :verify_info)) end context 'when clicking the "Start Over" button from the "Cancel" view' do @@ -167,7 +167,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to the start of the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.start_over') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/get_started") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :get_started)) end end @@ -179,7 +179,7 @@ def complete_idv_steps_up_to_inherited_proofing_verify_your_info_step(user, it 'redirects the user back to where the user left off in the Inherited Proofing process' do click_button t('inherited_proofing.cancel.actions.keep_going') - expect(page).to have_current_path("#{idv_inherited_proofing_path}/verify_info") + expect(page).to have_current_path(idv_inherited_proofing_step_path(step: :verify_info)) end end From ad8fe02314418c5f2028f958956f005d2eb1f971 Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 14:25:46 -0400 Subject: [PATCH 19/22] Remove proofing-specific tests --- .../idv/sessions_controller_spec.rb | 147 +++++++----------- 1 file changed, 52 insertions(+), 95 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index be579e5e72d..11853142d84 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -53,124 +53,81 @@ end describe '#destroy' do - let(:idv_session) { double } - let(:flow_session) { {} } - let(:pii) { { first_name: 'Jane' } } - before do allow(idv_session).to receive(:clear) allow(subject).to receive(:idv_session).and_return(idv_session) controller.user_session['idv/doc_auth'] = { idv_doc_auth_session: true } controller.user_session['idv/in_person'] = { idv_in_person_session: true } + controller.user_session['idv/inherited_proofing'] = { idv_idv_inherited_proofing_session: true } controller.user_session[:decrypted_pii] = pii end - context 'when inherited proofing' do - before do - allow(IdentityConfig.store).to receive(:inherited_proofing_enabled).and_return(true) - allow(subject).to receive(:inherited_proofing?).and_return true - end + let(:idv_session) { double } + let(:flow_session) { {} } + let(:pii) { { first_name: 'Jane' } } - context 'when destroying the session' do - before do - controller.user_session['idv/inherited_proofing'] = idv_inherited_proofing_session - expect(idv_session).to receive(:clear) - - delete :destroy - end - - let(:payload_hash) { Idv::InheritedProofing::Va::Mocks::Service::PAYLOAD_HASH } - let(:pii) { Idv::InheritedProofing::Va::Form.new(payload_hash: payload_hash).user_pii } - - let(:idv_inherited_proofing_session) do - { - 'pii_from_user' => { - 'uuid' => '5b7a6a09-840a-4139-b1e2-edee2462f8d2', - }, - 'error_message' => nil, - 'Idv::Steps::InheritedProofing::GetStartedStep' => true, - } - end - - it_behaves_like 'the idv/doc_auth session is cleared' - it_behaves_like 'the idv/in_person session is cleared' - it_behaves_like 'the idv/inherited_proofing session is cleared' - it_behaves_like 'the decrypted_pii session is cleared' + context 'when destroying the session' do + before do + expect(idv_session).to receive(:clear) + delete :destroy end - # In the case of Inherited Proofing (IP) we will redirect to the - # idv_url, which will pass through the IdvController and eventually - # redirect us to the idv_inherited_proofing_url. This is by design - # so that analytics can be logged, throttling and quotes can be - # properly checked; this could not take place if we simply redirected - # to idv_inherited_proofing_url. - it_behaves_like 'a redirect occurs to the start of identity verification' - it_behaves_like 'logs IDV start over analytics with step and location params' + it_behaves_like 'the idv/doc_auth session is cleared' + it_behaves_like 'the idv/in_person session is cleared' + it_behaves_like 'the idv/inherited_proofing session is cleared' + it_behaves_like 'the decrypted_pii session is cleared' end - context 'when idv proofing' do - context 'when destroying the session' do - before do - expect(idv_session).to receive(:clear) - delete :destroy - end + it_behaves_like 'logs IDV start over analytics with step and location params' + it_behaves_like 'a redirect occurs to the start of identity verification' - it_behaves_like 'the idv/doc_auth session is cleared' - it_behaves_like 'the idv/in_person session is cleared' - it_behaves_like 'the decrypted_pii session is cleared' + context 'pending profile' do + let(:user) do + create( + :user, + profiles: [create(:profile, deactivation_reason: :gpo_verification_pending)], + ) end - it_behaves_like 'logs IDV start over analytics with step and location params' - it_behaves_like 'a redirect occurs to the start of identity verification' - - context 'pending profile' do - let(:user) do - create( - :user, - profiles: [create(:profile, deactivation_reason: :gpo_verification_pending)], - ) - end - - it 'cancels verification attempt' do - cancel = double - expect(Idv::CancelVerificationAttempt).to receive(:new).and_return(cancel) - expect(cancel).to receive(:call) - - delete :destroy, params: { step: 'gpo_verify', location: 'clear_and_start_over' } - expect(@analytics).to have_logged_event( - 'IdV: start over', - step: 'gpo_verify', - location: 'clear_and_start_over', - ) - end + it 'cancels verification attempt' do + cancel = double + expect(Idv::CancelVerificationAttempt).to receive(:new).and_return(cancel) + expect(cancel).to receive(:call) + + delete :destroy, params: { step: 'gpo_verify', location: 'clear_and_start_over' } + expect(@analytics).to have_logged_event( + 'IdV: start over', + step: 'gpo_verify', + location: 'clear_and_start_over', + ) end + end - context 'with in person enrollment' do - let(:user) { build(:user, :with_pending_in_person_enrollment) } + context 'with in person enrollment' do + let(:user) { build(:user, :with_pending_in_person_enrollment) } - before do - allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) - end + before do + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end - it 'cancels pending in person enrollment' do - pending_enrollment = user.pending_in_person_enrollment - expect(user.reload.pending_in_person_enrollment).to_not be_blank - delete :destroy + it 'cancels pending in person enrollment' do + pending_enrollment = user.pending_in_person_enrollment + expect(user.reload.pending_in_person_enrollment).to_not be_blank + delete :destroy - pending_enrollment.reload - expect(pending_enrollment.status).to eq('cancelled') - expect(user.reload.pending_in_person_enrollment).to be_blank - end + pending_enrollment.reload + expect(pending_enrollment.status).to eq('cancelled') + expect(user.reload.pending_in_person_enrollment).to be_blank + end - it 'cancels establishing in person enrollment' do - establishing_enrollment = create(:in_person_enrollment, :establishing, user: user) - expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(1) - delete :destroy + it 'cancels establishing in person enrollment' do + establishing_enrollment = create(:in_person_enrollment, :establishing, user: user) + expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(1) + delete :destroy - establishing_enrollment.reload - expect(establishing_enrollment.status).to eq('cancelled') - expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(0) - end + establishing_enrollment.reload + expect(establishing_enrollment.status).to eq('cancelled') + expect(InPersonEnrollment.where(user: user, status: :establishing).count).to eq(0) end end end From cc8ec240bbf125072f1cf3417c6d3dd49104ad84 Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 14:47:12 -0400 Subject: [PATCH 20/22] Fix rubocop errors --- spec/controllers/idv/sessions_controller_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 11853142d84..15431316d09 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -58,7 +58,8 @@ allow(subject).to receive(:idv_session).and_return(idv_session) controller.user_session['idv/doc_auth'] = { idv_doc_auth_session: true } controller.user_session['idv/in_person'] = { idv_in_person_session: true } - controller.user_session['idv/inherited_proofing'] = { idv_idv_inherited_proofing_session: true } + controller.user_session['idv/inherited_proofing'] = + { idv_idv_inherited_proofing_session: true } controller.user_session[:decrypted_pii] = pii end From 33a3425a56e534e184765176d046d6fc92e32b6a Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 14:55:13 -0400 Subject: [PATCH 21/22] Move tests inline --- .../idv/sessions_controller_spec.rb | 80 +++++++------------ 1 file changed, 30 insertions(+), 50 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index 15431316d09..e5676d77c89 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -1,49 +1,5 @@ require 'rails_helper' -shared_examples 'the idv/doc_auth session is cleared' do - it 'clears the session' do - expect(controller.user_session['idv/doc_auth']).to be_blank - end -end - -shared_examples 'the idv/in_person session is cleared' do - it 'clears the session' do - expect(controller.user_session['idv/in_person']).to be_blank - end -end - -shared_examples 'the idv/inherited_proofing session is cleared' do - it 'clears the session' do - expect(controller.user_session['idv/inherited_proofing']).to be_blank - end -end - -shared_examples 'the decrypted_pii session is cleared' do - it 'clears the session' do - expect(controller.user_session[:decrypted_pii]).to be_blank - end -end - -shared_examples 'a redirect occurs to the start of identity verification' do - it 'redirects' do - delete :destroy - - expect(response).to redirect_to(idv_url) - end -end - -shared_examples 'logs IDV start over analytics with step and location params' do - it 'logs the analytics' do - delete :destroy, params: { step: 'first', location: 'get_help' } - - expect(@analytics).to have_logged_event( - 'IdV: start over', - step: 'first', - location: 'get_help', - ) - end -end - describe Idv::SessionsController do let(:user) { build(:user) } @@ -73,14 +29,38 @@ delete :destroy end - it_behaves_like 'the idv/doc_auth session is cleared' - it_behaves_like 'the idv/in_person session is cleared' - it_behaves_like 'the idv/inherited_proofing session is cleared' - it_behaves_like 'the decrypted_pii session is cleared' + it 'clears the idv/doc_auth session' do + expect(controller.user_session['idv/doc_auth']).to be_blank + end + + it 'clears the idv/in_person session' do + expect(controller.user_session['idv/in_person']).to be_blank + end + + it 'clears the idv/inherited_proofing session' do + expect(controller.user_session['idv/inherited_proofing']).to be_blank + end + + it 'clears the decrypted_pii session' do + expect(controller.user_session[:decrypted_pii]).to be_blank + end + end + + it 'logs IDV start over analytics with step and location params' do + delete :destroy, params: { step: 'first', location: 'get_help' } + + expect(@analytics).to have_logged_event( + 'IdV: start over', + step: 'first', + location: 'get_help', + ) end - it_behaves_like 'logs IDV start over analytics with step and location params' - it_behaves_like 'a redirect occurs to the start of identity verification' + it 'redirect occurs to the start of identity verification' do + delete :destroy + + expect(response).to redirect_to(idv_url) + end context 'pending profile' do let(:user) do From 31fee6bc003d974a2a19dcc844c37c5afed92628 Mon Sep 17 00:00:00 2001 From: gangelo Date: Fri, 4 Nov 2022 16:08:22 -0400 Subject: [PATCH 22/22] Tidy up session mock --- spec/controllers/idv/sessions_controller_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index e5676d77c89..224c33c332f 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -12,15 +12,14 @@ before do allow(idv_session).to receive(:clear) allow(subject).to receive(:idv_session).and_return(idv_session) - controller.user_session['idv/doc_auth'] = { idv_doc_auth_session: true } - controller.user_session['idv/in_person'] = { idv_in_person_session: true } - controller.user_session['idv/inherited_proofing'] = - { idv_idv_inherited_proofing_session: true } + controller.user_session['idv/doc_auth'] = flow_session + controller.user_session['idv/in_person'] = flow_session + controller.user_session['idv/inherited_proofing'] = flow_session controller.user_session[:decrypted_pii] = pii end let(:idv_session) { double } - let(:flow_session) { {} } + let(:flow_session) { { x: {} } } let(:pii) { { first_name: 'Jane' } } context 'when destroying the session' do