LG-10759 Fix State Address Validation#9134
Conversation
gina-yamada
left a comment
There was a problem hiding this comment.
Tested both same as address and different and working as expected.
Both an empty value and a value of only spaces display a validation message for both address 1 and city on the page. In both cases, a user can not continue until fields are entered.
LGTM
| # rubocop:disable Style/MultilineIfModifier | ||
| validates :identity_doc_address1, | ||
| :identity_doc_city, | ||
| presence: true if IdentityConfig.store.in_person_capture_secondary_id_enabled | ||
| # rubocop:enable Style/MultilineIfModifier |
There was a problem hiding this comment.
To avoid the lint, could we use .presence on the config value, since it'd be true if true, and nil if false, and I think that's the behavior you're after?
[1] pry(main)> false.presence
=> nil
[2] pry(main)> true.presence
=> true| # rubocop:disable Style/MultilineIfModifier | |
| validates :identity_doc_address1, | |
| :identity_doc_city, | |
| presence: true if IdentityConfig.store.in_person_capture_secondary_id_enabled | |
| # rubocop:enable Style/MultilineIfModifier | |
| validates :identity_doc_address1, | |
| :identity_doc_city, | |
| presence: IdentityConfig.store.in_person_capture_secondary_id_enabled.presence |
|
@aduth @NavaTim I wanted to only validate those fields if the user has encountered dav in order to fix the pii detected error I'm seeing for some of the other specs. However the form is still logging pii in specs when dav is not enabled for the user. Part of what I thought was the issue was the |
First, update the conditional validation and check if the issue is still happening. The conditional you currently have is evaluated with the class definition, so the validator may not actually be added/removed between tests. If that doesn't fix it, then here's some more context.The address field name is making it into the error details, which makes it into the log entry via the The safest way to prevent the issue is to scrub the error entirely, similar to how the transliteration errors were removed (though that removes potentially valuable info from logs). An alternative would be manually adding |
NavaTim
left a comment
There was a problem hiding this comment.
The implementation looks good, but we should simplify the tests before proceeding.
| fill_in t('in_person_proofing.form.state_id.state_id_number'), with: GOOD_STATE_ID_NUMBER | ||
|
|
||
| if double_address_verification | ||
| if double_address_verification && capture_secondary_id_enabled |
There was a problem hiding this comment.
double_address_verification and capture_secondary_id_enabled appear to be synonymous with regard to the test helpers. Do we really need an additional parameter here?
There was a problem hiding this comment.
good point, i did think about removing double_address_verification from the places where I checked capture_secondary_id_enabled but had decided against it since other tests are still using dav and wanted to minimize any confusion. But it is a bit redundant. I'll remove dav from the tests I updated.
NavaTim
left a comment
There was a problem hiding this comment.
I would prefer some additional test changes, but approving since the issue is likely to become moot very soon.
| fill_out_state_id_form_ok(same_address_as_id: false, capture_secondary_id_enabled: true) | ||
| click_idv_continue | ||
| fill_out_address_form_ok(double_address_verification: true, same_address_as_id: false) |
There was a problem hiding this comment.
The usage of both double_address_verification and capture_secondary_id_enabled here seems likely to cause confusion. I think we should only use one or the other for the test methods in general unless a specific test needs to differentiate.
My preferred approach in this case is reverting to double_address_verification for most usages & mapping to capture_secondary_id_enabled where needed.
There was a problem hiding this comment.
i'm going to go ahead and merge since we'll be removing dav though I understand it might be confusing to see the different params for state_id_form vs address_form

🎫 Ticket
LG-10759
🛠 Summary of changes
This fixes a bug that allowed a user to submit the state id form with blank spaces at Address Line 1 and City. If the user did this and clicked true for
same_address_as_idthen on submission the next page is not rendered. This pr adds those fields to the state id validator to make sure the user input is validated.📜 Testing Plan
Provide a checklist of steps to confirm the changes.
in_person_capture_secondary_id_enabledto truesame_address_as_idto no and re-submit👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.