Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class DocumentCaptureController < ApplicationController
include DocumentCaptureConcern
include Idv::HybridMobile::HybridMobileConcern
include RenderConditionConcern
include DocumentCaptureConcern

check_or_render_not_found -> { IdentityConfig.store.socure_enabled }
before_action :check_valid_document_capture_session, except: [:update]
Expand All @@ -19,7 +20,7 @@ def show

# document request
document_request = DocAuth::Socure::Requests::DocumentRequest.new(
redirect_url: idv_hybrid_mobile_socure_document_capture_url,
redirect_url: idv_hybrid_mobile_socure_document_capture_update_url,
language: I18n.locale,
)
document_response = document_request.fetch
Expand Down Expand Up @@ -49,7 +50,16 @@ def show
end

def update
render plain: 'stub to ensure Socure callback exists and the route works'
result = handle_stored_result(
user: document_capture_session.user,
store_in_session: false,
)

if result.success?
redirect_to idv_ssn_url
else
redirect_to idv_hybrid_mobile_socure_document_capture_url
end
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/idv/socure/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def update
Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]).
call('socure_document_capture', :update, true)

cancel_establishing_in_person_enrollments

if result.success?
redirect_to idv_ssn_url
else
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
put '/hybrid_mobile/document_capture' => 'hybrid_mobile/document_capture#update'
get '/hybrid_mobile/capture_complete' => 'hybrid_mobile/capture_complete#show'
get '/hybrid_mobile/socure/document_capture' => 'hybrid_mobile/socure/document_capture#show'
post '/hybrid_mobile/socure/document_capture' => 'hybrid_mobile/socure/document_capture#update'
get '/hybrid_mobile/socure/document_capture_update' => 'hybrid_mobile/socure/document_capture#update', as: :hybrid_mobile_socure_document_capture_update
get '/hybrid_handoff' => 'hybrid_handoff#show'
put '/hybrid_handoff' => 'hybrid_handoff#update'
get '/link_sent' => 'link_sent#show'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
allow(IdentityConfig.store).to receive(:doc_auth_vendor_default).and_return(idv_vendor)

allow(subject).to receive(:stored_result).and_return(stored_result)

session[:doc_capture_user_id] = user&.id
session[:document_capture_session_uuid] = document_capture_session_uuid
end

describe 'before_actions' do
Expand All @@ -48,9 +51,6 @@
status: 200,
body: JSON.generate(response_body),
)

session[:doc_capture_user_id] = user&.id
session[:document_capture_session_uuid] = document_capture_session_uuid
end

context 'with no user id in session' do
Expand Down Expand Up @@ -97,7 +97,7 @@
it 'creates a DocumentRequest' do
expect(request_class).to have_received(:new).
with(
redirect_url: idv_hybrid_mobile_socure_document_capture_url,
redirect_url: idv_hybrid_mobile_socure_document_capture_update_url,
language: expected_language,
)
end
Expand All @@ -119,7 +119,7 @@
documentType: 'license',
redirect: {
method: 'GET',
url: idv_hybrid_mobile_socure_document_capture_url,
url: idv_hybrid_mobile_socure_document_capture_update_url,
},
language: expected_language,
},
Expand All @@ -141,7 +141,7 @@
documentType: 'license',
redirect: {
method: 'GET',
url: idv_hybrid_mobile_socure_document_capture_url,
url: idv_hybrid_mobile_socure_document_capture_update_url,
},
language: 'zh-cn',
},
Expand Down Expand Up @@ -257,19 +257,48 @@
end

describe '#update' do
it 'returns OK (200)' do
post(:update)
let(:stored_result) do
DocumentCaptureSessionResult.new(
success: true,
selfie_status: 'not_processed',
pii: { state: 'MD' },
)
end

before do
stub_sign_in(user)
end

it 'redirects to the ssn page' do
get(:update)

expect(response).to have_http_status(:ok)
expect(response).to redirect_to(idv_ssn_url)
end

context 'when socure is disabled' do
let(:socure_enabled) { false }

it 'the webhook route does not exist' do
post(:update)
get(:update)

expect(response).to be_not_found
end
end

context 'when socure reports failure' do
let(:stored_result) do
DocumentCaptureSessionResult.new(
success: false,
selfie_status: 'not_processed',
pii: { state: 'MD' },
)
end

it 'redirects back to the capture page' do
get(:update)

expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_url)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
end

describe '#update' do
it 'returns OK (200)' do
it 'returns FOUND (302) and redirects to SSN' do
get(:update)

expect(response).to redirect_to(idv_ssn_path)
Expand All @@ -288,8 +288,9 @@

context 'when socure is disabled' do
let(:socure_enabled) { false }

it 'the webhook route does not exist' do
post(:update)
get(:update)

expect(response).to be_not_found
end
Expand Down