diff --git a/app/services/proofing/aamva/response/authentication_token_response.rb b/app/services/proofing/aamva/response/authentication_token_response.rb index ee2a9190a23..541585bdda0 100644 --- a/app/services/proofing/aamva/response/authentication_token_response.rb +++ b/app/services/proofing/aamva/response/authentication_token_response.rb @@ -6,8 +6,8 @@ class AuthenticationTokenResponse def initialize(http_response) @http_response = http_response - handle_soap_error handle_http_error + handle_soap_error parse_response end diff --git a/app/services/proofing/aamva/response/security_token_response.rb b/app/services/proofing/aamva/response/security_token_response.rb index 6255b019b84..0b2d52760ff 100644 --- a/app/services/proofing/aamva/response/security_token_response.rb +++ b/app/services/proofing/aamva/response/security_token_response.rb @@ -9,8 +9,8 @@ class SecurityTokenResponse def initialize(http_response) @http_response = http_response - handle_soap_error handle_http_error + handle_soap_error parse_response end diff --git a/app/services/proofing/aamva/response/verification_response.rb b/app/services/proofing/aamva/response/verification_response.rb index 62938086233..a5784fcd868 100644 --- a/app/services/proofing/aamva/response/verification_response.rb +++ b/app/services/proofing/aamva/response/verification_response.rb @@ -33,8 +33,8 @@ def initialize(http_response) @missing_attributes = [] @verification_results = {} @http_response = http_response - handle_soap_error handle_http_error + handle_soap_error parse_response end diff --git a/spec/services/proofing/aamva/response/authentication_token_response_spec.rb b/spec/services/proofing/aamva/response/authentication_token_response_spec.rb index f7c65c20ef6..23ad2d37b5f 100644 --- a/spec/services/proofing/aamva/response/authentication_token_response_spec.rb +++ b/spec/services/proofing/aamva/response/authentication_token_response_spec.rb @@ -26,6 +26,18 @@ end end + context 'with a non-200 status code and a non-xml body' do + let(:status_code) { 504 } + let(:response_body) { '

Oh no


This is not xml.' } + + it 'raises a AuthenticationError' do + expect { subject }.to raise_error( + Proofing::Aamva::AuthenticationError, + 'Unexpected status code in response: 504', + ) + end + end + context 'when the API response has an error' do let(:response_body) { AamvaFixtures.soap_fault_response_simplified } diff --git a/spec/services/proofing/aamva/response/security_token_response_spec.rb b/spec/services/proofing/aamva/response/security_token_response_spec.rb index 0f4de27030e..beb19be3d62 100644 --- a/spec/services/proofing/aamva/response/security_token_response_spec.rb +++ b/spec/services/proofing/aamva/response/security_token_response_spec.rb @@ -30,6 +30,18 @@ end end + context 'with a non-200 status code and a non-xml body' do + let(:status_code) { 504 } + let(:response_body) { '

Oh no


This is not xml.' } + + it 'raises a AuthenticationError' do + expect { subject }.to raise_error( + Proofing::Aamva::AuthenticationError, + 'Unexpected status code in response: 504', + ) + end + end + context 'when the API response is an error' do let(:response_body) { AamvaFixtures.soap_fault_response_simplified } diff --git a/spec/services/proofing/aamva/response/verification_response_spec.rb b/spec/services/proofing/aamva/response/verification_response_spec.rb index 2914a81357e..5f5aeff4348 100644 --- a/spec/services/proofing/aamva/response/verification_response_spec.rb +++ b/spec/services/proofing/aamva/response/verification_response_spec.rb @@ -42,6 +42,18 @@ end end + context 'with a non-200 status code and a non-xml body' do + let(:status_code) { 504 } + let(:response_body) { '

Oh no


This is not xml.' } + + it 'raises a VerificationError' do + expect { subject }.to raise_error( + Proofing::Aamva::VerificationError, + 'Unexpected status code in response: 504', + ) + end + end + context 'when the API response has an error' do let(:response_body) { AamvaFixtures.soap_fault_response_simplified }