-
Notifications
You must be signed in to change notification settings - Fork 167
LG-12557: session result success status + portrait match result not requested #10197
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
Changes from all commits
7f61917
e999531
49e3f99
3769854
ba7ca96
1645661
d38248e
e1693e8
10135fe
1b0202b
8920b82
efd8015
cefc72a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,15 +25,17 @@ def update | |
| # Not used in standard flow, here for data consistency with hybrid flow. | ||
| document_capture_session.confirm_ocr | ||
|
|
||
| result = handle_stored_result | ||
| analytics.idv_doc_auth_document_capture_submitted(**result.to_h.merge(analytics_arguments)) | ||
| form_response = handle_stored_result | ||
|
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. 👍 to make it clear. |
||
| analytics.idv_doc_auth_document_capture_submitted( | ||
| **form_response.to_h.merge(analytics_arguments), | ||
| ) | ||
|
|
||
| Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]). | ||
| call('document_capture', :update, true) | ||
|
|
||
| cancel_establishing_in_person_enrollments | ||
|
|
||
| if result.success? | ||
| if form_response.success? | ||
| redirect_to idv_ssn_url | ||
| else | ||
| redirect_to idv_document_capture_url | ||
|
|
@@ -98,7 +100,8 @@ def analytics_arguments | |
| end | ||
|
|
||
| def handle_stored_result | ||
| if stored_result&.success? && selfie_requirement_met? | ||
| if stored_result&.success?(selfie_required: decorated_sp_session.selfie_required?) && | ||
| selfie_requirement_met? | ||
| save_proofing_components(current_user) | ||
| extract_pii_from_doc(current_user, store_in_session: true) | ||
| flash[:success] = t('doc_auth.headings.capture_complete') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,12 +103,13 @@ def billed? | |
| end | ||
|
|
||
| # @return [:success, :fail, :not_processed] | ||
| # When selfie result is missing, return :not_processed | ||
| # When selfie result is missing or not requested: | ||
| # return :not_processed | ||
| # Otherwise: | ||
| # return :success if selfie check result == 'Pass' | ||
| # return :fail | ||
| def selfie_status | ||
| return :not_processed if selfie_result.nil? | ||
| return :not_processed if selfie_result.nil? || !@liveness_checking_enabled | ||
|
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. Good stuff. 👍🏻
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. Nit: Would you be okay with updating the comment on L106? Something like: |
||
| selfie_result == 'Pass' ? :success : :fail | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,9 @@ def selfie_status | |
| self[:selfie_status].to_sym | ||
| end | ||
|
|
||
| def success_status | ||
| def success_status(selfie_required:) | ||
|
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. this seems like a really unexpected place to pass a param, sepecially since this method is aliased as is there any way we can pass the |
||
| # doc_auth_success : including document, attention_with_barcode and id type verification | ||
| !!doc_auth_success && selfie_status != :fail && !!pii | ||
| !!doc_auth_success && (selfie_required ? selfie_status == :success : true) && !!pii | ||
|
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. What was the motivation for changing I’d expect
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. with the presence of selfie_required argument we now have the ability to be more strict which is a more secure to way to say what is a pass as opposed to allowing anything that is !:fail to be a pass. it also safeguards against the potential for values of selfie_status to expand over time and requires us to be explicit about what passes.
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.
Since we determine the values of Both implementations work. I do think the previous implementation is more readable, but YMMV.
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. it's a small add but I do understand your readability sentiment 👍🏿
something to consider 🤔 ... An easier and more readable option could be to simply use the :success attribute since it has all of these scenarios baked in and this bug nor the previous bug would be an issue 😐
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. I think may be we should create a response subclass for selfie required scenario(not now), where it's unambiguous and can decide
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. In retrospective and a little bit of topic, the
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. (I’m not sure the status of this work because I was out yesterday and the jira ticket is in the review column, but I figured I should still respond.) As discussed in past meetings, I will defer to the rest of the team about using the success attribute. I get the argument that you’d rather be explicit about what is a pass, as opposed to what is not a fail. I think my concern is similar to what Zach posted, that this seems like an unexpected place to pass a param. |
||
| end | ||
|
|
||
| alias_method :success?, :success_status | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| let(:back_image) { DocAuthImageFixtures.document_back_image_multipart } | ||
| let(:selfie_img) { nil } | ||
| let(:state_id_number) { 'S59397998' } | ||
| let(:liveness_checking_required) { false } | ||
|
|
||
| describe '#create' do | ||
| subject(:action) do | ||
|
|
@@ -354,6 +355,7 @@ | |
| context 'selfie included' do | ||
| let(:back_image) { DocAuthImageFixtures.portrait_match_success_yaml } | ||
| let(:selfie_img) { DocAuthImageFixtures.selfie_image_multipart } | ||
| let(:liveness_checking_required) { true } | ||
|
|
||
| before do | ||
| allow(controller.decorated_sp_session).to receive(:selfie_required?).and_return(true) | ||
|
|
@@ -368,15 +370,19 @@ | |
| image_source: :unknown, | ||
| user_uuid: an_instance_of(String), | ||
| uuid_prefix: nil, | ||
| liveness_checking_required: true, | ||
| liveness_checking_required: liveness_checking_required, | ||
|
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. Nice clean-up. 👏🏻 |
||
| images_cropped: false, | ||
| ).and_call_original | ||
|
|
||
| action | ||
|
|
||
| expect(response.status).to eq(200) | ||
| expect(json[:success]).to eq(true) | ||
| expect(document_capture_session.reload.load_result.success?).to eq(true) | ||
| expect( | ||
| document_capture_session.reload.load_result.success?( | ||
| selfie_required: liveness_checking_required, | ||
| ), | ||
| ).to eq(true) | ||
| expect(document_capture_session.reload.load_result.selfie_check_performed?).to eq(true) | ||
| end | ||
| end | ||
|
|
@@ -390,15 +396,18 @@ | |
| image_source: :unknown, | ||
| user_uuid: an_instance_of(String), | ||
| uuid_prefix: nil, | ||
| liveness_checking_required: false, | ||
| liveness_checking_required: liveness_checking_required, | ||
| images_cropped: false, | ||
| ).and_call_original | ||
|
|
||
| action | ||
|
|
||
| expect(response.status).to eq(200) | ||
| expect(json[:success]).to eq(true) | ||
| expect(document_capture_session.reload.load_result.success?).to eq(true) | ||
| expect( | ||
| document_capture_session.reload.load_result. | ||
| success?(selfie_required: liveness_checking_required), | ||
| ).to eq(true) | ||
| end | ||
|
|
||
| it 'tracks events' do | ||
|
|
@@ -1271,12 +1280,17 @@ | |
|
|
||
| let(:back_image) { DocAuthImageFixtures.portrait_match_success_yaml } | ||
| let(:selfie_img) { DocAuthImageFixtures.selfie_image_multipart } | ||
| let(:liveness_checking_required) { true } | ||
|
|
||
| it 'returns a successful response' do | ||
| action | ||
| expect(response.status).to eq(200) | ||
| expect(json[:success]).to eq(true) | ||
| expect(document_capture_session.reload.load_result.success?).to eq(true) | ||
| expect( | ||
| document_capture_session.reload.load_result.success?( | ||
| selfie_required: liveness_checking_required, | ||
| ), | ||
| ).to eq(true) | ||
| expect(document_capture_session.reload.load_result.selfie_check_performed?).to eq(true) | ||
| end | ||
|
|
||
|
|
@@ -1296,7 +1310,11 @@ | |
| action | ||
| expect(response.status).to eq(200) | ||
| expect(json[:success]).to eq(true) | ||
| expect(document_capture_session.reload.load_result.success?).to eq(true) | ||
| expect( | ||
| document_capture_session.reload.load_result.success?( | ||
| selfie_required: liveness_checking_required, | ||
| ), | ||
| ).to eq(true) | ||
| end | ||
| end | ||
| end | ||
|
|
||
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.
This makes me think the session result should reflect all business logic?