Skip to content

Commit

Permalink
Remove holdovers from legacy library (twilio#346)
Browse files Browse the repository at this point in the history
* Remove holdovers from legacy library

* Remove unused/outdated imports

* Update tests for Configuration removal

* Remove more things

* Remove more things
  • Loading branch information
dougblack authored and codejudas committed Sep 29, 2017
1 parent 8ccdb15 commit 038a3f9
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 239 deletions.
46 changes: 0 additions & 46 deletions lib/rack/twilio_webhook_authentication.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/twilio-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
require 'json'

require 'twilio-ruby/version' unless defined?(Twilio::VERSION)
require 'rack/twilio_webhook_authentication'

require 'twilio-ruby/util'
require 'twilio-ruby/jwt/jwt'
require 'twilio-ruby/jwt/access_token'
require 'twilio-ruby/jwt/client_capability'
require 'twilio-ruby/jwt/task_router'
require 'twilio-ruby/security/request_validator'
require 'twilio-ruby/util/configuration'

require 'twilio-ruby/twiml/twiml'
require 'twilio-ruby/twiml/voice_response'
Expand All @@ -42,20 +40,4 @@

module Twilio
extend SingleForwardable

def_delegators :configuration, :account_sid, :auth_token

##
# Pre-configure with account SID and auth token so that you don't need to
# pass them to various initializers each time.
def self.configure(&block)
yield configuration
end

##
# Returns an existing or instantiates a new configuration object.
def self.configuration
@configuration ||= Util::Configuration.new
end
private_class_method :configuration
end
6 changes: 3 additions & 3 deletions lib/twilio-ruby/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class Client
##
# Initializes the Twilio Client
def initialize(username=nil, password=nil, account_sid=nil, region=nil, http_client=Twilio::HTTP::Client.new)
@username = username || Twilio.account_sid
@password = password || Twilio.auth_token
@username = username
@password = password
@region = region
@account_sid = account_sid || @username
@auth_token = @password
Expand Down Expand Up @@ -394,4 +394,4 @@ class TaskRouterClient < ObsoleteClient; end
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class TrunkingClient < ObsoleteClient; end
end
end
end
2 changes: 1 addition & 1 deletion lib/twilio-ruby/security/request_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Twilio
module Security
class RequestValidator
def initialize(auth_token = nil)
@auth_token = auth_token || Twilio.auth_token
@auth_token = auth_token
raise ArgumentError, 'Auth token is required' if @auth_token.nil?
end

Expand Down
7 changes: 0 additions & 7 deletions lib/twilio-ruby/util/configuration.rb

This file was deleted.

106 changes: 0 additions & 106 deletions spec/rack/twilio_webhook_authentication_spec.rb

This file was deleted.

28 changes: 0 additions & 28 deletions spec/security/request_validator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
require 'spec_helper'

describe Twilio::Security::RequestValidator do
describe 'configuration' do
after(:each) do
Twilio.instance_variable_set('@configuration', nil)
end

it 'should set the auth token from a configuration block' do
Twilio.configure do |config|
config.auth_token = 'someToken'
end

validator = Twilio::Security::RequestValidator.new
expect(validator.instance_variable_get('@auth_token')).to eq('someToken')
end

it 'should overwrite the auth token if passed to initializer' do
Twilio.configure do |config|
config.auth_token = 'someToken'
end

validator = Twilio::Security::RequestValidator.new 'otherToken'
expect(validator.instance_variable_get('@auth_token')).to eq('otherToken')
end

it 'should throw an argument error if the auth token isn\'t set' do
expect { Twilio::Security::RequestValidator.new }.to raise_error(ArgumentError)
end
end

describe 'validations' do
let(:token) { '2bd9e9638872de601313dc77410d3b23' }

Expand Down
15 changes: 0 additions & 15 deletions spec/twilio_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
describe Twilio do
after(:each) do
Twilio.instance_variable_set('@configuration', nil)
end

it 'should set the account sid and auth token with a config block' do
Twilio.configure do |config|
config.account_sid = 'someSid'
config.auth_token = 'someToken'
end

expect(Twilio.account_sid).to eq('someSid')
expect(Twilio.auth_token).to eq('someToken')
end
end
15 changes: 0 additions & 15 deletions spec/util/configuration_spec.rb

This file was deleted.

0 comments on commit 038a3f9

Please sign in to comment.