-
Notifications
You must be signed in to change notification settings - Fork 121
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
Add a mocked version of Socure docauth #11698
Closed
Closed
Changes from all commits
Commits
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 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 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
109 changes: 109 additions & 0 deletions
109
app/controllers/test/mock_socure_document_capture_controller.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# frozen_string_literal: true | ||
|
||
module Test | ||
class MockSocureDocumentCaptureController < ApplicationController | ||
before_action :check_not_in_prod | ||
|
||
def show | ||
if verify? | ||
simulate_socure_docv | ||
return | ||
end | ||
|
||
@url = test_mock_socure_url(verify: 1, hybrid: hybrid? ? 1 : 0) | ||
end | ||
|
||
private | ||
|
||
def check_not_in_prod | ||
render_not_found if Rails.env.production? | ||
end | ||
|
||
def build_fake_docv_result_response | ||
DocAuth::Socure::Responses::DocvResultResponse.new( | ||
http_response: Struct.new(:body, keyword_init: true).new( | ||
body: JSON.generate( | ||
{ | ||
referenceId: SecureRandom.uuid, | ||
documentVerification: { | ||
customerProfile: { | ||
customerUserId: '', | ||
userId: SecureRandom.uuid, | ||
}, | ||
decision: { | ||
name: '', | ||
value: 'accept', | ||
}, | ||
documentData: { | ||
dob: '1938-01-01', | ||
documentNumber: 'ABCD-1234', | ||
expirationDate: (Time.zone.now + 1.year).to_date, | ||
firstName: 'Joey', | ||
issueDate: 3.years.ago.to_date, | ||
middleName: 'Joe-Joe', | ||
surName: 'Junior Shabbadoo', | ||
parsedAddress: { | ||
physicalAddress: '1234 Fake St.', | ||
physicalAddress2: 'Unit 99', | ||
city: 'Fakeville', | ||
state: 'CA', | ||
zip: '90210', | ||
}, | ||
}, | ||
documentType: { | ||
state: 'WA', | ||
country: 'US', | ||
}, | ||
reasonCodes: [], | ||
}, | ||
|
||
}, | ||
), | ||
), | ||
) | ||
end | ||
|
||
def document_capture_session | ||
DocumentCaptureSession.find_by( | ||
uuid: if idv_session.present? | ||
idv_session.document_capture_session_uuid | ||
else | ||
session[:document_capture_session_uuid] | ||
end, | ||
) | ||
end | ||
|
||
def hybrid? | ||
params[:hybrid].to_i == 1 | ||
end | ||
|
||
def idv_session | ||
return nil if user_session.nil? | ||
|
||
@idv_session ||= Idv::Session.new( | ||
user_session: user_session, | ||
current_user: current_user, | ||
service_provider: current_sp, | ||
) | ||
end | ||
|
||
def simulate_socure_docv | ||
# Fake what the Socure webhook processor would've done. | ||
# TODO: It'd be cool to just call the webhook processing code here | ||
|
||
document_capture_session.store_result_from_response( | ||
build_fake_docv_result_response, | ||
) | ||
|
||
if hybrid? | ||
redirect_to idv_hybrid_mobile_capture_complete_url | ||
else | ||
redirect_to idv_socure_document_capture_update_url | ||
end | ||
end | ||
|
||
def verify? | ||
params[:verify].to_i == 1 | ||
end | ||
end | ||
end |
This file contains 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 |
---|---|---|
|
@@ -8,6 +8,12 @@ | |
) %> | ||
<% end %> | ||
|
||
<% if local_assigns.fetch(:show_test_mode_warning, false) %> | ||
<p> | ||
<marquee class="bg-accent-warm" ><strong>FOR TESTING ONLY.</strong> This will only <strong>simulate</strong> verifying your documents.</marquee> | ||
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.
|
||
</p> | ||
<% end %> | ||
|
||
<%= render PageHeadingComponent.new do %> | ||
<%= t('doc_auth.headings.verify_with_phone') %> | ||
<% end %> | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= render 'idv/shared/doc_capture_interstitial', show_test_mode_warning: true %> |
This file contains 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 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.
All deployed environments (including sandbox environments) are considered production. Is that the behavior we're expecting? I see we're also only registering this route if
enable_test_routes
is enabled.I'd wonder if either (a) this isn't needed since we're only registering the route in environments with test routes enabled, or (b) we could rename this to clarify "deployed environments" instead of "production" to try to preempt any potential future misunderstandings.