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
2 changes: 2 additions & 0 deletions app/controllers/idv/inherited_proofing_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Idv
class InheritedProofingController < ApplicationController
include Flow::FlowStateMachine
include IdvSession
include InheritedProofingConcern

before_action :render_404_if_disabled

Expand Down
5 changes: 5 additions & 0 deletions app/services/idv/flows/inherited_proofing_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class InheritedProofingFlow < Flow::BaseFlow
def initialize(controller, session, name)
@idv_session = self.class.session_idv(session)
super(controller, STEPS, ACTIONS, session[name])

@flow_session ||= {}
@flow_session[:pii_from_user] ||= { uuid: current_user.uuid }
applicant = @idv_session['applicant'] || {}
@flow_session[:pii_from_user] = @flow_session[:pii_from_user].to_h.merge(applicant)
end

def self.session_idv(session)
Expand Down
4 changes: 4 additions & 0 deletions app/services/idv/steps/inherited_proofing/agreement_step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ module Idv
module Steps
module InheritedProofing
class AgreementStep < InheritedProofingBaseStep
include UserPiiManagable

STEP_INDICATOR_STEP = :getting_started

def call
inherited_proofing_save_user_pii_to_session!
inherited_proofing_form_response
end

def form_submit
Expand Down
37 changes: 37 additions & 0 deletions app/services/idv/steps/inherited_proofing/user_pii_managable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Idv
module Steps
module InheritedProofing
module UserPiiManagable
include UserPiiRetrievable

def inherited_proofing_save_user_pii_to_session!
inherited_proofing_save_session!
inherited_proofing_skip_steps!
end

private

def inherited_proofing_save_session!
return unless inherited_proofing_form_response.success?

flow_session[:pii_from_user] =
flow_session[:pii_from_user].to_h.merge(inherited_proofing_user_pii)
# This is unnecessary, but added for completeness. Any subsequent FLOWS we
# might splice into will pull from idv_session['applicant'] and merge into
# flow_session[:pii_from_user] anyhow in their #initialize(r); any subsequent
# STEP FLOWS we might splice into will populate idv_session['applicant'] and
# ultimately get merged in to flow_session[:pii_from_user] as well.
idv_session['applicant'] = flow_session[:pii_from_user]
end

def inherited_proofing_skip_steps!
idv_session['profile_confirmation'] = true
idv_session['vendor_phone_confirmation'] = false
idv_session['user_phone_confirmation'] = false
idv_session['address_verification_mechanism'] = 'phone'
idv_session['resolution_successful'] = 'phone'
end
end
end
end
end
39 changes: 39 additions & 0 deletions app/services/idv/steps/inherited_proofing/user_pii_retrievable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Idv
module Steps
module InheritedProofing
module UserPiiRetrievable
def inherited_proofing_user_pii
inherited_proofing_info[0]
end

def inherited_proofing_form_response
inherited_proofing_info[1]
end

private

# This needs error handling.
def inherited_proofing_info
return @inherited_proofing_info if defined? @inherited_proofing_info

payload_hash = inherited_proofing_service.execute.dup
form = inherited_proofing_form(payload_hash)
form_response = form.submit

user_pii = {}
user_pii = form.user_pii if form_response.success?

@inherited_proofing_info = [user_pii, form_response]
end

def inherited_proofing_service
controller.inherited_proofing_service
end

def inherited_proofing_form(payload_hash)
controller.inherited_proofing_form payload_hash
end
end
end
end
end
2 changes: 2 additions & 0 deletions app/services/idv/steps/inherited_proofing_base_step.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Idv
module Steps
class InheritedProofingBaseStep < Flow::BaseStep
delegate :controller, :idv_session, to: :@flow

def initialize(flow)
super(flow, :inherited_proofing)
end
Expand Down
1 change: 1 addition & 0 deletions lib/session_encryptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SensitiveValueError < StandardError; end
# personal keys are generated and stored in the session between requests, but are used
# to decrypt PII bundles, so we treat them similarly to the PII itself.
SENSITIVE_PATHS = [
['warden.user.user.session', 'idv/inherited_proofing'],
['warden.user.user.session', 'idv/doc_auth'],
['warden.user.user.session', 'idv/in_person'],
['warden.user.user.session', 'idv'],
Expand Down
32 changes: 29 additions & 3 deletions spec/controllers/idv/inherited_proofing_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe Idv::InheritedProofingController do
shared_examples 'the flow steps work correctly' do
describe '#index' do
it 'redirects to the first step' do
get :index
Expand Down Expand Up @@ -50,8 +50,34 @@
expect(response).to redirect_to idv_inherited_proofing_step_url(step: :get_started)
end
end
end

def mock_next_step(step)
allow_any_instance_of(Idv::Flows::InheritedProofingFlow).to receive(:next_step).and_return(step)
end

describe Idv::InheritedProofingController do
let(:sp) { nil }
let(:user) { build(:user) }

before do
allow(controller).to receive(:current_sp).and_return(sp)
stub_sign_in(user)
end

context 'when VA inherited proofing mock is enabled' do
before do
allow(IdentityConfig.store).to receive(:va_inherited_proofing_mock_enabled).and_return(true)
end

it_behaves_like 'the flow steps work correctly'
end

context 'when VA inherited proofing mock is not enabled' do
before do
allow(IdentityConfig.store).to receive(:va_inherited_proofing_mock_enabled).and_return(false)
end

def mock_next_step(step)
allow_any_instance_of(Idv::Flows::InheritedProofingFlow).to receive(:next_step).and_return(step)
it_behaves_like 'the flow steps work correctly'
end
end
10 changes: 10 additions & 0 deletions spec/features/idv/inherited_proofing/agreement_step_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
include IdvHelper
include DocAuthHelper

before do
allow(IdentityConfig.store).to receive(:va_inherited_proofing_mock_enabled).and_return true
allow_any_instance_of(Idv::InheritedProofingController).to \
receive(:va_inherited_proofing?).and_return true
allow_any_instance_of(Idv::InheritedProofingController).to \
receive(:va_inherited_proofing_auth_code).and_return auth_code
end

let(:auth_code) { Idv::InheritedProofing::Va::Mocks::Service::VALID_AUTH_CODE }

def expect_ip_verify_info_step
expect(page).to have_current_path(idv_ip_verify_info_step)
end
Expand Down