Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions app/controllers/idv/in_person/usps_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def index
city: search_params['city'], state: search_params['state'],
zip_code: search_params['zip_code']
)
is_enhanced_ipp = resolved_authn_context_result.enhanced_ipp?
locations = proofer.request_facilities(candidate, is_enhanced_ipp)
locations = proofer.request_facilities(candidate, is_authn_context_enhanced_ipp?)
if locations.length > 0
analytics.idv_in_person_locations_searched(
success: true,
Expand All @@ -47,6 +46,7 @@ def update
selected_location_details: update_params.as_json,
issuer: current_sp&.issuer,
doc_auth_result: document_capture_session&.last_doc_auth_result,
sponsor_id: enrollment_sponsor_id,
)

add_proofing_component
Expand Down Expand Up @@ -123,6 +123,16 @@ def enrollment
)
end

def enrollment_sponsor_id
is_authn_context_enhanced_ipp? ?
IdentityConfig.store.usps_eipp_sponsor_id :
IdentityConfig.store.usps_ipp_sponsor_id
end

def is_authn_context_enhanced_ipp?
resolved_authn_context_result.enhanced_ipp?
end

def search_params
params.require(:address).permit(
:street_address,
Expand Down
13 changes: 7 additions & 6 deletions app/services/usps_in_person_proofing/enrollment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ def schedule_in_person_enrollment(user:, pii:, is_enhanced_ipp:, opt_in: nil)
return unless enrollment

enrollment.current_address_matches_id = pii['same_address_as_id']

if enrollment.sponsor_id.nil?
enrollment.sponsor_id = is_enhanced_ipp ?
IdentityConfig.store.usps_eipp_sponsor_id :
IdentityConfig.store.usps_ipp_sponsor_id
end

enrollment.save!

# Send state ID address to USPS
Expand All @@ -20,12 +27,6 @@ def schedule_in_person_enrollment(user:, pii:, is_enhanced_ipp:, opt_in: nil)
enrollment_code = create_usps_enrollment(enrollment, pii, is_enhanced_ipp)
return unless enrollment_code

if is_enhanced_ipp
enrollment.sponsor_id = IdentityConfig.store.usps_eipp_sponsor_id
else
enrollment.sponsor_id = IdentityConfig.store.usps_ipp_sponsor_id
end

# update the enrollment to status pending
enrollment.enrollment_code = enrollment_code
enrollment.status = :pending
Expand Down
57 changes: 47 additions & 10 deletions spec/controllers/idv/in_person/usps_locations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,60 @@
end

describe '#update' do
let(:enrollment) { InPersonEnrollment.last }
let(:sp) { create(:service_provider, ial: 2) }
subject(:response) { put :update, params: selected_location }

it 'writes the passed location to in-person enrollment' do
response
context 'when the user is going through ID-IPP' do
it 'creates an in person enrollment' do
expect { response }.to change { InPersonEnrollment.count }.from(0).to(1)
expect(enrollment.user).to eq(user)
expect(enrollment.status).to eq('establishing')
expect(enrollment.profile).to be_nil
expect(enrollment.sponsor_id).to eq(IdentityConfig.store.usps_ipp_sponsor_id)
expect(enrollment.selected_location_details).to eq(
selected_location[:usps_location].as_json,
)
expect(enrollment.service_provider).to eq(sp)
end

it 'updates proofing component vendor' do
expect(user.proofing_component&.document_check).to be_nil

enrollment = user.reload.establishing_in_person_enrollment
response

expect(enrollment.selected_location_details).to eq(selected_location[:usps_location].as_json)
expect(enrollment.service_provider).to be_nil
expect(user.proofing_component.document_check).to eq Idp::Constants::Vendors::USPS
end
end

it 'updates proofing component vendor' do
expect(user.proofing_component&.document_check).to be_nil
context 'when the user is going through EIPP' do
let(:vtr) { ['C1.C2.P1.Pe'] }
let(:enhanced_ipp_sp_session) { { vtr: vtr, acr_values: nil } }

before do
allow(controller).to receive(:sp_session).and_return(enhanced_ipp_sp_session)
allow(controller).to receive(:sp_from_sp_session).and_return(sp)
end

it 'creates an in person enrollment' do
expect { response }.to change { InPersonEnrollment.count }.from(0).to(1)
expect(enrollment.user).to eq(user)
expect(enrollment.status).to eq('establishing')
expect(enrollment.profile).to be_nil
expect(enrollment.sponsor_id).to eq(IdentityConfig.store.usps_eipp_sponsor_id)
expect(enrollment.selected_location_details).to eq(
selected_location[:usps_location].as_json,
)
expect(enrollment.service_provider).to eq(sp)
end

response
it 'updates proofing component vendor' do
expect(user.proofing_component&.document_check).to be_nil

expect(user.proofing_component.document_check).to eq Idp::Constants::Vendors::USPS
response

expect(user.proofing_component.document_check).to eq Idp::Constants::Vendors::USPS
end
end

context 'when unauthenticated' do
Expand Down Expand Up @@ -322,7 +359,7 @@
expect(enrollment.selected_location_details).to eq(
selected_location[:usps_location].as_json,
)
expect(enrollment.service_provider).to be_nil
expect(enrollment.service_provider).to eq(sp)
end
end

Expand Down
Loading