Skip to content
Merged
1 change: 1 addition & 0 deletions app/controllers/sign_up/completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
149 changes: 130 additions & 19 deletions spec/controllers/sign_up/completions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions spec/features/idv/in_person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down