Migrate twilio to use rails creds

fixes FOO-1496

Change-Id: I26e329e09022aecca3f575667fe5ff8c377eb24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276546
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
Jacob Burroughs 2021-10-21 15:37:10 -05:00
parent 21e7de523f
commit b329523126
2 changed files with 4 additions and 8 deletions

View File

@ -23,16 +23,12 @@ require 'twilio-ruby'
module Canvas::Twilio
DEFAULT_COUNTRY = 'US'
def self.config
@config ||= ConfigFile.load('twilio') || {}
end
def self.account_sid
config['account_sid']
Rails.application.credentials.twilio_creds&.[](:account_sid)
end
def self.auth_token
config['auth_token']
Rails.application.credentials.twilio_creds&.[](:auth_token)
end
def self.client

View File

@ -104,8 +104,8 @@ describe 'Canvas::Twilio' do
)
end
it 'raises an exception when attempting to deliver without a config file' do
allow(Canvas::Twilio).to receive(:config).and_return({})
it 'raises an exception when attempting to deliver without config' do
allow(Rails.application.credentials).to receive(:twilio_creds).and_return(nil)
expect { Canvas::Twilio.deliver('+18015550100', 'message text') }.to raise_error("Twilio is not configured")
end