Skip to content

Commit

Permalink
Merge pull request #1739 from 18F/tspencer/fix/twilioproxy
Browse files Browse the repository at this point in the history
Turn off twilio proxy feature
  • Loading branch information
monfresh authored Oct 31, 2017
2 parents 6ed9bd1 + 5bc52d5 commit 6d36250
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
19 changes: 0 additions & 19 deletions app/services/twilio_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'],
Expand Down
2 changes: 0 additions & 2 deletions config/application.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,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'
Expand Down
38 changes: 0 additions & 38 deletions spec/services/twilio_service_spec.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 6d36250

Please sign in to comment.