trails 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.4 / 2010-03-06
2
+
3
+ * Clean up logging a bit
4
+
1
5
  === 1.0.3 / 2010-03-06
2
6
 
3
7
  * Fix Manifest so all required files get added (!)
data/lib/trails.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Trails
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
4
4
  begin
5
5
  TwilioRest
@@ -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
- if( opts.blank? )
7
- STDERR.puts "no opts specified. trying to pull opts from #{self.class.config.inspect}"
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 = @config[: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: check caller credentials here. :)
33
- return true
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.3
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-08 00:00:00 -08:00
12
+ date: 2010-03-13 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency