diff --git a/app/controllers/sign_up/completions_controller.rb b/app/controllers/sign_up/completions_controller.rb index f2a9e2c9cb8..94eacd36a13 100644 --- a/app/controllers/sign_up/completions_controller.rb +++ b/app/controllers/sign_up/completions_controller.rb @@ -123,6 +123,7 @@ def pii end def send_in_person_completion_survey + return unless IdentityConfig.store.in_person_completion_survey_delivery_enabled return unless resolved_authn_context_result.identity_proofing? Idv::InPerson::CompletionSurveySender.send_completion_survey( diff --git a/config/application.yml.default b/config/application.yml.default index 4c95ae8166a..f1fa72c404a 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -172,6 +172,7 @@ idv_socure_reason_code_download_enabled: false idv_socure_shadow_mode_enabled: false idv_socure_shadow_mode_enabled_for_docv_users: true idv_sp_required: false +in_person_completion_survey_delivery_enabled: false in_person_completion_survey_url: 'https://login.gov' in_person_doc_auth_button_enabled: true in_person_eipp_enrollment_validity_in_days: 7 diff --git a/lib/identity_config.rb b/lib/identity_config.rb index 58b89a7d4c5..326b45845e3 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -198,6 +198,7 @@ def self.store config.add(:idv_socure_shadow_mode_enabled, type: :boolean) config.add(:idv_socure_shadow_mode_enabled_for_docv_users, type: :boolean) config.add(:idv_sp_required, type: :boolean) + config.add(:in_person_completion_survey_delivery_enabled, type: :boolean) config.add(:in_person_completion_survey_url, type: :string) config.add(:in_person_doc_auth_button_enabled, type: :boolean) config.add(:in_person_eipp_enrollment_validity_in_days, type: :integer) diff --git a/spec/controllers/sign_up/completions_controller_spec.rb b/spec/controllers/sign_up/completions_controller_spec.rb index 051072162ba..a598df3375a 100644 --- a/spec/controllers/sign_up/completions_controller_spec.rb +++ b/spec/controllers/sign_up/completions_controller_spec.rb @@ -355,26 +355,137 @@ end end - it 'sends the in-person proofing completion survey' do - user = create(:user, profiles: [create(:profile, :verified, :active)]) - stub_sign_in(user) - sp = create(:service_provider, issuer: 'https://awesome') - subject.session[:sp] = { - issuer: sp.issuer, - acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, - request_url: 'http://example.com', - requested_attributes: %w[email first_name verified_at], - } - allow(@linker).to receive(:link_identity).with( - verified_attributes: %w[email first_name verified_at], - last_consented_at: now, - clear_deleted_at: true, - ) - expect(Idv::InPerson::CompletionSurveySender).to receive(:send_completion_survey) - .with(user, sp.issuer) - freeze_time do - travel_to(now) + context 'in person completion survey delievery enabled' do + before do + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + allow(IdentityConfig.store).to receive(:in_person_completion_survey_delivery_enabled) + .and_return(true) + end + + it 'sends the in-person proofing completion survey' do + user = create(:user, profiles: [create(:profile, :verified, :active)]) + stub_sign_in(user) + sp = create( + :service_provider, issuer: 'https://awesome', + in_person_proofing_enabled: true + ) + + subject.session[:sp] = { + issuer: sp.issuer, + acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, + request_url: 'http://example.com', + requested_attributes: %w[email first_name verified_at], + } + allow(@linker).to receive(:link_identity).with( + verified_attributes: %w[email first_name verified_at], + last_consented_at: now, + clear_deleted_at: true, + ) + expect(Idv::InPerson::CompletionSurveySender).to receive(:send_completion_survey) + .with(user, sp.issuer) + freeze_time do + travel_to(now) + patch :update + end + end + + it 'updates follow_up_survey_sent on enrollment to true' do + user = create(:user, profiles: [create(:profile, :verified, :active)]) + stub_sign_in(user) + sp = create( + :service_provider, issuer: 'https://awesome', + in_person_proofing_enabled: true + ) + e = create( + :in_person_enrollment, status: 'passed', doc_auth_result: 'Passed', + user: user, issuer: sp.issuer + ) + + expect(e.follow_up_survey_sent).to be false + + subject.session[:sp] = { + issuer: sp.issuer, + acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, + request_url: 'http://example.com', + requested_attributes: %w[email first_name verified_at], + } + allow(@linker).to receive(:link_identity).with( + verified_attributes: %w[email first_name verified_at], + last_consented_at: now, + clear_deleted_at: true, + ) + + patch :update + e.reload + + expect(e.follow_up_survey_sent).to be true + end + end + + context 'in person completion survey delievery disabled' do + before do + allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + allow(IdentityConfig.store).to receive(:in_person_completion_survey_delivery_enabled) + .and_return(false) + end + + it 'does not send the in-person proofing completion survey' do + user = create(:user, profiles: [create(:profile, :verified, :active)]) + stub_sign_in(user) + sp = create( + :service_provider, issuer: 'https://awesome', + in_person_proofing_enabled: true + ) + + subject.session[:sp] = { + issuer: sp.issuer, + acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, + request_url: 'http://example.com', + requested_attributes: %w[email first_name verified_at], + } + allow(@linker).to receive(:link_identity).with( + verified_attributes: %w[email first_name verified_at], + last_consented_at: now, + clear_deleted_at: true, + ) + expect(Idv::InPerson::CompletionSurveySender).not_to receive(:send_completion_survey) + .with(user, sp.issuer) + freeze_time do + travel_to(now) + patch :update + end + end + + it 'does not update enrollment' do + user = create(:user, profiles: [create(:profile, :verified, :active)]) + stub_sign_in(user) + sp = create( + :service_provider, issuer: 'https://awesome', + in_person_proofing_enabled: true + ) + e = create( + :in_person_enrollment, status: 'passed', doc_auth_result: 'Passed', + user: user, issuer: sp.issuer + ) + + expect(e.follow_up_survey_sent).to be false + + subject.session[:sp] = { + issuer: sp.issuer, + acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, + request_url: 'http://example.com', + requested_attributes: %w[email first_name verified_at], + } + allow(@linker).to receive(:link_identity).with( + verified_attributes: %w[email first_name verified_at], + last_consented_at: now, + clear_deleted_at: true, + ) + patch :update + e.reload + + expect(e.follow_up_survey_sent).to be false end end end diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index 8550a4d8bfa..febfef85a33 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -9,6 +9,8 @@ before do allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true) + allow(IdentityConfig.store).to receive(:in_person_completion_survey_delivery_enabled) + .and_return(true) end it 'works for a happy path', allow_browser_log: true do