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
4 changes: 0 additions & 4 deletions app/services/usps_in_person_proofing/mock/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ def self.request_in_progress_proofing_results_response
load_response_fixture('request_in_progress_proofing_results_response.json')
end

def self.request_enrollment_code_response
load_response_fixture('request_enrollment_code_response.json')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the file app/services/usps_in_person_proofing/mock/responses/request_enrollment_code_response.json be removed as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See commit 210c9e0.

end

def self.load_response_fixture(filename)
path = File.join(
File.dirname(__FILE__),
Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions app/services/usps_in_person_proofing/proofer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,6 @@ def request_proofing_results(enrollment)
end.body
end

# Makes HTTP request to retrieve enrollment code
# If an applicant has a currently valid enrollment code, it will be returned.
# If they do not, a new one will be generated and returned. USPS sends the applicant an email
# with instructions and the enrollment code.
# Requires the applicant's unique ID.
# @param unique_id [String]
# @return [Hash] API response
def request_enrollment_code(unique_id)
url = "#{root_url}/ivs-ippaas-api/IPPRest/resources/rest/requestEnrollmentCode"
request_body = {
sponsorID: sponsor_id,
uniqueID: unique_id,
}

faraday.post(url, request_body, dynamic_headers) do |req|
req.options.context = { service_name: 'usps_enrollment_code' }
end.body
end

# Makes a request to retrieve a new OAuth token, caches it, and returns it. Tokens have
# historically had 15 minute expirys
# @return [String] the token
Expand Down
46 changes: 0 additions & 46 deletions spec/services/usps_in_person_proofing/proofer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -493,50 +493,4 @@ def expect_facility_fields_to_be_present(facility)
end
end
end

describe '#request_enrollment_code' do
let(:applicant) do
double(
'applicant',
unique_id: '123456789',
)
end

before(:each) do
stub_request_token
end

it 'returns enrollment information' do
stub_request_enrollment_code

enrollment = subject.request_enrollment_code(applicant)
expect(enrollment['enrollmentCode']).to be_present
expect(enrollment['responseMessage']).to be_present
end

context 'when the auth token is expired' do
expires_at = nil
let(:expires_in) { 15.minutes }

before do
stub_request_enrollment_code
end

before(:each) do
subject.retrieve_token!
expires_at = Time.zone.now + expires_in
end

it 'refreshes the auth token before making the request' do
enrollment = nil
travel_to(expires_at) do
enrollment = subject.request_enrollment_code(applicant)
end

expect(WebMock).to have_requested(:post, "#{root_url}/oauth/authenticate").twice
expect(enrollment['enrollmentCode']).to be_present
expect(enrollment['responseMessage']).to be_present
end
end
end
end
15 changes: 0 additions & 15 deletions spec/support/usps_ipp_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,6 @@ def stub_request_proofing_results_with_invalid_response
)
end

def stub_request_enrollment_code
stub_request(:post, %r{/ivs-ippaas-api/IPPRest/resources/rest/requestEnrollmentCode}).to_return(
status: 200,
body: UspsInPersonProofing::Mock::Fixtures.request_enrollment_code_response,
headers: { 'content-type' => 'application/json' },
)
end

def stub_request_enrollment_code_with_forbidden_error
stub_request(
:post,
%r{/ivs-ippaas-api/IPPRest/resources/rest/requestEnrollmentCode},
).to_raise(Faraday::ForbiddenError)
end

private

# Merges an object into the JSON string of a response's body and returns the updated response
Expand Down