-
Notifications
You must be signed in to change notification settings - Fork 166
LG-7819: Modify enrollment creation CLI tool to create enrollments in USPS API #7302
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
5 commits
Select commit
Hold shift + click to select a range
1fbfae7
LG-7819: Modify enrollment creation CLI tool to create enrollments in…
NavaTim 3b87021
Merge branch 'main' of https://github.com/18F/identity-idp into tbrad…
NavaTim 31d67aa
Remove redundant falsy fallback
NavaTim 0781221
Merge branch 'main' of https://github.com/18F/identity-idp into tbrad…
NavaTim 48fcc9c
LG-7819: Add comment describing reason for number conversion in last …
NavaTim 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,6 +93,8 @@ namespace :dev do | |
| enrollment_status = InPersonEnrollment.statuses[raw_enrollment_status] | ||
| is_established = ['pending', 'passed', 'failed', 'expired'].include?(raw_enrollment_status) | ||
|
|
||
| create_in_usps = !!ENV['CREATE_PENDING_ENROLLMENT_IN_USPS'] | ||
|
|
||
| InPersonEnrollment.transaction do | ||
| (0...num_users).each do |n| | ||
| email_addr = "testuser#{n}@example.com" | ||
|
|
@@ -101,22 +103,48 @@ namespace :dev do | |
| if is_established | ||
| unless raw_enrollment_status == 'pending' && !user.pending_in_person_enrollment.nil? | ||
| profile = Profile.new(user: user) | ||
|
|
||
| # Convert index to a string of letters to be a valid last name for the USPS API | ||
| usps_compatible_number_alternative = n.to_s.chars.map do |c| | ||
| ('a'.ord + c.to_i).chr | ||
| end.join('') | ||
|
|
||
| pii = Pii::Attributes.new_from_hash( | ||
| first_name: 'Test', | ||
| last_name: "User #{n}", | ||
| last_name: "User #{usps_compatible_number_alternative}", | ||
| dob: '1970-05-01', | ||
| ssn: "666-#{n}", # doesn't need to be legit 9 digits, just unique | ||
|
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. Do we need to worry about duplicates across multiple runs?
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. Duplicates are expected, and that's fine. |
||
| address1: '1200 FORESTVILLE DR', | ||
| city: 'GREAT FALLS', | ||
| state: 'VA', | ||
| zipcode: '22066', | ||
| ) | ||
| personal_key = profile.encrypt_pii(pii, pw) | ||
| enrollment = InPersonEnrollment.create!( | ||
| user: user, | ||
| profile: profile, | ||
| status: enrollment_status, | ||
| enrollment_established_at: Time.zone.now - random.rand(0..5).days, | ||
| unique_id: SecureRandom.hex(9), | ||
| enrollment_code: SecureRandom.hex(16), | ||
| ) | ||
| enrollment.profile.activate if raw_enrollment_status == 'passed' | ||
|
|
||
| if raw_enrollment_status === 'pending' && create_in_usps | ||
| enrollment = InPersonEnrollment.find_or_initialize_by( | ||
| user: user, | ||
| status: :establishing, | ||
| profile: profile, | ||
| ) | ||
| enrollment.save! | ||
|
|
||
| UspsInPersonProofing::EnrollmentHelper.schedule_in_person_enrollment( | ||
| user, | ||
| pii, | ||
| ) | ||
| else | ||
| enrollment = InPersonEnrollment.create!( | ||
| user: user, | ||
| profile: profile, | ||
| status: enrollment_status, | ||
| enrollment_established_at: Time.zone.now - random.rand(0..5).days, | ||
| unique_id: SecureRandom.hex(9), | ||
| enrollment_code: SecureRandom.hex(16), | ||
| ) | ||
|
|
||
| enrollment.profile.activate if raw_enrollment_status == 'passed' | ||
| end | ||
| Rails.logger.warn "email=#{email_addr} personal_key=#{personal_key}" | ||
| end | ||
| else | ||
|
|
||
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.
A comment here would aid readability, something as simple as
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.
Added