facebook-signed-request 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,16 +27,16 @@ Usage
27
27
 
28
28
  request.data
29
29
  # => {
30
- # "algorithm"=>"HMAC-SHA256",
31
- # "expires"=>1308988800,
32
- # "issued_at"=>1308985018,
33
- # "oauth_token"=>"114998258593813|2.AQBAttRlLVnwqNPZ.3600.1308988800…",
34
- # "user"=> {
35
- # "country"=>"de",
36
- # "locale"=>"en_US",
37
- # "age"=>{"min"=>21}
30
+ # :Algorithm => "HMAC-SHA256",
31
+ # :expires => 1308988800,
32
+ # :issued_at => 1308985018,
33
+ # :oauth_token => "114998258593813|2.AQBAttRlLVnwqNPZ.3600.1308988800…",
34
+ # :user => {
35
+ # :country => "de",
36
+ # :locale => "en_US",
37
+ # :age => {"min"=>21}
38
38
  # },
39
- # "user_id"=>"100000656666199"
39
+ # :user_id => "100000656666199"
40
40
  # }
41
41
 
42
42
 
@@ -81,7 +81,7 @@ module Facebook
81
81
 
82
82
  def parse_request_playload
83
83
  begin
84
- return JSON.parse( @payload )
84
+ return JSON.parse( @payload, :symbolize_names => true )
85
85
  rescue
86
86
  @errors << "Invalid JSON object"
87
87
  return {}
@@ -89,7 +89,7 @@ module Facebook
89
89
  end
90
90
 
91
91
  def validate_algorithm
92
- if @data['algorithm'] != "HMAC-SHA256"
92
+ if @data[:algorithm] != "HMAC-SHA256"
93
93
  @errors << "Invalid Algorithm. Expected: HMAC-SHA256"
94
94
  end
95
95
  end
@@ -111,7 +111,7 @@ module Facebook
111
111
  end
112
112
 
113
113
  def validate_timestamp
114
- timestamp = @data['expires']
114
+ timestamp = @data[:expires]
115
115
 
116
116
  if timestamp && Time.at( timestamp ) <= Time.now
117
117
  raise ArgumentError, "OAuth Token has expired: #{Time.at( timestamp )}"
@@ -1,5 +1,5 @@
1
1
  module Facebook
2
2
  class SignedRequest
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -20,6 +20,14 @@ class SignedRequestTest < Test::Unit::TestCase
20
20
  assert request.errors == [], "Request should contain no errors"
21
21
  end
22
22
 
23
+ test "data of valid request is parsed to ruby hash with symbols as keys" do
24
+ request = Facebook::SignedRequest.new( @valid_request )
25
+
26
+ key_classes = request.data.map { |k,v| k.class } | [Symbol]
27
+
28
+ assert_equal 1, key_classes.length, "All keys should be symbols"
29
+ end
30
+
23
31
  test "parsing a request with invalid signature" do
24
32
  request = Facebook::SignedRequest.new( @invalid_request_1 )
25
33
  assert_equal false, request.valid?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-signed-request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-28 00:00:00.000000000 +02:00
12
+ date: 2011-07-01 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Parses and validates Facebook signed requests