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
54 changes: 54 additions & 0 deletions app/services/idv/inherited_proofing/va/mocks/service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module Idv
module InheritedProofing
module Va
module Mocks
class Service
VALID_AUTH_CODE = 'mocked-auth-code-for-testing'.freeze

attr_reader :auth_code

PAYLOAD_HASH = {
first_name: 'Fakey',
last_name: 'Fakerson',
address: {
street: '123 Fake St',
street2: 'Apt 235',
city: 'Faketown',
state: 'WA',
country: nil,
zip: '98037',
},
phone: '2063119187',
birth_date: '2022-1-31',
ssn: '123456789',
mhv_data: {
mhvId: 99999999,
identityProofedMethod: 'IPA',
identityDocumentExist: true,
identityProofingDate: '2020-12-14',
identityDocumentInfo: {
primaryIdentityDocumentNumber: '88888888',
primaryIdentityDocumentType: 'StateIssuedId',
primaryIdentityDocumentCountry: 'United States',
primaryIdentityDocumentExpirationDate: '2222-03-30',
},
},
}.freeze

def initialize(auth_code)
@auth_code = auth_code
end

def execute
if (@auth_code != VALID_AUTH_CODE)
raise TypeError,
"auth_code is invalid: #{@auth_code}"
end

PAYLOAD_HASH
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'rails_helper'

RSpec.describe 'Inherited Proofing VA API Proofer Service' do
subject(:form) { Idv::InheritedProofing::Va::Form.new(payload_hash: proofer_results) }

let(:proofer_results) { Idv::InheritedProofing::Va::Mocks::Service.new(auth_code).execute }
let(:auth_code) { Idv::InheritedProofing::Va::Mocks::Service::VALID_AUTH_CODE }

context 'when used with the VA Inherited Proofing Response Form' do
it 'works as expected' do
expect(form.submit.success?).to eq true
end
end
end
28 changes: 28 additions & 0 deletions spec/services/idv/inherited_proofing/va/mocks/service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'rails_helper'

RSpec.describe Idv::InheritedProofing::Va::Mocks::Service do
subject { described_class.new(auth_code) }
let(:auth_code) { described_class::VALID_AUTH_CODE }

describe '#initialize' do
it 'sets #auth_code' do
expect(subject.auth_code).to eq auth_code
end
end

describe '#execute' do
context 'when auth_code is valid' do
it 'returns a Hash' do
expect(subject.execute).to eq(described_class::PAYLOAD_HASH)
end
end

context 'with auth code is invalid' do
let(:auth_code) { "invalid-#{described_class::VALID_AUTH_CODE}" }

it 'returns an error' do
expect { subject.execute }.to raise_error(/auth_code is invalid/)
end
end
end
end