diff --git a/app/controllers/idv/doc_auth_controller.rb b/app/controllers/idv/doc_auth_controller.rb index 45a937fc904..8dc73cea4f1 100644 --- a/app/controllers/idv/doc_auth_controller.rb +++ b/app/controllers/idv/doc_auth_controller.rb @@ -3,6 +3,7 @@ class DocAuthController < ApplicationController before_action :confirm_two_factor_authenticated before_action :redirect_if_mail_bounced before_action :redirect_if_pending_profile + before_action :redirect_if_pending_in_person_enrollment before_action :extend_timeout_using_meta_refresh_for_select_paths include IdvSession # remove if we retire the non docauth LOA3 flow @@ -36,6 +37,11 @@ def redirect_if_pending_profile redirect_to idv_gpo_verify_url if current_user.decorate.pending_profile_requires_verification? end + def redirect_if_pending_in_person_enrollment + return if !IdentityConfig.store.in_person_proofing_enabled + redirect_to idv_in_person_ready_to_verify_url if current_user.pending_in_person_enrollment + end + def update_if_skipping_upload return if params[:step] != 'upload' || !flow_session || !flow_session[:skip_upload_step] track_step_visited diff --git a/app/controllers/idv/gpo_verify_controller.rb b/app/controllers/idv/gpo_verify_controller.rb index 94fa42750c5..232fc432a75 100644 --- a/app/controllers/idv/gpo_verify_controller.rb +++ b/app/controllers/idv/gpo_verify_controller.rb @@ -36,8 +36,12 @@ def create sp_name: decorated_session.sp_name, disavowal_token: event.disavowal_token, ) - flash[:success] = t('account.index.verification.success') - redirect_to sign_up_completed_url + if result.extra[:pending_in_person_enrollment] + redirect_to idv_in_person_ready_to_verify_url + else + flash[:success] = t('account.index.verification.success') + redirect_to sign_up_completed_url + end else flash[:error] = @gpo_verify_form.errors.first.message redirect_to idv_gpo_verify_url diff --git a/app/controllers/idv/sessions_controller.rb b/app/controllers/idv/sessions_controller.rb index 821d62d7566..529416729e4 100644 --- a/app/controllers/idv/sessions_controller.rb +++ b/app/controllers/idv/sessions_controller.rb @@ -6,6 +6,7 @@ class SessionsController < ApplicationController 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], @@ -19,10 +20,15 @@ def destroy private def cancel_verification_attempt_if_pending_profile - return if current_user.profiles.verification_pending.blank? + return if current_user.profiles.gpo_verification_pending.blank? Idv::CancelVerificationAttempt.new(user: current_user).call end + def cancel_in_person_enrollment_if_exists + return if !IdentityConfig.store.in_person_proofing_enabled + current_user.pending_in_person_enrollment&.update(status: :cancelled) + end + def location_params params.permit(:step, :location).to_h.symbolize_keys end diff --git a/app/forms/api/profile_creation_form.rb b/app/forms/api/profile_creation_form.rb index 9a84ceb3dd4..14e20630e8a 100644 --- a/app/forms/api/profile_creation_form.rb +++ b/app/forms/api/profile_creation_form.rb @@ -52,8 +52,21 @@ def cache_encrypted_pii end def complete_session - complete_profile if phone_confirmed? - create_gpo_entry if user_bundle.gpo_address_verification? + if user_bundle.gpo_address_verification? + profile.deactivate(:gpo_verification_pending) + create_gpo_entry + elsif phone_confirmed? + if pending_in_person_enrollment? + profile.deactivate(:in_person_verification_pending) + else + complete_profile + end + end + end + + def pending_in_person_enrollment? + return false unless IdentityConfig.store.in_person_proofing_enabled + ProofingComponent.find_by(user: user)&.document_check == Idp::Constants::Vendors::USPS end def phone_confirmed? @@ -61,7 +74,7 @@ def phone_confirmed? end def complete_profile - user.pending_profile&.activate + profile.activate move_pii_to_user_session end @@ -127,7 +140,7 @@ def form_valid? def extra_attributes if user.present? @extra_attributes ||= { - profile_pending: user.pending_profile?, + profile_pending: user_bundle.gpo_address_verification?, user_uuid: user.uuid, } else diff --git a/app/forms/gpo_verify_form.rb b/app/forms/gpo_verify_form.rb index e5ca6a4a894..9e1b55f29bc 100644 --- a/app/forms/gpo_verify_form.rb +++ b/app/forms/gpo_verify_form.rb @@ -17,7 +17,11 @@ def initialize(user:, otp: nil) def submit result = valid? if result - activate_profile + if pending_in_person_enrollment? + user.pending_profile&.deactivate(:in_person_verification_pending) + else + activate_profile + end else reset_sensitive_fields end @@ -26,6 +30,7 @@ def submit errors: errors, extra: { pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], + pending_in_person_enrollment: pending_in_person_enrollment?, }, ) end @@ -65,6 +70,11 @@ def reset_sensitive_fields self.otp = nil end + def pending_in_person_enrollment? + return false unless IdentityConfig.store.in_person_proofing_enabled + user.pending_in_person_enrollment.present? + end + def activate_profile user.pending_profile&.activate end diff --git a/app/models/in_person_enrollment.rb b/app/models/in_person_enrollment.rb index df33c0c161f..8c52cfec503 100644 --- a/app/models/in_person_enrollment.rb +++ b/app/models/in_person_enrollment.rb @@ -9,7 +9,7 @@ class InPersonEnrollment < ApplicationRecord passed: 2, failed: 3, expired: 4, - canceled: 5, + cancelled: 5, } validate :profile_belongs_to_user diff --git a/app/models/profile.rb b/app/models/profile.rb index 9ee54bc5cbe..8465f997a65 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -13,8 +13,9 @@ class Profile < ApplicationRecord enum deactivation_reason: { password_reset: 1, encryption_error: 2, - verification_pending: 3, + gpo_verification_pending: 3, verification_cancelled: 4, + in_person_verification_pending: 5, } attr_reader :personal_key diff --git a/app/models/user.rb b/app/models/user.rb index 56277bd34d5..11df6019bb0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -92,7 +92,7 @@ def pending_profile? end def pending_profile - profiles.verification_pending.order(created_at: :desc).first + profiles.gpo_verification_pending.order(created_at: :desc).first end def default_phone_configuration diff --git a/app/services/idv/cancel_verification_attempt.rb b/app/services/idv/cancel_verification_attempt.rb index e9d760bb2a5..8df5c4210fe 100644 --- a/app/services/idv/cancel_verification_attempt.rb +++ b/app/services/idv/cancel_verification_attempt.rb @@ -7,7 +7,7 @@ def initialize(user:) end def call - user.profiles.verification_pending.each do |profile| + user.profiles.gpo_verification_pending.each do |profile| profile.update!( active: false, deactivation_reason: :verification_cancelled, diff --git a/app/services/idv/profile_maker.rb b/app/services/idv/profile_maker.rb index 1c93d0a7170..70e780b58ce 100644 --- a/app/services/idv/profile_maker.rb +++ b/app/services/idv/profile_maker.rb @@ -9,10 +9,7 @@ def initialize(applicant:, user:, user_password:) end def save_profile - profile = Profile.new( - deactivation_reason: :verification_pending, - user: user, - ) + profile = Profile.new(user: user, active: false) profile.encrypt_pii(pii_attributes, user_password) profile.proofing_components = current_proofing_components profile.save! diff --git a/app/services/idv/session.rb b/app/services/idv/session.rb index 31220460131..ffdb8d19b01 100644 --- a/app/services/idv/session.rb +++ b/app/services/idv/session.rb @@ -72,17 +72,30 @@ def clear user_session.delete(:idv) end + def pending_in_person_enrollment? + return false unless IdentityConfig.store.in_person_proofing_enabled + ProofingComponent.find_by(user: current_user)&.document_check == Idp::Constants::Vendors::USPS + end + def phone_confirmed? vendor_phone_confirmation == true && user_phone_confirmation == true end def complete_session - complete_profile if phone_confirmed? - create_gpo_entry if address_verification_mechanism == 'gpo' + if address_verification_mechanism == 'gpo' + profile.deactivate(:gpo_verification_pending) + create_gpo_entry + elsif phone_confirmed? + if pending_in_person_enrollment? + profile.deactivate(:in_person_verification_pending) + else + complete_profile + end + end end def complete_profile - current_user.pending_profile&.activate + profile.activate move_pii_to_user_session end diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index 7bbc6ba4160..ff263a19a8c 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -63,7 +63,7 @@ user = create( :user, :signed_up, - profiles: [build(:profile, deactivation_reason: :verification_pending)], + profiles: [build(:profile, deactivation_reason: :gpo_verification_pending)], ) sign_in user diff --git a/spec/controllers/api/verify/password_confirm_controller_spec.rb b/spec/controllers/api/verify/password_confirm_controller_spec.rb index 8b235e1e3b4..09649f16db7 100644 --- a/spec/controllers/api/verify/password_confirm_controller_spec.rb +++ b/spec/controllers/api/verify/password_confirm_controller_spec.rb @@ -146,7 +146,13 @@ def stub_idv_session end context 'with pending profile' do - let(:jwt_metadata) { { vendor_phone_confirmation: false, user_phone_confirmation: false } } + let(:jwt_metadata) do + { + vendor_phone_confirmation: false, + user_phone_confirmation: false, + address_verification_mechanism: 'gpo', + } + end it 'creates a profile and returns completion url' do post :create, params: { password: password, user_bundle_token: jwt } diff --git a/spec/controllers/idv/gpo_verify_controller_spec.rb b/spec/controllers/idv/gpo_verify_controller_spec.rb index 7aefd6ae7c6..2cdd7a1f61d 100644 --- a/spec/controllers/idv/gpo_verify_controller_spec.rb +++ b/spec/controllers/idv/gpo_verify_controller_spec.rb @@ -96,6 +96,7 @@ 'IdV: GPO verification submitted', success: true, errors: {}, + pending_in_person_enrollment: false, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ) @@ -106,6 +107,28 @@ expect(disavowal_event_count).to eq 1 expect(response).to redirect_to(sign_up_completed_url) end + + context 'with pending in person enrollment' do + let(:user) { create(:user, :with_pending_in_person_enrollment) } + + before do + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'redirects to ready to verify screen' do + expect(@analytics).to receive(:track_event).with( + 'IdV: GPO verification submitted', + success: true, + errors: {}, + pending_in_person_enrollment: true, + pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], + ) + + action + + expect(response).to redirect_to(idv_in_person_ready_to_verify_url) + end + end end context 'with an invalid form' do @@ -116,6 +139,7 @@ 'IdV: GPO verification submitted', success: false, errors: { otp: [t('errors.messages.confirmation_code_incorrect')] }, + pending_in_person_enrollment: false, error_details: { otp: [:confirmation_code_incorrect] }, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ) @@ -142,6 +166,7 @@ 'IdV: GPO verification submitted', success: false, errors: { otp: [t('errors.messages.confirmation_code_incorrect')] }, + pending_in_person_enrollment: false, error_details: { otp: [:confirmation_code_incorrect] }, pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]], ).exactly(max_attempts).times diff --git a/spec/controllers/idv/sessions_controller_spec.rb b/spec/controllers/idv/sessions_controller_spec.rb index f4a5fc265fe..d4a5b1108ff 100644 --- a/spec/controllers/idv/sessions_controller_spec.rb +++ b/spec/controllers/idv/sessions_controller_spec.rb @@ -49,7 +49,7 @@ let(:user) do create( :user, - profiles: [create(:profile, deactivation_reason: :verification_pending)], + profiles: [create(:profile, deactivation_reason: :gpo_verification_pending)], ) end diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index c77f2240f8f..daed6dd85da 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -316,7 +316,7 @@ user = create(:user, :signed_up) create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, user: user, pii: { ssn: '1234' } ) @@ -564,7 +564,7 @@ it 'redirects to the verify profile page' do profile = create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, pii: { ssn: '6666', dob: '1920-01-01' }, ) user = profile.user diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index bab09da2b80..1fb31bf49f5 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -95,9 +95,18 @@ expect(page).to have_content(t('in_person_proofing.headings.barcode')) expect(page).to have_content(Idv::InPerson::EnrollmentCodeFormatter.format(enrollment_code)) expect(page).to have_content(t('in_person_proofing.body.barcode.deadline', deadline: deadline)) + + # signing in again before completing in-person proofing at a post office + sign_in_and_2fa_user(user) + complete_doc_auth_steps_before_welcome_step + expect(page).to have_current_path(idv_in_person_ready_to_verify_path) end context 'verify address by mail (GPO letter)' do + before do + allow(FeatureManagement).to receive(:reveal_gpo_code?).and_return(true) + end + it 'requires address verification before showing instructions', allow_browser_log: true do begin_in_person_proofing complete_all_in_person_proofing_steps @@ -109,7 +118,28 @@ expect(page).to have_content(t('idv.titles.come_back_later')) expect(page).to have_current_path(idv_come_back_later_path) - # WILLFIX: After LG-6897, assert that "Ready to Verify" content is shown after code entry. + click_idv_continue + expect(page).to have_current_path(account_path) + expect(page).not_to have_content(t('headings.account.verified_account')) + click_on t('account.index.verification.reactivate_button') + click_button t('forms.verify_profile.submit') + + expect(page).to have_current_path(idv_in_person_ready_to_verify_path) + expect(page).not_to have_content(t('account.index.verification.success')) + end + + it 'lets the user clear and start over from gpo confirmation', allow_browser_log: true do + begin_in_person_proofing + complete_all_in_person_proofing_steps + click_on t('idv.troubleshooting.options.verify_by_mail') + click_on t('idv.buttons.mail.send') + complete_review_step + acknowledge_and_confirm_personal_key + click_idv_continue + click_on t('account.index.verification.reactivate_button') + click_on t('idv.messages.clear_and_start_over') + + expect(page).to have_current_path(idv_doc_auth_welcome_step) end end end diff --git a/spec/features/idv/steps/gpo_step_spec.rb b/spec/features/idv/steps/gpo_step_spec.rb index a57e024c93c..6e061cc639c 100644 --- a/spec/features/idv/steps/gpo_step_spec.rb +++ b/spec/features/idv/steps/gpo_step_spec.rb @@ -64,7 +64,7 @@ def expect_user_to_be_unverified(user) profile = user.profiles.first expect(profile.active?).to eq false - expect(profile.deactivation_reason).to eq 'verification_pending' + expect(profile.deactivation_reason).to eq 'gpo_verification_pending' end end end diff --git a/spec/features/idv/strict_ial2/usps_upload_disallowed_spec.rb b/spec/features/idv/strict_ial2/usps_upload_disallowed_spec.rb index 60f8137e511..a8adef0377d 100644 --- a/spec/features/idv/strict_ial2/usps_upload_disallowed_spec.rb +++ b/spec/features/idv/strict_ial2/usps_upload_disallowed_spec.rb @@ -51,7 +51,7 @@ it 'does not prompt a pending user for a mailed code' do user = create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, pii: { first_name: 'John', ssn: '111223333' }, ).user diff --git a/spec/features/saml/ial2_sso_spec.rb b/spec/features/saml/ial2_sso_spec.rb index bc925fb60bf..830bfbbe9b2 100644 --- a/spec/features/saml/ial2_sso_spec.rb +++ b/spec/features/saml/ial2_sso_spec.rb @@ -85,7 +85,7 @@ def sign_out_user let(:profile) do create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, pii: { ssn: '6666', dob: '1920-01-01' }, ) end diff --git a/spec/features/users/verify_profile_spec.rb b/spec/features/users/verify_profile_spec.rb index 0b246e23abb..a979c0f966b 100644 --- a/spec/features/users/verify_profile_spec.rb +++ b/spec/features/users/verify_profile_spec.rb @@ -7,7 +7,7 @@ before do profile = create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, pii: { ssn: '666-66-1234', dob: '1920-01-01', phone: '+1 703-555-9999' }, user: user, ) diff --git a/spec/forms/api/profile_creation_form_spec.rb b/spec/forms/api/profile_creation_form_spec.rb index bc351f67790..c1bb8f03c80 100644 --- a/spec/forms/api/profile_creation_form_spec.rb +++ b/spec/forms/api/profile_creation_form_spec.rb @@ -78,6 +78,21 @@ expect(stored_pii['first_name']).to eq 'Ada' end + + context 'with pending in person enrollment' do + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'sets profile to pending in person verification' do + subject.submit + profile = user.profiles.first + + expect(profile.active?).to be false + expect(profile.deactivation_reason).to eq('in_person_verification_pending') + end + end end context 'with the user having verified their address via GPO letter' do @@ -92,6 +107,7 @@ profile = user.profiles.first expect(profile.active?).to be false + expect(profile.deactivation_reason).to eq('gpo_verification_pending') end it 'moves the pii to the user_session' do @@ -121,6 +137,21 @@ expect(subject.gpo_code).to eq(gpo_code) end end + + context 'with pending in person enrollment' do + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'does not activate the user profile' do + subject.submit + profile = user.profiles.first + + expect(profile.active?).to be false + expect(profile.deactivation_reason).to eq('gpo_verification_pending') + end + end end end diff --git a/spec/forms/gpo_verify_form_spec.rb b/spec/forms/gpo_verify_form_spec.rb index 2032ba1cd8a..722f06e1293 100644 --- a/spec/forms/gpo_verify_form_spec.rb +++ b/spec/forms/gpo_verify_form_spec.rb @@ -9,7 +9,7 @@ let(:entered_otp) { otp } let(:otp) { 'ABC123' } let(:code_sent_at) { Time.zone.now } - let(:pending_profile) { create(:profile, deactivation_reason: :verification_pending) } + let(:pending_profile) { create(:profile, deactivation_reason: :gpo_verification_pending) } before do next if pending_profile.blank? @@ -101,6 +101,21 @@ expect(pending_profile.reload).to be_active end + + context 'pending in person enrollment' do + before do + create(:in_person_enrollment, :pending, user: user, profile: pending_profile) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + end + + it 'sets profile to pending in person verification' do + subject.submit + pending_profile.reload + + expect(pending_profile).not_to be_active + expect(pending_profile.deactivation_reason).to eq('in_person_verification_pending') + end + end end context 'incorrect OTP' do diff --git a/spec/models/in_person_enrollment_spec.rb b/spec/models/in_person_enrollment_spec.rb index 25e78b231c7..df0298f09f9 100644 --- a/spec/models/in_person_enrollment_spec.rb +++ b/spec/models/in_person_enrollment_spec.rb @@ -9,7 +9,7 @@ describe 'Status' do it 'defines enum correctly' do should define_enum_for(:status). - with_values([:establishing, :pending, :passed, :failed, :expired, :canceled]) + with_values([:establishing, :pending, :passed, :failed, :expired, :cancelled]) end end @@ -17,7 +17,7 @@ it 'requires the profile to be associated with the user' do user1 = create(:user) user2 = create(:user) - profile2 = create(:profile, :verification_pending, user: user2) + profile2 = create(:profile, :gpo_verification_pending, user: user2) expect { create(:in_person_enrollment, user: user1, profile: profile2) }. to raise_error ActiveRecord::RecordInvalid expect(InPersonEnrollment.count).to eq 0 @@ -25,8 +25,8 @@ it 'does not allow more than one pending enrollment per user' do user = create(:user) - profile = create(:profile, :verification_pending, user: user) - profile2 = create(:profile, :verification_pending, user: user) + profile = create(:profile, :gpo_verification_pending, user: user) + profile2 = create(:profile, :gpo_verification_pending, user: user) create(:in_person_enrollment, user: user, profile: profile, status: :pending) expect(InPersonEnrollment.pending.count).to eq 1 expect { create(:in_person_enrollment, user: user, profile: profile2, status: :pending) }. @@ -36,7 +36,7 @@ it 'does not allow duplicate unique ids' do user = create(:user) - profile = create(:profile, :verification_pending, user: user) + profile = create(:profile, :gpo_verification_pending, user: user) unique_id = InPersonEnrollment.generate_unique_id create(:in_person_enrollment, user: user, profile: profile, unique_id: unique_id) expect { create(:in_person_enrollment, user: user, profile: profile, unique_id: unique_id) }. @@ -49,13 +49,13 @@ expect { InPersonEnrollment.statuses.each do |key,| status = InPersonEnrollment.statuses[key] - profile = create(:profile, :verification_pending, user: user) + profile = create(:profile, :gpo_verification_pending, user: user) create(:in_person_enrollment, user: user, profile: profile, status: status) end InPersonEnrollment.statuses.each do |key,| status = InPersonEnrollment.statuses[key] if status != InPersonEnrollment.statuses[:pending] - profile = create(:profile, :verification_pending, user: user) + profile = create(:profile, :gpo_verification_pending, user: user) create(:in_person_enrollment, user: user, profile: profile, status: status) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index aa0dc753537..98c37c38449 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -197,7 +197,7 @@ create(:profile, :verification_cancelled, user: user, pii: { first_name: 'Jane' }) } let(:profile2) { - create(:profile, :verification_pending, user: user, pii: { first_name: 'Susan' }) + create(:profile, :gpo_verification_pending, user: user, pii: { first_name: 'Susan' }) } let!(:enrollment1) { create(:in_person_enrollment, :failed, user: user, profile: profile1) } @@ -425,18 +425,18 @@ end describe '#pending_profile' do - context 'when a profile with a verification_pending deactivation_reason exists' do + context 'when a profile with a gpo_verification_pending deactivation_reason exists' do it 'returns the most recent profile' do user = User.new _old_profile = create( :profile, - :verification_pending, + :gpo_verification_pending, created_at: 1.day.ago, user: user, ) new_profile = create( :profile, - :verification_pending, + :gpo_verification_pending, user: user, ) @@ -444,7 +444,7 @@ end end - context 'when a verification_pending profile does not exist' do + context 'when a gpo_verification_pending profile does not exist' do it 'returns nil' do user = User.new create( diff --git a/spec/presenters/idv/gpo_presenter_spec.rb b/spec/presenters/idv/gpo_presenter_spec.rb index e9015aa25e4..fcafc1ea2d4 100644 --- a/spec/presenters/idv/gpo_presenter_spec.rb +++ b/spec/presenters/idv/gpo_presenter_spec.rb @@ -49,7 +49,7 @@ describe '#fallback_back_path' do context 'when the user has a pending profile' do it 'returns the verify account path' do - create(:profile, user: user, deactivation_reason: :verification_pending) + create(:profile, user: user, deactivation_reason: :gpo_verification_pending) expect(subject.fallback_back_path).to eq('/account/verify') end end diff --git a/spec/services/idv/cancel_verification_attempt_spec.rb b/spec/services/idv/cancel_verification_attempt_spec.rb index 3cfa7262a00..848c820f4ae 100644 --- a/spec/services/idv/cancel_verification_attempt_spec.rb +++ b/spec/services/idv/cancel_verification_attempt_spec.rb @@ -2,7 +2,7 @@ describe Idv::CancelVerificationAttempt do let(:user) { create(:user, profiles: profiles) } - let(:profiles) { [create(:profile, deactivation_reason: :verification_pending)] } + let(:profiles) { [create(:profile, deactivation_reason: :gpo_verification_pending)] } subject { described_class.new(user: user) } @@ -12,13 +12,13 @@ expect(profiles[0].active).to eq(false) expect(profiles[0].reload.deactivation_reason).to eq('verification_cancelled') - expect(user.reload.profiles.verification_pending).to be_empty + expect(user.reload.profiles.gpo_verification_pending).to be_empty end end context 'the user has multiple pending profiles' do let(:profiles) do - super().push(create(:profile, deactivation_reason: :verification_pending)) + super().push(create(:profile, deactivation_reason: :gpo_verification_pending)) end it 'deactivates both profiles' do @@ -28,7 +28,7 @@ expect(profiles[0].reload.deactivation_reason).to eq('verification_cancelled') expect(profiles[1].active).to eq(false) expect(profiles[1].reload.deactivation_reason).to eq('verification_cancelled') - expect(user.reload.profiles.verification_pending).to be_empty + expect(user.reload.profiles.gpo_verification_pending).to be_empty end end @@ -44,20 +44,20 @@ expect(profiles[0].reload.deactivation_reason).to eq('verification_cancelled') expect(profiles[1].active).to eq(true) expect(profiles[1].reload.deactivation_reason).to be_nil - expect(user.reload.profiles.verification_pending).to be_empty + expect(user.reload.profiles.gpo_verification_pending).to be_empty end end context 'when there are pending profiles for other users' do it 'only updates profiles for the specificed user' do - other_profile = create(:profile, deactivation_reason: :verification_pending) + other_profile = create(:profile, deactivation_reason: :gpo_verification_pending) subject.call expect(profiles[0].active).to eq(false) expect(profiles[0].reload.deactivation_reason).to eq('verification_cancelled') expect(other_profile.active).to eq(false) - expect(other_profile.reload.deactivation_reason).to eq('verification_pending') + expect(other_profile.reload.deactivation_reason).to eq('gpo_verification_pending') end end end diff --git a/spec/services/idv/profile_maker_spec.rb b/spec/services/idv/profile_maker_spec.rb index 5fb57840654..f996ad8c2bc 100644 --- a/spec/services/idv/profile_maker_spec.rb +++ b/spec/services/idv/profile_maker_spec.rb @@ -13,7 +13,8 @@ user_password: user_password, ) end - it 'creates a Profile with encrypted PII' do + + it 'creates an inactive Profile with encrypted PII' do proofing_component = ProofingComponent.create(user_id: user.id, document_check: 'acuant') profile = subject.save_profile pii = subject.pii_attributes @@ -23,6 +24,8 @@ expect(profile.encrypted_pii).to_not be_nil expect(profile.encrypted_pii).to_not match 'Some' expect(profile.proofing_components).to match proofing_component.as_json + expect(profile.active).to eq false + expect(profile.deactivation_reason).to be_nil expect(pii).to be_a Pii::Attributes expect(pii.first_name).to eq 'Some' diff --git a/spec/services/idv/session_spec.rb b/spec/services/idv/session_spec.rb index f39d7cd3c20..1239df66dce 100644 --- a/spec/services/idv/session_spec.rb +++ b/spec/services/idv/session_spec.rb @@ -39,7 +39,7 @@ describe '#complete_session' do context 'with phone verifed by vendor' do before do - subject.address_verification_mechanism = :phone + subject.address_verification_mechanism = 'phone' subject.vendor_phone_confirmation = true allow(subject).to receive(:complete_profile) end @@ -57,11 +57,47 @@ expect(subject).not_to have_received(:complete_profile) end + + context 'with pending in person enrollment' do + let(:user) { create(:user, :with_pending_in_person_enrollment) } + + before do + ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS) + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + subject.user_phone_confirmation = true + end + + it 'sets profile to pending in person verification' do + subject.applicant = {} + subject.create_profile_from_applicant_with_password(user.password) + subject.complete_session + + expect(subject).not_to have_received(:complete_profile) + expect(subject.profile.deactivation_reason).to eq('in_person_verification_pending') + end + end + end + + context 'with gpo address verification' do + before do + subject.address_verification_mechanism = 'gpo' + subject.vendor_phone_confirmation = false + allow(subject).to receive(:complete_profile) + end + + it 'sets profile to pending gpo verification' do + subject.applicant = {} + subject.create_profile_from_applicant_with_password(user.password) + subject.complete_session + + expect(subject).not_to have_received(:complete_profile) + expect(subject.profile.deactivation_reason).to eq('gpo_verification_pending') + end end context 'without a confirmed phone number' do before do - subject.address_verification_mechanism = :phone + subject.address_verification_mechanism = 'phone' subject.vendor_phone_confirmation = false end diff --git a/spec/support/features/interaction_helper.rb b/spec/support/features/interaction_helper.rb index c6d57ade971..efc8ccf0a95 100644 --- a/spec/support/features/interaction_helper.rb +++ b/spec/support/features/interaction_helper.rb @@ -1,6 +1,6 @@ module InteractionHelper def click_spinner_button_and_wait(...) - click_button(...) + click_on(...) expect(page).to have_no_css('lg-spinner-button.spinner-button--spinner-active', wait: 10) end end diff --git a/spec/support/idv_examples/gpo_otp_verification_step.rb b/spec/support/idv_examples/gpo_otp_verification_step.rb index 12bdfb4e431..f2a6a8f1485 100644 --- a/spec/support/idv_examples/gpo_otp_verification_step.rb +++ b/spec/support/idv_examples/gpo_otp_verification_step.rb @@ -3,7 +3,7 @@ let(:profile) do create( :profile, - deactivation_reason: :verification_pending, + deactivation_reason: :gpo_verification_pending, pii: { ssn: '123-45-6789', dob: '1970-01-01' }, ) end