diff --git a/app/controllers/sign_up/completions_controller.rb b/app/controllers/sign_up/completions_controller.rb index c6e77351c08..5aa70d16aa2 100644 --- a/app/controllers/sign_up/completions_controller.rb +++ b/app/controllers/sign_up/completions_controller.rb @@ -18,6 +18,7 @@ def show def update track_completion_event('agency-page') update_verified_attributes + send_in_person_completion_survey if decider.go_back_to_mobile_app? sign_user_out_and_instruct_to_go_back_to_mobile_app else @@ -89,5 +90,14 @@ def pii pii_string = Pii::Cacher.new(current_user, user_session).fetch_string JSON.parse(pii_string || '{}', symbolize_names: true) end + + def send_in_person_completion_survey + return unless sp_session_ial == ::Idp::Constants::IAL2 + + Idv::InPerson::CompletionSurveySender.send_completion_survey( + current_user, + current_sp.issuer, + ) + end end end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index cbd8e1e9336..d2243c1be1f 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -228,6 +228,18 @@ def account_verified(user, email_address, date_time:, sp_name:, disavowal_token: end end + def in_person_completion_survey(user, email_address) + with_user_locale(user) do + @header = t('user_mailer.in_person_completion_survey.header') + @privacy_url = MarketingSite.security_and_privacy_practices_url + @survey_url = IdentityConfig.store.in_person_completion_survey_url + mail( + to: email_address.email, + subject: t('user_mailer.in_person_completion_survey.subject', app_name: APP_NAME), + ) + end + end + def in_person_ready_to_verify(user, email_address, first_name:, enrollment:) attachments.inline['barcode.png'] = BarcodeOutputter.new( code: enrollment.enrollment_code, diff --git a/app/models/user.rb b/app/models/user.rb index d9ebc343577..668157dbc23 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -105,6 +105,32 @@ def default_phone_configuration phone_configurations.order('made_default_at DESC NULLS LAST, created_at').first end + ## + # @param [String] issuer + # @return [Boolean] Whether the user should receive a survey for completing in-person proofing + def should_receive_in_person_completion_survey?(issuer) + Idv::InPersonConfig.enabled_for_issuer?(issuer) && + in_person_enrollments. + where(issuer: issuer, status: :passed).order(created_at: :desc). + pick(:follow_up_survey_sent) == false + end + + ## + # Record that the in-person proofing survey was sent + # @param [String] issuer + def mark_in_person_completion_survey_sent(issuer) + enrollment_id, follow_up_survey_sent = in_person_enrollments. + where(issuer: issuer, status: :passed). + order(created_at: :desc). + pick(:id, :follow_up_survey_sent) + + if follow_up_survey_sent == false + # Enrollment record is present and survey was not previously sent + InPersonEnrollment.update(enrollment_id, follow_up_survey_sent: true) + end + nil + end + MINIMUM_LIKELY_ENCRYPTED_DATA_LENGTH = 1000 def broken_personal_key? diff --git a/app/services/idv/in_person/completion_survey_sender.rb b/app/services/idv/in_person/completion_survey_sender.rb new file mode 100644 index 00000000000..b84a9c3da5d --- /dev/null +++ b/app/services/idv/in_person/completion_survey_sender.rb @@ -0,0 +1,21 @@ +module Idv + module InPerson + class CompletionSurveySender + ## + # @param [User] user + # @param [String] issuer + def self.send_completion_survey(user, issuer) + return unless user.should_receive_in_person_completion_survey?(issuer) + + user.confirmed_email_addresses.each do |email_address| + UserMailer.in_person_completion_survey( + user, + email_address, + ).deliver_now_or_later + end + + user.mark_in_person_completion_survey_sent(issuer) + end + end + end +end diff --git a/app/views/user_mailer/in_person_completion_survey.html.erb b/app/views/user_mailer/in_person_completion_survey.html.erb new file mode 100644 index 00000000000..493cdbc3604 --- /dev/null +++ b/app/views/user_mailer/in_person_completion_survey.html.erb @@ -0,0 +1,38 @@ +

<%= t('user_mailer.in_person_completion_survey.body.greeting') %>

+

<%= t('user_mailer.in_person_completion_survey.body.thanks', app_name: APP_NAME) %>

+

+<%= t('user_mailer.in_person_completion_survey.body.intent') %> +<%= t('user_mailer.in_person_completion_survey.body.request_description') %> +<%= t( + 'user_mailer.in_person_completion_survey.body.privacy_html', + url: @privacy_url, + ) %> +

+

<%= t('user_mailer.in_person_completion_survey.body.cta.callout') %>

+ + + + + + + + +
+ + + + + + +
+
+ <%= link_to t('user_mailer.in_person_completion_survey.body.cta.label'), + @survey_url, + target: '_blank', + class: 'float-center', + align: 'center', + rel: 'noopener' %> +
+
+
+
\ No newline at end of file diff --git a/config/application.yml.default b/config/application.yml.default index 50ee5c37deb..4023560c4e0 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -115,6 +115,7 @@ idv_sp_required: false in_person_proofing_enabled: false in_person_enrollment_validity_in_days: 30 in_person_results_delay_in_hours: 1 +in_person_completion_survey_url: 'https://login.gov' include_slo_in_saml_metadata: false inherited_proofing_enabled: false inherited_proofing_va_base_url: 'https://staging-api.va.gov' diff --git a/config/locales/user_mailer/en.yml b/config/locales/user_mailer/en.yml index 6299a7c0576..84cf22c1bbc 100644 --- a/config/locales/user_mailer/en.yml +++ b/config/locales/user_mailer/en.yml @@ -100,6 +100,21 @@ en: %{app_name} %{help_link} or %{contact_link}. subject: Email address deleted help_link_text: Help Center + in_person_completion_survey: + body: + cta: + callout: Click the button below to get started. + label: Take our survey + greeting: Hello, + intent: We want to hear about your experience verifying your identity in person + at the Post Office. + privacy_html: Your answers to this survey will be protected according to the + following privacy and security standards. + request_description: Fill out a short, anonymous survey and we’ll use your input + to help us get better at serving your needs. + thanks: Thanks for using %{app_name}. + header: Take a minute to tell us how we did + subject: Tell us about your recent experience with %{app_name} in_person_failed: body: with_cta: Click the button or copy the link below to try verifying your identity diff --git a/config/locales/user_mailer/es.yml b/config/locales/user_mailer/es.yml index 89b1b74432e..a0e45abdeec 100644 --- a/config/locales/user_mailer/es.yml +++ b/config/locales/user_mailer/es.yml @@ -106,6 +106,21 @@ es: %{app_name} %{help_link} o el %{contact_link}. subject: Dirección de correo electrónico eliminada help_link_text: Centro de Ayuda + in_person_completion_survey: + body: + cta: + callout: Haga clic en el botón de abajo para empezar. + label: Tome nuestra encuesta + greeting: Hola, + intent: Queremos conocer su experiencia al verificar su identidad en persona en + la oficina de correos. + privacy_html: Sus respuestas a esta encuesta estarán protegidas conforme a los siguientes estándares de privacidad y seguridad. + request_description: Responde una breve encuesta anónima y su opinión nos + ayudará a atender mejor tus necesidades. + thanks: Gracias por utilizar %{app_name}. + header: Tómese un minuto para decirnos cómo lo hicimos + subject: Cuéntenos su experiencia reciente con %{app_name} in_person_failed: body: with_cta: Haga clic en el botón o copie el enlace siguiente para volver a diff --git a/config/locales/user_mailer/fr.yml b/config/locales/user_mailer/fr.yml index 4a2063b1ec8..1a8e4362d75 100644 --- a/config/locales/user_mailer/fr.yml +++ b/config/locales/user_mailer/fr.yml @@ -109,6 +109,21 @@ fr: veuillez visiter le %{help_link} de %{app_name} ou %{contact_link}. subject: Adresse email supprimée help_link_text: Centre d’aide + in_person_completion_survey: + body: + cta: + callout: Cliquez sur le bouton ci-dessous pour commencer. + label: Répondez à notre enquête + greeting: Bonjour, + intent: Nous voulons connaître votre expérience en matière de vérification de + votre identité en personne au bureau de poste. + privacy_html: Vos réponses à cette enquête seront protégées conformément aux normes de confidentialité et de sécurité suivantes. + request_description: Remplissez une courte enquête anonyme et nous utiliserons + vos commentaires pour nous aider à mieux répondre à vos besoins. + thanks: Merci d’utiliser %{app_name}. + header: Prenez une minute pour nous faire part de vos impressions + subject: Parlez-nous de votre expérience récente avec %{app_name} in_person_failed: body: with_cta: Cliquez sur le bouton ou copiez le lien ci-dessous pour essayer de diff --git a/db/primary_migrate/20220921233413_add_follow_up_survey_sent_to_in_person_enrollment.rb b/db/primary_migrate/20220921233413_add_follow_up_survey_sent_to_in_person_enrollment.rb new file mode 100644 index 00000000000..000ccf67dbf --- /dev/null +++ b/db/primary_migrate/20220921233413_add_follow_up_survey_sent_to_in_person_enrollment.rb @@ -0,0 +1,5 @@ +class AddFollowUpSurveySentToInPersonEnrollment < ActiveRecord::Migration[7.0] + def change + add_column :in_person_enrollments, :follow_up_survey_sent, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index e208a7600d6..0c62309953f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_09_09_021833) do +ActiveRecord::Schema[7.0].define(version: 2022_09_21_233413) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "pgcrypto" @@ -294,6 +294,7 @@ t.string "unique_id", comment: "Unique ID to use with the USPS service" t.datetime "enrollment_established_at", comment: "When the enrollment was successfully established" t.string "issuer", comment: "Issuer associated with the enrollment at time of creation" + t.boolean "follow_up_survey_sent", default: false t.index ["profile_id"], name: "index_in_person_enrollments_on_profile_id" t.index ["unique_id"], name: "index_in_person_enrollments_on_unique_id", unique: true t.index ["user_id", "status"], name: "index_in_person_enrollments_on_user_id_and_status", unique: true, where: "(status = 1)" diff --git a/lib/identity_config.rb b/lib/identity_config.rb index 7e92c9f946f..c4444637cad 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -194,6 +194,7 @@ def self.build_store(config_map) config.add(:in_person_proofing_enabled, type: :boolean) config.add(:in_person_enrollment_validity_in_days, type: :integer) config.add(:in_person_results_delay_in_hours, type: :integer) + config.add(:in_person_completion_survey_url, type: :string) config.add(:include_slo_in_saml_metadata, type: :boolean) config.add(:inherited_proofing_enabled, type: :boolean) config.add(:inherited_proofing_va_base_url, type: :string) diff --git a/spec/controllers/sign_up/completions_controller_spec.rb b/spec/controllers/sign_up/completions_controller_spec.rb index 98a9330adfa..f7808abfd8a 100644 --- a/spec/controllers/sign_up/completions_controller_spec.rb +++ b/spec/controllers/sign_up/completions_controller_spec.rb @@ -232,6 +232,32 @@ last_consented_at: now, clear_deleted_at: true, ) + allow(Idv::InPerson::CompletionSurveySender).to receive(:send_completion_survey). + with(user, sp.issuer) + freeze_time do + travel_to(now) + patch :update + 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, + ial: 2, + request_url: 'http://example.com', + requested_attributes: %w[email first_name verified_at], + } + allow(@linker).to receive(:link_identity).with( + ial: 2, + 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 diff --git a/spec/features/idv/in_person_spec.rb b/spec/features/idv/in_person_spec.rb index bd21d5ef2ce..26388b8d5d0 100644 --- a/spec/features/idv/in_person_spec.rb +++ b/spec/features/idv/in_person_spec.rb @@ -3,6 +3,7 @@ RSpec.describe 'In Person Proofing', js: true do include IdvStepHelper + include SpAuthHelper include InPersonHelper before do @@ -176,6 +177,29 @@ end end + context 'after in-person proofing is completed and passed for a partner' do + let(:sp) { nil } + before do + create_in_person_ial2_account_go_back_to_sp_and_sign_out(sp) + end + + [ + :oidc, + :saml, + ].each do |service_provider| + context "using #{service_provider}" do + let(:sp) { service_provider } + it 'sends a survey when they share information with that partner', + allow_browser_log: true do + expect(last_email.html_part.body). + to have_selector( + "a[href='#{IdentityConfig.store.in_person_completion_survey_url}']", + ) + end + end + end + end + context 'with hybrid document capture' do before do allow(FeatureManagement).to receive(:doc_capture_polling_enabled?).and_return(true) diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb index 1a71d660d8c..fcc4272022b 100644 --- a/spec/mailers/previews/user_mailer_preview.rb +++ b/spec/mailers/previews/user_mailer_preview.rb @@ -134,6 +134,13 @@ def account_verified ) end + def in_person_completion_survey + UserMailer.in_person_completion_survey( + user, + email_address_record, + ) + end + def in_person_ready_to_verify UserMailer.in_person_ready_to_verify( user, diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index eb1d454ac83..a351b9b25d8 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -623,6 +623,47 @@ def expect_email_body_to_have_help_and_contact_links it_behaves_like 'an email that respects user email locale preference' end + describe '#in_person_completion_survey' do + let(:mail) do + UserMailer.in_person_completion_survey( + user, + email_address, + ) + end + + it_behaves_like 'a system email' + it_behaves_like 'an email that respects user email locale preference' + + it 'sends to the current email' do + expect(mail.to).to eq [email_address.email] + end + + it 'renders the subject' do + expect(mail.subject).to eq t( + 'user_mailer.in_person_completion_survey.subject', + app_name: APP_NAME, + ) + end + + it 'renders the body' do + expect(mail.html_part.body). + to have_content( + t( + 'user_mailer.in_person_completion_survey.body.thanks', + app_name: APP_NAME, + ), + ) + expect(mail.html_part.body). + to have_selector( + "a[href='#{MarketingSite.security_and_privacy_practices_url}']", + ) + expect(mail.html_part.body). + to have_selector( + "a[href='#{IdentityConfig.store.in_person_completion_survey_url}']", + ) + end + end + def strip_tags(str) ActionController::Base.helpers.strip_tags(str) end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c50d5e9145f..2ccfdf73bf5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -510,6 +510,118 @@ end end + describe '#should_receive_in_person_completion_survey?' do + let!(:user) { create(:user) } + let(:service_provider) { create(:service_provider) } + let(:issuer) { service_provider.issuer } + + before do + allow(Idv::InPersonConfig).to receive(:enabled_for_issuer?). + and_return(true) + end + + def test_send_survey(should_send) + expect(user.should_receive_in_person_completion_survey?(issuer)).to be(should_send) + user.mark_in_person_completion_survey_sent(issuer) + expect(user.should_receive_in_person_completion_survey?(issuer)).to be(false) + end + + def it_should_send_survey + test_send_survey(true) + end + + def it_should_not_send_survey + test_send_survey(false) + end + + context 'user has no enrollments' do + it 'should not send survey' do + it_should_not_send_survey + end + end + context 'user has completed enrollment for different issuer but no survey' do + let(:other_service_provider) { create(:service_provider, issuer: 'otherissuer') } + let!(:enrollment) do + create( + :in_person_enrollment, user: user, issuer: other_service_provider.issuer, + status: :passed + ) + end + it 'should not send survey' do + it_should_not_send_survey + end + end + context 'user has completed survey for other issuer and enrollments for both issuers' do + let(:other_service_provider) { create(:service_provider, issuer: 'otherissuer') } + let!(:enrollment) do + create(:in_person_enrollment, user: user, issuer: issuer, status: :passed) + end + let!(:enrollment2) do + create( + :in_person_enrollment, user: user, issuer: other_service_provider.issuer, + status: :passed, follow_up_survey_sent: true + ) + end + it 'should send survey' do + it_should_send_survey + end + end + context 'user has incomplete enrollment but no survey' do + let!(:user) { create(:user, :with_pending_in_person_enrollment) } + it 'should not send survey' do + it_should_not_send_survey + end + end + context 'user has completed enrollment but no survey' do + let!(:enrollment) do + create(:in_person_enrollment, user: user, issuer: issuer, status: :passed) + end + it 'should send survey' do + it_should_send_survey + end + end + context 'user has multiple enrollments but only completed a survey for the last one' do + let!(:enrollment) do + create(:in_person_enrollment, user: user, issuer: issuer, status: :passed) + end + let!(:enrollment2) do + create( + :in_person_enrollment, user: user, issuer: issuer, status: :passed, + follow_up_survey_sent: true + ) + end + it 'should not send survey' do + it_should_not_send_survey + end + end + context 'user has completed enrollment but no survey and feature is disabled' do + let!(:enrollment) do + create(:in_person_enrollment, user: user, issuer: issuer, status: :passed) + end + + before do + allow(Idv::InPersonConfig).to receive(:enabled_for_issuer?). + and_return(false) + end + + it 'should not send survey' do + it_should_not_send_survey + end + end + context 'user has completed enrollment and survey' do + let!(:enrollment) do + create( + :in_person_enrollment, user: user, issuer: issuer, status: :passed, + follow_up_survey_sent: true + ) + end + + it 'should not send survey' do + it_should_not_send_survey + end + end + end + describe '#broken_personal_key?' do before do allow(IdentityConfig.store).to receive(:broken_personal_key_window_start). diff --git a/spec/services/idv/in_person/completion_survey_sender_spec.rb b/spec/services/idv/in_person/completion_survey_sender_spec.rb new file mode 100644 index 00000000000..323d8a42c43 --- /dev/null +++ b/spec/services/idv/in_person/completion_survey_sender_spec.rb @@ -0,0 +1,52 @@ +require 'rails_helper' + +describe Idv::InPerson::CompletionSurveySender do + describe '.send_completion_survey' do + let(:user) { instance_double(User) } + let(:issuer) { 'test_issuer' } + + it 'does nothing if the user should not receive a survey' do + expect(UserMailer).to_not receive(:in_person_completion_survey) + allow(user).to receive(:should_receive_in_person_completion_survey?). + with(issuer).and_return(false) + + described_class.send_completion_survey(user, issuer) + end + + context 'user should receive a survey' do + let(:message) { instance_double(ActionMailer::MessageDelivery) } + let(:message2) { instance_double(ActionMailer::MessageDelivery) } + let(:email_address_one) { 'hello@world.com' } + let(:email_address_two) { 'hola@mundo.com' } + before do + allow(user).to receive(:should_receive_in_person_completion_survey?). + with(issuer).and_return(true) + allow(user).to receive(:confirmed_email_addresses). + and_return([ + email_address_one, + email_address_two, + ]) + allow(UserMailer).to receive(:in_person_completion_survey). + with(user, email_address_one). + and_return(message) + allow(UserMailer).to receive(:in_person_completion_survey). + with(user, email_address_two). + and_return(message2) + allow(message).to receive(:deliver_now_or_later) + allow(message2).to receive(:deliver_now_or_later) + allow(user).to receive(:mark_in_person_completion_survey_sent). + with(issuer) + + described_class.send_completion_survey(user, issuer) + end + it 'sends a survey to the user\'s confirmed email addresses' do + expect(message).to have_received(:deliver_now_or_later) + expect(message2).to have_received(:deliver_now_or_later) + end + it 'marks the user as having received a survey' do + expect(user).to have_received(:mark_in_person_completion_survey_sent). + with(issuer) + end + end + end +end diff --git a/spec/support/features/idv_helper.rb b/spec/support/features/idv_helper.rb index 293ded6e4b4..238e1890048 100644 --- a/spec/support/features/idv_helper.rb +++ b/spec/support/features/idv_helper.rb @@ -75,14 +75,30 @@ def visit_idp_from_sp_with_ial2(sp, **extra) visit_saml_authn_request_url(overrides: saml_overrides) elsif sp == :oidc @state = SecureRandom.hex - @client_id = 'urn:gov:gsa:openidconnect:sp:server' + @client_id = sp_oidc_issuer @nonce = SecureRandom.hex visit_idp_from_oidc_sp_with_ial2(state: @state, client_id: @client_id, nonce: @nonce, **extra) end end + def sp_oidc_redirect_uri + 'http://localhost:7654/auth/result' + end + + def sp_oidc_issuer + 'urn:gov:gsa:openidconnect:sp:server' + end + + def service_provider_issuer(sp) + if sp == :saml + sp1_issuer + elsif sp == :oidc + sp_oidc_issuer + end + end + def visit_idp_from_oidc_sp_with_ial2( - client_id: 'urn:gov:gsa:openidconnect:sp:server', + client_id: sp_oidc_issuer, state: SecureRandom.hex, nonce: SecureRandom.hex, verified_within: nil @@ -92,7 +108,7 @@ def visit_idp_from_oidc_sp_with_ial2( response_type: 'code', acr_values: Saml::Idp::Constants::IAL2_AUTHN_CONTEXT_CLASSREF, scope: 'openid email profile:name phone social_security_number', - redirect_uri: 'http://localhost:7654/auth/result', + redirect_uri: sp_oidc_redirect_uri, state: state, prompt: 'select_account', nonce: nonce, @@ -102,11 +118,11 @@ def visit_idp_from_oidc_sp_with_ial2( def visit_idp_from_oidc_sp_with_loa3 visit openid_connect_authorize_path( - client_id: 'urn:gov:gsa:openidconnect:sp:server', + client_id: sp_oidc_issuer, response_type: 'code', acr_values: Saml::Idp::Constants::LOA3_AUTHN_CONTEXT_CLASSREF, scope: 'openid email profile:name phone social_security_number', - redirect_uri: 'http://localhost:7654/auth/result', + redirect_uri: sp_oidc_redirect_uri, state: SecureRandom.hex, prompt: 'select_account', nonce: SecureRandom.hex, @@ -115,11 +131,11 @@ def visit_idp_from_oidc_sp_with_loa3 def visit_idp_from_oidc_sp_with_ial2_strict visit openid_connect_authorize_path( - client_id: 'urn:gov:gsa:openidconnect:sp:server', + client_id: sp_oidc_issuer, response_type: 'code', acr_values: Saml::Idp::Constants::IAL2_STRICT_AUTHN_CONTEXT_CLASSREF, scope: 'openid email profile:name phone social_security_number', - redirect_uri: 'http://localhost:7654/auth/result', + redirect_uri: sp_oidc_redirect_uri, state: SecureRandom.hex, prompt: 'select_account', nonce: SecureRandom.hex, diff --git a/spec/support/features/in_person_helper.rb b/spec/support/features/in_person_helper.rb index c8fd9f5dc78..cc6a56d8c8a 100644 --- a/spec/support/features/in_person_helper.rb +++ b/spec/support/features/in_person_helper.rb @@ -47,15 +47,25 @@ def begin_in_person_proofing(_user = nil) end def complete_location_step(_user = nil) + # Wait for page to load before selecting location + expect(page).to have_css('.location-collection-item') first('.location-collection-item'). click_button(t('in_person_proofing.body.location.location_button')) end def complete_prepare_step(_user = nil) + # Wait for page to load before clicking continue + expect(page).to have_content( + t('in_person_proofing.headings.prepare'), + ) click_link t('forms.buttons.continue') end def complete_state_id_step(_user = nil) + # Wait for page to load before attempting to fill out form + expect(page).to have_current_path( + idv_in_person_step_path(step: :state_id), + ) fill_out_state_id_form_ok click_idv_continue end diff --git a/spec/support/sp_auth_helper.rb b/spec/support/sp_auth_helper.rb index 8ed1fdba128..e3a1e67a27c 100644 --- a/spec/support/sp_auth_helper.rb +++ b/spec/support/sp_auth_helper.rb @@ -31,4 +31,47 @@ def create_ial2_account_go_back_to_sp_and_sign_out(sp) visit sign_out_url user.reload end + + def create_in_person_ial2_account_go_back_to_sp_and_sign_out(sp) + user = user_with_totp_2fa + ServiceProvider.find_by(issuer: service_provider_issuer(sp)). + update(in_person_proofing_enabled: true) + + visit_idp_from_sp_with_ial2(sp) + sign_in_user(user) + uncheck(t('forms.messages.remember_device')) + fill_in_code_with_last_totp(user) + click_submit_default + + expect(page).to have_current_path(idv_doc_auth_welcome_step) + begin_in_person_proofing + complete_all_in_person_proofing_steps + + complete_phone_step(user) + complete_review_step(user) + acknowledge_and_confirm_personal_key + expect(page).to have_current_path(idv_in_person_ready_to_verify_path) + + visit sign_out_url + user.reload + + # Mark IPP as passed + enrollment = user.in_person_enrollments.last + expect(enrollment).to_not be_nil + enrollment.profile.activate + enrollment.update(status: :passed) + + visit_idp_from_sp_with_ial2(sp) + + sign_in_user(user) + uncheck(t('forms.messages.remember_device')) + fill_in_code_with_last_totp(user) + click_submit_default + + expect(current_path).to eq(sign_up_completed_path) + click_agree_and_continue + + visit sign_out_url + user.reload + end end