trails 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/lib/trails.rb +1 -1
- data/lib/trails/test_helper.rb +1 -1
- data/lib/trails/twilio/account.rb +13 -5
- metadata +2 -2
data/History.txt
CHANGED
data/lib/trails.rb
CHANGED
data/lib/trails/test_helper.rb
CHANGED
@@ -113,11 +113,11 @@ end # module Trails
|
|
113
113
|
|
114
114
|
# open up the TwilioRest::Account class so that we can keep track of faked requests
|
115
115
|
class TwilioRest::Account
|
116
|
+
@@fake_requests ||= []
|
116
117
|
def self.faked_requests
|
117
118
|
return @@fake_requests
|
118
119
|
end
|
119
120
|
def request_with_fake( url, method, params )
|
120
|
-
@@fake_requests ||= []
|
121
121
|
@@fake_requests.push( OpenStruct.new( :url => url, :method => method, :params => params ) )
|
122
122
|
fake_response = OpenStruct.new
|
123
123
|
fake_response.body = 'Fake Body'
|
@@ -3,14 +3,16 @@ module Trails
|
|
3
3
|
class Account
|
4
4
|
attr_reader :config
|
5
5
|
def initialize( opts = {} )
|
6
|
-
|
7
|
-
|
6
|
+
_logger = opts[:logger] || ActiveRecord::Base.logger rescue Logger.new( STDERR )
|
7
|
+
if( !opts.blank? )
|
8
|
+
_logger.warn "overriding default opts #{self.class.config.inspect} with #{opts.inspect}"
|
9
|
+
else
|
8
10
|
opts = self.class.config[self.class.config.keys.first]
|
9
11
|
end
|
10
12
|
@config = opts.dup
|
11
13
|
@sid = @config[:sid] || raise( "no sid specified on #{self}" )
|
12
14
|
@token = @config[:token]
|
13
|
-
@logger =
|
15
|
+
@logger = _logger
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.sid_from_request( request )
|
@@ -29,8 +31,14 @@ module Trails
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def verify_caller( request )
|
32
|
-
# TODO:
|
33
|
-
|
34
|
+
# TODO: fix testing stuff so that it includes the right signature.
|
35
|
+
base_string = request.url
|
36
|
+
base_string += request.post_parameters.
|
37
|
+
sort{ |a,b| a.first.to_s <=> b.first.to_s }.
|
38
|
+
flatten.join if( :post == request.method.to_sym )
|
39
|
+
|
40
|
+
digest = OpenSSL::Digest::Digest.new('sha1')
|
41
|
+
expected = Base64.encode64( OpenSSL::HMAC.digest(digest, @sid, base_string) ).strip
|
34
42
|
end
|
35
43
|
|
36
44
|
# Make outgoing calls.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hemant Bhanoo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|