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 @@ -15,7 +15,7 @@ def initialize(body)

def parse_response
unless body.is_a?(Hash)
raise StandardError.new("Expected a hash but got a #{body.class.class_name}")
raise StandardError.new("Expected a hash but got a #{body.class.name}")
end

unless body['enrollmentCode']
Expand Down
20 changes: 20 additions & 0 deletions spec/controllers/idv/review_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,26 @@ def show
end
end

context 'when the USPS response is not a hash' do
let(:stub_usps_response) do
stub_request_enroll_non_hash_response
end

it 'logs an error message' do
put :create, params: { user: { password: ControllerHelper::VALID_PASSWORD } }

expect(@analytics).to have_logged_event(
'USPS IPPaaS enrollment failed',
context: 'authentication',
enrollment_id: enrollment.id,
exception_class: 'UspsInPersonProofing::Exception::RequestEnrollException',
exception_message: 'Expected a hash but got a NilClass',
original_exception_class: 'StandardError',
reason: 'Request exception',
)
end
end

context 'when the USPS response is missing an enrollment code' do
let(:stub_usps_response) do
stub_request_enroll_invalid_response
Expand Down
8 changes: 8 additions & 0 deletions spec/support/usps_ipp_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def stub_request_enroll_invalid_response
)
end

def stub_request_enroll_non_hash_response
stub_request(:post, %r{/ivs-ippaas-api/IPPRest/resources/rest/optInIPPApplicant}).to_return(
status: 200,
body: nil,
headers: { 'content-type' => 'application/json' },
)
end

def stub_request_expired_proofing_results
stub_request(:post, %r{/ivs-ippaas-api/IPPRest/resources/rest/getProofingResults}).to_return(
**request_expired_proofing_results_args,
Expand Down