Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LG-14175: Expire EIPP enrollments in job #11085

Merged
merged 6 commits into from
Aug 16, 2024
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
8 changes: 6 additions & 2 deletions app/services/usps_in_person_proofing/mock/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ def self.request_passed_proofing_secondary_id_type_results_response_ial_2
)
end

def self.request_expired_proofing_results_response
load_response_fixture('request_expired_proofing_results_response.json')
def self.request_expired_enhanced_ipp_results_response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed- no more instances of request_expired_proofing_results_response found

load_response_fixture('request_expired_enhanced_ipp_results_response.json')
end

def self.request_expired_id_ipp_results_response
load_response_fixture('request_expired_id_ipp_results_response.json')
end

def self.request_unexpected_expired_proofing_results_response
Expand Down
10 changes: 8 additions & 2 deletions app/services/usps_in_person_proofing/mock/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ def request_facilities(_location, is_enhanced_ipp)
end
end

def request_proofing_results(_enrollment)
JSON.parse(Fixtures.request_passed_proofing_results_response)
def request_proofing_results(enrollment)
if enrollment.days_to_due_date.negative? && enrollment.enhanced_ipp?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to support manual testing. Feedback is welcome! Making the manual testing plan took me longer than anticipated.

body = JSON.parse(Fixtures.request_expired_enhanced_ipp_results_response)
response = { body: body, status: 400 }
raise Faraday::BadRequestError.new('Bad request error', response)
else
JSON.parse(Fixtures.request_passed_proofing_results_response)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"responseMessage": "More than 7 days have passed since opt-in to IPP"
}
69 changes: 60 additions & 9 deletions spec/jobs/get_usps_proofing_results_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@
request_in_progress_proofing_results_args,
{ status: 500 },
request_failed_proofing_results_args,
request_expired_proofing_results_args,
request_expired_id_ipp_results_args,
).and_raise(Faraday::TimeoutError).and_raise(Faraday::ConnectionFailed)

job.perform(Time.zone.now)
Expand Down Expand Up @@ -527,7 +527,7 @@
end

it 'sends deadline passed email on response with expired status' do
stub_request_expired_proofing_results
stub_request_expired_id_ipp_proofing_results
user = pending_enrollment.user
expect(pending_enrollment.deadline_passed_sent).to be false
freeze_time do
Expand Down Expand Up @@ -851,7 +851,7 @@

context 'when an enrollment expires' do
before(:each) do
stub_request_expired_proofing_results
stub_request_expired_id_ipp_proofing_results
end

it_behaves_like(
Expand All @@ -860,7 +860,7 @@
email_type: 'deadline passed',
enrollment_status: InPersonEnrollment::STATUS_EXPIRED,
response_json: UspsInPersonProofing::Mock::Fixtures.
request_expired_proofing_results_response,
request_expired_id_ipp_results_response,
)

it 'logs that the enrollment expired' do
Expand Down Expand Up @@ -1229,7 +1229,7 @@
end

it 'does not set the fraud related fields of an expired enrollment' do
stub_request_expired_proofing_results
stub_request_expired_id_ipp_proofing_results

job.perform(Time.zone.now)
profile = pending_enrollment.reload.profile
Expand Down Expand Up @@ -1354,7 +1354,7 @@
end

it 'deactivates and sets fraud related fields of an expired enrollment' do
stub_request_expired_proofing_results
stub_request_expired_id_ipp_proofing_results

job.perform(Time.zone.now)

Expand Down Expand Up @@ -1449,7 +1449,7 @@

context 'enrollment is expired' do
it 'deletes the notification phone configuration without sending an sms' do
stub_request_expired_proofing_results
stub_request_expired_id_ipp_proofing_results

expect(pending_enrollment.notification_phone_configuration).to_not be_nil

Expand Down Expand Up @@ -1531,7 +1531,7 @@
end

context <<~STR.squish do
When an Enhanced IPP enrollment passess proofing
When an Enhanced IPP enrollment passes proofing
with unsupported ID,enrollment by-passes the
Primary ID check and
STR
Expand Down Expand Up @@ -1585,7 +1585,7 @@
end
end

context 'By passes the Secondary ID check when enrollment is Enhanced IPP' do
context 'Bypasses the Secondary ID check when enrollment is Enhanced IPP' do
before do
stub_request_passed_proofing_secondary_id_type_results_ial_2
end
Expand All @@ -1600,6 +1600,57 @@
enhanced_ipp_enrollment: true,
)
end

context 'when an enrollment expires' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are looking good! 👍🏻

before(:each) do
stub_request_expired_enhanced_ipp_proofing_results
end

it_behaves_like(
'enrollment_with_a_status_update',
passed: false,
email_type: 'deadline passed',
enrollment_status: InPersonEnrollment::STATUS_EXPIRED,
response_json: UspsInPersonProofing::Mock::Fixtures.
request_expired_enhanced_ipp_results_response,
enhanced_ipp_enrollment: true,
)

it 'logs that the enrollment expired' do
job.perform(Time.zone.now)

expect(pending_enrollment.proofed_at).to eq(nil)
expect(job_analytics).to have_logged_event(
'GetUspsProofingResultsJob: Enrollment status updated',
hash_including(
reason: 'Enrollment has expired',
job_name: 'GetUspsProofingResultsJob',
enhanced_ipp: true,
),
)
end

context 'when the in_person_stop_expiring_enrollments flag is true' do
before do
allow(IdentityConfig.store).to(
receive(:in_person_stop_expiring_enrollments).and_return(true),
)
end

it 'treats the enrollment as incomplete' do
job.perform(Time.zone.now)

expect(pending_enrollment.status).to eq(InPersonEnrollment::STATUS_PENDING)
expect(job_analytics).to have_logged_event(
'GetUspsProofingResultsJob: Enrollment incomplete',
hash_including(
response_message: 'More than 7 days have passed since opt-in to IPP',
job_name: 'GetUspsProofingResultsJob',
),
)
end
end
end
end
end

Expand Down
22 changes: 18 additions & 4 deletions spec/support/usps_ipp_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,30 @@ def stub_request_enroll_non_hash_response
)
end

def stub_request_expired_proofing_results
def stub_request_expired_enhanced_ipp_proofing_results
stub_request(:post, %r{/ivs-ippaas-api/IPPRest/resources/rest/getProofingResults}).to_return(
**request_expired_proofing_results_args,
**request_expired_enhanced_ipp_results_args,
)
end

def request_expired_proofing_results_args
def request_expired_enhanced_ipp_results_args
{
status: 400,
body: UspsInPersonProofing::Mock::Fixtures.request_expired_proofing_results_response,
body: UspsInPersonProofing::Mock::Fixtures.request_expired_enhanced_ipp_results_response,
headers: { 'content-type' => 'application/json' },
}
end

def stub_request_expired_id_ipp_proofing_results
stub_request(:post, %r{/ivs-ippaas-api/IPPRest/resources/rest/getProofingResults}).to_return(
**request_expired_id_ipp_results_args,
)
end

def request_expired_id_ipp_results_args
{
status: 400,
body: UspsInPersonProofing::Mock::Fixtures.request_expired_id_ipp_results_response,
headers: { 'content-type' => 'application/json' },
}
end
Expand Down