-
Notifications
You must be signed in to change notification settings - Fork 166
LG-7275 Expand metrics for USPS proofing attempts #6967
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fba34bf
expand metrics for USPS proofing attempts
eileen-nava 623a90e
Merge branch 'main' into em/7275-proof-attempt-metrics
eileen-nava dc29936
LG-7275 Expand metrics for USPS proofing attempts
eileen-nava 63d66bd
enumerate params from analytics methods
eileen-nava 689c5bc
refactor usps proofing tests to be DRYer
eileen-nava 25ca8a9
clean up usps proofing job and spec
eileen-nava ae8baf4
tweak fixtures for expired id & unsupported status
eileen-nava a94dbd7
clean up formatting and fixture
eileen-nava File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 2 additions & 14 deletions
16
...ces/usps_in_person_proofing/mock/responses/request_expired_proofing_results_response.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,3 @@ | ||
| { | ||
| "status": "In-person expired", | ||
| "proofingPostOffice": "WILKES BARRE", | ||
| "proofingCity": "WILKES BARRE", | ||
| "proofingState": "PA", | ||
| "enrollmentCode": "2090002197604352", | ||
| "primaryIdType": "Uniformed Services identification card", | ||
| "transactionStartDateTime": "12/17/2020 033855", | ||
| "transactionEndDateTime": "12/17/2020 034055", | ||
| "secondaryIdType": "Deed of Trust", | ||
| "responseMessage": "More than 30 days have passed since opt-in to IPP", | ||
| "fraudSuspected": false, | ||
| "proofingConfirmationNumber": "350040248346707", | ||
| "ippAssuranceLevel": "1.5" | ||
| } | ||
| "responseMessage": "More than 30 days have passed since opt-in to IPP" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.shared_examples 'enrollment with a status update' do |passed:, status:| | ||
| RSpec.shared_examples 'enrollment with a status update' do |passed:, status:, response_json:| | ||
| it 'logs a message with common attributes' do | ||
| freeze_time do | ||
| pending_enrollment.update( | ||
|
|
@@ -12,14 +12,28 @@ | |
| job.perform(Time.zone.now) | ||
| end | ||
|
|
||
| response = JSON.parse(response_json) | ||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Enrollment status updated', | ||
| assurance_level: response['assuranceLevel'], | ||
| enrollment_code: pending_enrollment.enrollment_code, | ||
| enrollment_id: pending_enrollment.id, | ||
| failure_reason: response['failureReason'], | ||
| fraud_suspected: response['fraudSuspected'], | ||
| minutes_since_last_status_check: 15.0, | ||
| minutes_since_last_status_update: 2.days.in_minutes, | ||
| minutes_to_completion: 3.days.in_minutes, | ||
| passed: passed, | ||
| primary_id_type: response['primaryIdType'], | ||
| proofing_city: response['proofingCity'], | ||
| proofing_post_office: response['proofingPostOffice'], | ||
| proofing_state: response['proofingState'], | ||
| response_message: response['responseMessage'], | ||
| scan_count: response['scanCount'], | ||
| secondary_id_type: response['secondaryIdType'], | ||
| status: response['status'], | ||
| transaction_end_date_time: response['transactionEndDateTime'], | ||
| transaction_start_date_time: response['transactionStartDateTime'], | ||
| ) | ||
| end | ||
|
|
||
|
|
@@ -300,14 +314,19 @@ | |
| stub_request_passed_proofing_results | ||
| end | ||
|
|
||
| it_behaves_like('enrollment with a status update', passed: true, status: 'passed') | ||
| it_behaves_like( | ||
| 'enrollment with a status update', | ||
| passed: true, | ||
| status: 'passed', | ||
| response_json: UspsInPersonProofing::Mock::Fixtures. | ||
| request_passed_proofing_results_response, | ||
| ) | ||
|
|
||
| it 'logs details about the success' do | ||
| job.perform(Time.zone.now) | ||
|
|
||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Enrollment status updated', | ||
| fraud_suspected: false, | ||
| reason: 'Successful status update', | ||
| ) | ||
| end | ||
|
|
@@ -318,21 +337,19 @@ | |
| stub_request_failed_proofing_results | ||
| end | ||
|
|
||
| it_behaves_like('enrollment with a status update', passed: false, status: 'failed') | ||
| it_behaves_like( | ||
| 'enrollment with a status update', | ||
| passed: false, | ||
| status: 'failed', | ||
| response_json: UspsInPersonProofing::Mock::Fixtures. | ||
| request_failed_proofing_results_response, | ||
| ) | ||
|
|
||
| it 'logs failure details' do | ||
| job.perform(Time.zone.now) | ||
|
|
||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Enrollment status updated', | ||
| failure_reason: 'Clerk indicates that ID name or address does not match source data.', | ||
| fraud_suspected: false, | ||
| primary_id_type: 'Uniformed Services identification card', | ||
| proofing_state: 'PA', | ||
| reason: 'Failed status', | ||
| secondary_id_type: 'Deed of Trust', | ||
| transaction_end_date_time: '12/17/2020 034055', | ||
| transaction_start_date_time: '12/17/2020 033855', | ||
|
Comment on lines
-328
to
-335
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 |
||
| ) | ||
| end | ||
| end | ||
|
|
@@ -342,15 +359,19 @@ | |
| stub_request_passed_proofing_unsupported_id_results | ||
| end | ||
|
|
||
| it_behaves_like('enrollment with a status update', passed: false, status: 'failed') | ||
| it_behaves_like( | ||
| 'enrollment with a status update', | ||
| passed: false, | ||
| status: 'failed', | ||
| response_json: UspsInPersonProofing::Mock::Fixtures. | ||
| request_passed_proofing_unsupported_id_results_response, | ||
| ) | ||
|
|
||
| it 'logs a message about the unsupported ID' do | ||
| job.perform Time.zone.now | ||
|
|
||
| expect(job_analytics).to have_logged_event( | ||
| 'GetUspsProofingResultsJob: Enrollment status updated', | ||
| fraud_suspected: false, | ||
| primary_id_type: 'Not supported', | ||
| reason: 'Unsupported ID type', | ||
| ) | ||
| end | ||
|
|
@@ -361,7 +382,13 @@ | |
| stub_request_expired_proofing_results | ||
| end | ||
|
|
||
| it_behaves_like('enrollment with a status update', passed: false, status: 'expired') | ||
| it_behaves_like( | ||
| 'enrollment with a status update', | ||
| passed: false, | ||
| status: 'expired', | ||
| response_json: UspsInPersonProofing::Mock::Fixtures. | ||
| request_expired_proofing_results_response, | ||
| ) | ||
|
|
||
| it 'logs that the enrollment expired' do | ||
| job.perform(Time.zone.now) | ||
|
|
@@ -378,15 +405,21 @@ | |
| stub_request_proofing_results_with_responses({}) | ||
| end | ||
|
|
||
| it_behaves_like('enrollment encountering an exception', reason: 'Bad response structure') | ||
| it_behaves_like( | ||
| 'enrollment encountering an exception', | ||
| reason: 'Bad response structure', | ||
| ) | ||
| end | ||
|
|
||
| context 'when USPS returns an unexpected status' do | ||
| before(:each) do | ||
| stub_request_passed_proofing_unsupported_status_results | ||
| end | ||
|
|
||
| it_behaves_like('enrollment encountering an exception', reason: 'Unsupported status') | ||
| it_behaves_like( | ||
| 'enrollment encountering an exception', | ||
| reason: 'Unsupported status', | ||
| ) | ||
|
|
||
| it 'logs the status received' do | ||
| job.perform(Time.zone.now) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO I think all this switching of cases might be a good hint to move the processing of the response to the USPS proofer client class, have it return a
Structor equivalent object that has snake_case keys already (similar to https://cm-jira.usa.gov/browse/LG-7025)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this point! I will make another ticket to address it.