Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
63c9d1d
add user#establishing_in_person_enrollment_with_address
theabrad Aug 17, 2023
9b00d51
use user#establishing_in_person_enrollment_with_address?
theabrad Aug 18, 2023
b0ffacf
changing ipp method for step indicator concern
theabrad Aug 18, 2023
8b609ba
remove proofing component methods from step_indicator_concern
theabrad Aug 18, 2023
2539c28
use in_person selected location details to determine if ipp ready
theabrad Aug 21, 2023
9973183
changed name to user#has_in_person_enrollment?
theabrad Aug 21, 2023
287a2c1
add changelog
theabrad Aug 21, 2023
8a1ce6a
remove profile#pending_in_person_enrollment?
theabrad Aug 21, 2023
50a3917
use new has_in_person_enrollment?
theabrad Aug 22, 2023
80f45cf
fix error in idv step concern
theabrad Aug 22, 2023
8198d8e
Merge branch 'main' of github.com:18F/identity-idp into abrad-lg-1061…
theabrad Aug 22, 2023
dc0f123
fix idv_step_concern spec
theabrad Aug 22, 2023
39025a0
only check for establishing or pending ipp statuses
theabrad Aug 22, 2023
42f3861
linty mclinterson
theabrad Aug 23, 2023
5133f00
Merge branch 'main' of github.com:18F/identity-idp into abrad-lg-1061…
theabrad Aug 23, 2023
3fc021c
check profile in person enrollment on gpo verify
theabrad Aug 24, 2023
ce180bc
add #has_pending_in_person_enrollment
theabrad Aug 24, 2023
da85d74
make current_user#has_in_person_enrollment more explicit in idv session
theabrad Aug 25, 2023
0db91ba
fix method missing
theabrad Aug 25, 2023
2218c48
Merge branch 'main' into abrad-lg-10617-consolidate-ipp
kbighorse Aug 28, 2023
9738090
Merge branch 'main' into abrad-lg-10617-consolidate-ipp
kbighorse Aug 28, 2023
1008f7e
Remove unused private method
kbighorse Aug 29, 2023
13c7edb
Replace private method with inline boolean computation
kbighorse Aug 29, 2023
3f24605
Use `User#has_in_person_enrollment?` in `GpoVerifyForm#submit`
kbighorse Aug 29, 2023
dbf67a6
Merge branch 'main' into abrad-lg-10617-consolidate-ipp
kbighorse Aug 29, 2023
961c77e
Merge branch 'main' into abrad-lg-10617-consolidate-ipp
kbighorse Aug 29, 2023
78fd989
Format establishing in person enrollment in gpo form spec
kbighorse Aug 29, 2023
a00f102
Name test object better
kbighorse Aug 29, 2023
403edcc
Test pending in person enrollment
kbighorse Aug 29, 2023
0bacc8e
Call `User.has_establishing_in_person_enrollment_safe?` from `GpoVeri…
kbighorse Aug 30, 2023
09ba7db
Correctly describe spec
kbighorse Aug 30, 2023
0e74149
Remove unnecessary expectation in user spec
kbighorse Aug 30, 2023
390fe2c
Remove unnecessary expectation in user spec
kbighorse Aug 30, 2023
1d7f994
Merge branch 'main' into abrad-lg-10617-consolidate-ipp
kbighorse Aug 30, 2023
347ca00
We will always trust `pending_profile` for this value
kbighorse Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions app/controllers/concerns/idv/step_indicator_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def step_indicator_steps
private

def in_person_proofing?
proofing_components_as_hash['document_check'] == Idp::Constants::Vendors::USPS
current_user&.has_in_person_enrollment?
end

def gpo_address_verification?
Expand All @@ -49,22 +49,5 @@ def gpo_address_verification?

return idv_session&.address_verification_mechanism == 'gpo' if defined?(idv_session)
end

def proofing_components
return {} if !current_user

if current_user.pending_profile
current_user.pending_profile.proofing_components
else
ProofingComponent.find_by(user: current_user).as_json
end
end

def proofing_components_as_hash
# A proofing component record exists as a zero-or-one-to-one relation with a user, and values
# are set during identity verification. These values are recorded to the profile at creation,
# including for a pending profile.
@proofing_components_as_hash ||= proofing_components.to_h
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/idv_step_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def confirm_document_capture_complete
def confirm_verify_info_step_complete
return if idv_session.verify_info_step_complete?

if idv_session.pending_in_person_enrollment?
if current_user.has_in_person_enrollment?
redirect_to idv_in_person_verify_info_url
else
redirect_to idv_verify_info_url
Expand Down
8 changes: 2 additions & 6 deletions app/forms/gpo_verify_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def submit
if result
pending_profile&.remove_gpo_deactivation_reason

if profile_has_pending_in_person_enrollment?
if user.has_establishing_in_person_enrollment_safe?
schedule_in_person_enrollment_and_deactivate_profile
elsif fraud_check_failed && threatmetrix_enabled?
pending_profile&.deactivate_for_fraud_review
Expand All @@ -43,7 +43,7 @@ def submit
letter_count: letter_count,
attempts: attempts,
pii_like_keypaths: [[:errors, :otp], [:error_details, :otp]],
pending_in_person_enrollment: pending_profile&.pending_in_person_enrollment?,
pending_in_person_enrollment: !!pending_profile&.in_person_enrollment&.pending?,
fraud_check_failed: fraud_check_failed,
},
)
Expand All @@ -61,10 +61,6 @@ def gpo_confirmation_code
pending_profile.gpo_confirmation_codes.first_with_otp(otp)
end

def profile_has_pending_in_person_enrollment?
pending_profile&.pending_in_person_enrollment?
end

def schedule_in_person_enrollment_and_deactivate_profile
UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment(user, pii)
pending_profile&.deactivate_for_in_person_verification
Expand Down
4 changes: 0 additions & 4 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ def self.build_compound_pii(pii)
values.join(':')
end

def pending_in_person_enrollment?
proofing_components&.[]('document_check') == Idp::Constants::Vendors::USPS
end

def includes_phone_check?
return false if proofing_components.blank?
proofing_components['address_check'] == 'lexis_nexis_address'
Expand Down
9 changes: 9 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@ def in_person_pending_profile
pending_profile if pending_profile&.in_person_verification_pending?
end

def has_in_person_enrollment?
pending_in_person_enrollment.present? || establishing_in_person_enrollment.present?
end

# Trust `pending_profile` rather than enrollment associations
def has_establishing_in_person_enrollment_safe?
!!pending_profile&.in_person_enrollment&.establishing?
end

def personal_key_generated_at
encrypted_recovery_code_digest_generated_at ||
active_profile&.verified_at ||
Expand Down
11 changes: 4 additions & 7 deletions app/services/idv/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_profile_from_applicant_with_password(user_password)
profile = profile_maker.save_profile(
fraud_pending_reason: threatmetrix_fraud_pending_reason,
gpo_verification_needed: gpo_verification_needed?,
in_person_verification_needed: pending_in_person_enrollment?,
in_person_verification_needed: current_user.has_in_person_enrollment?,
)

profile.activate unless profile.reason_not_to_activate
Expand All @@ -76,7 +76,7 @@ def create_profile_from_applicant_with_password(user_password)
move_pii_to_user_session
elsif address_verification_mechanism == 'gpo'
create_gpo_entry
elsif pending_in_person_enrollment?
elsif current_user.has_in_person_enrollment?
UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment(
current_user,
pii,
Expand Down Expand Up @@ -106,7 +106,8 @@ def clear
end

def associate_in_person_enrollment_with_profile
return unless pending_in_person_enrollment? && current_user.establishing_in_person_enrollment
return unless current_user.has_in_person_enrollment?

current_user.establishing_in_person_enrollment.update(profile: profile)
end

Expand Down Expand Up @@ -142,10 +143,6 @@ def add_failed_phone_step_number(phone)
failed_phone_step_numbers << phone_e164 if !failed_phone_step_numbers.include?(phone_e164)
end

def pending_in_person_enrollment?
current_user.proofing_component&.document_check == Idp::Constants::Vendors::USPS
end

def verify_info_step_complete?
resolution_successful
end
Expand Down
3 changes: 3 additions & 0 deletions spec/controllers/concerns/idv/step_indicator_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,16 @@ def force_gpo
end

it 'returns in person gpo steps' do
ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS)
create(:in_person_enrollment, :establishing, user: user)
expect(steps).to eq in_person_step_indicator_steps_gpo
end
end

context 'via current idv session' do
before do
ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS)
create(:in_person_enrollment, :establishing, user: user)
end

it 'returns in person steps' do
Expand Down
8 changes: 6 additions & 2 deletions spec/controllers/concerns/idv_step_concern_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,17 @@ def show
end

context 'the user has not completed the verify info step with an in-person enrollment' do
let(:selected_location_details) do
JSON.parse(UspsInPersonProofing::Mock::Fixtures.enrollment_selected_location_details)
end

it 'redirects to the in-person verify info step' do
idv_session.resolution_successful = nil

ProofingComponent.find_or_create_by(
InPersonEnrollment.find_or_create_by(
user: user,
).update!(
document_check: Idp::Constants::Vendors::USPS,
selected_location_details: selected_location_details,
)

get :show
Expand Down
50 changes: 43 additions & 7 deletions spec/forms/gpo_verify_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@
expect(result.to_h[:enqueued_at]).to eq(confirmation_code.code_sent_at)
end

context 'pending in person enrollment' do
let!(:enrollment) do
create(:in_person_enrollment, :establishing, profile: pending_profile, user: user)
context 'establishing in person enrollment' do
let!(:establishing_enrollment) do
create(
:in_person_enrollment,
:establishing,
profile: pending_profile,
user: user,
)
end

let(:proofing_components) do
ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS)
end

before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end
Expand All @@ -148,11 +155,40 @@
it 'updates establishing in-person enrollment to pending' do
subject.submit

enrollment.reload
establishing_enrollment.reload

expect(establishing_enrollment.status).to eq(InPersonEnrollment::STATUS_PENDING)
expect(establishing_enrollment.user_id).to eq(user.id)
expect(establishing_enrollment.enrollment_code).to be_a(String)
end
end

expect(enrollment.status).to eq(InPersonEnrollment::STATUS_PENDING)
expect(enrollment.user_id).to eq(user.id)
expect(enrollment.enrollment_code).to be_a(String)
context 'pending in person enrollment' do
let!(:pending_enrollment) do
create(
:in_person_enrollment,
:pending,
profile: pending_profile,
user: user,
)
end

let(:proofing_components) do
ProofingComponent.create(user: user, document_check: Idp::Constants::Vendors::USPS)
end

before do
allow(IdentityConfig.store).to receive(:in_person_proofing_enabled).and_return(true)
end

it 'changes profile from pending to active' do
subject.submit
pending_profile.reload

expect(pending_profile).to be_active
expect(pending_profile.deactivation_reason).to be_nil
expect(pending_profile.in_person_verification_pending_at).to be_nil
expect(pending_profile.gpo_verification_pending?).to eq(false)
end
end

Expand Down
20 changes: 0 additions & 20 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,6 @@
end
end

describe '#pending_in_person_enrollment?' do
it 'returns true if the document_check component is usps' do
profile = create(:profile, proofing_components: { document_check: 'usps' })

expect(profile.pending_in_person_enrollment?).to eq(true)
end

it 'returns false if the document_check component is something else' do
profile = create(:profile, proofing_components: { document_check: 'something_else' })

expect(profile.pending_in_person_enrollment?).to eq(false)
end

it 'returns false if proofing_components is blank' do
profile = create(:profile, proofing_components: '')

expect(profile.pending_in_person_enrollment?).to eq(false)
end
end

describe '#includes_phone_check?' do
it 'returns true if the address_check component is lexis_nexis_address' do
profile = create(:profile, proofing_components: { address_check: 'lexis_nexis_address' })
Expand Down
37 changes: 37 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,43 @@
expect(user.establishing_in_person_enrollment).to eq establishing_enrollment
end
end

describe '#has_in_person_enrollment?' do
it 'returns the establishing IPP enrollment that has an address' do
ProofingComponent.find_or_create_by(user: user).
update!(document_check: Idp::Constants::Vendors::USPS)

expect(user.has_in_person_enrollment?).to eq(true)
end
end

# We don't know yet if #establishing_in_person_enrollment is, in fact, `establishing`
# so we trust the pending profile in the meantime
describe '#has_establishing_in_person_enrollment_safe?' do
let(:new_user) { create(:user, :fully_registered) }
let(:proofing_components) { nil }
let(:new_pending_profile) do
create(
:profile,
:verify_by_mail_pending,
user: new_user,
proofing_components: proofing_components,
)
end
let!(:establishing_enrollment) do
create(
:in_person_enrollment,
:establishing,
profile: new_pending_profile,
user: new_user,
)
end

it 'returns the establishing IPP enrollment through the pending profile' do
# trust pending_profile
expect(new_user.has_establishing_in_person_enrollment_safe?).to eq(true)
end
end
end

describe 'deleting identities' do
Expand Down