-
Notifications
You must be signed in to change notification settings - Fork 167
lg-14790 handle network failures for socure #11430
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
AShukla-GSA
merged 18 commits into
main
from
lg-14790-handle-network-failures-for-socure
Nov 7, 2024
Merged
Changes from 3 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4e6a041
changelog: Upcoming Features, socure, implement handle_connection_err…
AShukla-GSA 1cf6a29
added method definition to lower levels and adding spec tests
AShukla-GSA 48ff9cd
Fixing test
AShukla-GSA 7530ec0
Making document_request handle_connection_error return a hash and upd…
AShukla-GSA 022ee68
raising Not implemented at base level
AShukla-GSA 278e169
Resoliving PR comment on socure 401 response
AShukla-GSA fbf0e5e
fixing test
AShukla-GSA eef45c0
Updating test and functionality to handle nil responses and nil respo…
AShukla-GSA c739e0c
simplifying logic
AShukla-GSA ce88d7f
Fixing nil issue
AShukla-GSA adf9ead
Updating tests and logic for 401 and 400 responses
AShukla-GSA cb7da5b
Removing & from json parse
AShukla-GSA b293251
Updating to coding standard and defining handle_invalid_response at t…
AShukla-GSA a8b0577
removing uneeded expects from tests, will be replaced with redirect o…
AShukla-GSA 4c1a0f4
updating to use .test in fake socure testing links
AShukla-GSA 806e0ef
Updating fake_socure_endpoint links
AShukla-GSA 6e1cc06
Adding safe check for response body
AShukla-GSA c8bf9d6
Changing docv_result_request handle_connection_error to return a doc …
AShukla-GSA 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
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
51 changes: 51 additions & 0 deletions
51
spec/services/doc_auth/socure/requests/docv_result_request_spec.rb
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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe DocAuth::Socure::Requests::DocvResultRequest do | ||
| let(:document_capture_session_uuid) { 'fake uuid' } | ||
| let(:biometric_comparison_required) { false } | ||
|
|
||
| subject(:docv_result_request) do | ||
| described_class.new( | ||
| document_capture_session_uuid:, | ||
| biometric_comparison_required: biometric_comparison_required, | ||
| ) | ||
| end | ||
|
|
||
| describe '#fetch' do | ||
| let(:fake_socure_endpoint) { 'https://fake-socure.com/' } | ||
|
AShukla-GSA marked this conversation as resolved.
Outdated
|
||
| let(:fake_socure_api_endpoint) { 'https://fake-socure.com/api/3.0/EmailAuthScore' } | ||
|
AShukla-GSA marked this conversation as resolved.
Outdated
|
||
| let(:docv_transaction_token) { 'fake docv transaction token' } | ||
| let(:user) { create(:user) } | ||
| let(:document_capture_session) do | ||
| DocumentCaptureSession.create(user:).tap do |dcs| | ||
| dcs.socure_docv_transaction_token = docv_transaction_token | ||
| end | ||
| end | ||
|
|
||
| before do | ||
| allow(IdentityConfig.store).to receive(:socure_idplus_base_url). | ||
| and_return(fake_socure_endpoint) | ||
| allow(DocumentCaptureSession).to receive(:find_by).and_return(document_capture_session) | ||
| stub_request(:post, fake_socure_api_endpoint).to_raise(Faraday::ConnectionFailed) | ||
| end | ||
|
|
||
| context 'with timeout exception' do | ||
| let(:fake_socure_response) { {} } | ||
| let(:fake_socure_status) { 500 } | ||
|
|
||
| it 'expect handle_connection_error method to be called' do | ||
| connection_error_attributes = { | ||
| http_response: nil, | ||
| biometric_comparison_required: biometric_comparison_required, | ||
| } | ||
| failed_response = DocAuth::Socure::Responses::DocvResultResponse.new( | ||
| **connection_error_attributes, | ||
| ) | ||
| allow(DocAuth::Socure::Responses::DocvResultResponse).to receive(:new). | ||
| with(**connection_error_attributes). | ||
| and_return(failed_response) | ||
| expect(docv_result_request.fetch).to eq(failed_response) | ||
| end | ||
| end | ||
| end | ||
| end | ||
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.
Uh oh!
There was an error while loading. Please reload this page.