From 5bc52d54dea30d765301541cefd38c3362e7b9b6 Mon Sep 17 00:00:00 2001 From: timothy-spencer Date: Fri, 13 Oct 2017 09:49:07 -0700 Subject: [PATCH] Remove Twilio proxy feature __Why__ * In earlier versions of the Twilio gem, using an HTTP proxy required passing in `proxy_addr` and `proxy_port` arguments, but those aren't supported anymore in the current version of the gem. The default Twilio client we use seems to work out of the box with an HTTP proxy, so we can remove any proxy-related code from our app. --- app/services/twilio_service.rb | 19 -------------- config/application.yml.example | 2 -- spec/services/twilio_service_spec.rb | 38 ---------------------------- 3 files changed, 59 deletions(-) diff --git a/app/services/twilio_service.rb b/app/services/twilio_service.rb index 54c64170fa6..117d14abba4 100644 --- a/app/services/twilio_service.rb +++ b/app/services/twilio_service.rb @@ -9,8 +9,6 @@ class TwilioService def initialize @client = if FeatureManagement.telephony_disabled? NullTwilioClient.new - elsif proxy_addr.present? - twilio_proxy_client else twilio_client end @@ -42,23 +40,6 @@ def from_number attr_reader :client - def proxy_addr - Figaro.env.proxy_addr - end - - def proxy_port - Figaro.env.proxy_port - end - - def twilio_proxy_client - telephony_service.new( - account['sid'], - account['auth_token'], - proxy_addr: proxy_addr, - proxy_port: proxy_port - ) - end - def twilio_client telephony_service.new( account['sid'], diff --git a/config/application.yml.example b/config/application.yml.example index b7bc6fa4016..d1541cc2e50 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -155,8 +155,6 @@ production: password_pepper: # generate via `rake secret` password_strength_enabled: 'true' proofing_vendors: 'mock' - proxy_addr: - proxy_port: reauthn_window: '120' redis_url: 'redis://redis.login.gov.internal:6379' requests_per_ip_limit: '300' diff --git a/spec/services/twilio_service_spec.rb b/spec/services/twilio_service_spec.rb index 1aab3c58bd4..eef2faa8d9f 100644 --- a/spec/services/twilio_service_spec.rb +++ b/spec/services/twilio_service_spec.rb @@ -1,33 +1,6 @@ require 'rails_helper' describe TwilioService do - describe 'proxy configuration' do - it 'ignores the proxy configuration if not set' do - TwilioService.telephony_service = Twilio::REST::Client - - expect(Figaro.env).to receive(:proxy_addr).and_return(nil) - expect(Twilio::REST::Client).to receive(:new).with(/sid(1|2)/, /token(1|2)/) - - TwilioService.new - end - - it 'passes the proxy configuration if set' do - TwilioService.telephony_service = Twilio::REST::Client - - expect(Figaro.env).to receive(:proxy_addr).at_least(:once).and_return('123.456.789') - expect(Figaro.env).to receive(:proxy_port).and_return('6000') - - expect(Twilio::REST::Client).to receive(:new).with( - /sid(1|2)/, - /token(1|2)/, - proxy_addr: '123.456.789', - proxy_port: '6000' - ) - - TwilioService.new - end - end - context 'when telephony is disabled' do before do expect(FeatureManagement).to receive(:telephony_disabled?).at_least(:once).and_return(true) @@ -42,17 +15,6 @@ TwilioService.new end - it 'uses NullTwilioClient when proxy is set' do - TwilioService.telephony_service = Twilio::REST::Client - - allow(Figaro.env).to receive(:proxy_addr).and_return('123.456.789') - - expect(NullTwilioClient).to receive(:new) - expect(Twilio::REST::Client).to_not receive(:new) - - TwilioService.new - end - it 'does not send OTP messages', twilio: true do TwilioService.telephony_service = FakeSms