rest-graph 1.4.2 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +14 -1
- data/README +1 -1
- data/README.rdoc +1 -1
- data/example/rails/test/test_helper.rb +1 -0
- data/example/rails/test/unit/rails_util_test.rb +32 -0
- data/lib/rest-graph/rails_util.rb +13 -7
- data/lib/rest-graph/version.rb +1 -1
- data/lib/rest-graph.rb +3 -4
- data/test/test_parse.rb +8 -0
- metadata +5 -4
data/CHANGES
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
= rest-graph changes history
|
2
2
|
|
3
|
+
== rest-graph 1.4.3 -- 2010-08-06
|
4
|
+
|
5
|
+
* [RestGraph] Fixed a bug in RestGraph#fbs, which didn't join '&'.
|
6
|
+
Thanks, Andrew.
|
7
|
+
|
8
|
+
* [RailsUtil] Fixed a bug that wrongly rewrites request URI.
|
9
|
+
Previously it is processed by regular expressions,
|
10
|
+
now we're using URI.parse to handle this. Closed #4.
|
11
|
+
Thanks, Justin.
|
12
|
+
|
13
|
+
* [RailsUtil] Favor Request#fullpath over Request#request_uri,
|
14
|
+
which came from newer Rack and thus for Rails 3.
|
15
|
+
|
3
16
|
== rest-graph 1.4.2 -- 2010-08-05
|
4
17
|
|
5
18
|
* [RestGraph] Added RestGraph#fbs to generate fbs with correct sig,
|
@@ -9,7 +22,7 @@
|
|
9
22
|
* [RailsUtil] Fixed a bug that write_session didn't parse because parse_fbs!
|
10
23
|
reject the fbs due to missing sig.
|
11
24
|
* [RailsUtil] Fixed a bug that in Rails 3, must call safe_html to prevent
|
12
|
-
unintended HTML escaping.
|
25
|
+
unintended HTML escaping. Thanks, Justin.
|
13
26
|
|
14
27
|
* Thanks a lot, Andrew.
|
15
28
|
|
data/README
CHANGED
data/README.rdoc
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'test_helper'
|
3
|
+
require 'rr'
|
4
|
+
|
5
|
+
class RailsUtilTest < ActiveSupport::TestCase
|
6
|
+
include RR::Adapters::TestUnit
|
7
|
+
|
8
|
+
def setup_mock url
|
9
|
+
mock(RestGraph::RailsUtil).rest_graph_in_canvas?{ false }
|
10
|
+
mock(RestGraph::RailsUtil).request{
|
11
|
+
mock(Object.new).url{ url }
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_rest_graph_normalized_request_uri_0
|
16
|
+
setup_mock( 'http://test.com/?code=123&lang=en')
|
17
|
+
assert_equal('http://test.com/?lang=en',
|
18
|
+
RestGraph::RailsUtil.rest_graph_normalized_request_uri)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_rest_graph_normalized_request_uri_1
|
22
|
+
setup_mock( 'http://test.com/?lang=en&code=123')
|
23
|
+
assert_equal('http://test.com/?lang=en',
|
24
|
+
RestGraph::RailsUtil.rest_graph_normalized_request_uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_rest_graph_normalized_request_uri_2
|
28
|
+
setup_mock( 'http://test.com/?session=abc&lang=en&code=123')
|
29
|
+
assert_equal('http://test.com/?lang=en',
|
30
|
+
RestGraph::RailsUtil.rest_graph_normalized_request_uri)
|
31
|
+
end
|
32
|
+
end
|
@@ -237,13 +237,19 @@ module RestGraph::RailsUtil
|
|
237
237
|
end
|
238
238
|
|
239
239
|
def rest_graph_normalized_request_uri
|
240
|
-
if rest_graph_in_canvas?
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
240
|
+
URI.parse(if rest_graph_in_canvas?
|
241
|
+
# rails 3 uses newer rack which has fullpath
|
242
|
+
"http://apps.facebook.com/#{rest_graph_oget(:canvas)}" +
|
243
|
+
(request.respond_to?(:fullpath) ?
|
244
|
+
request.fullpath : request.request_uri)
|
245
|
+
else
|
246
|
+
request.url
|
247
|
+
end).
|
248
|
+
tap{ |uri|
|
249
|
+
uri.query = uri.query.split('&').reject{ |q|
|
250
|
+
q =~ /^(code|session)\=/
|
251
|
+
}.join('&') if uri.query
|
252
|
+
}.to_s
|
247
253
|
end
|
248
254
|
|
249
255
|
def rest_graph_in_canvas?
|
data/lib/rest-graph/version.rb
CHANGED
data/lib/rest-graph.rb
CHANGED
@@ -131,7 +131,7 @@ class RestGraph < RestGraphStruct
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def fbs
|
134
|
-
"#{fbs_without_sig(data)}&sig=#{calculate_sig(data)}"
|
134
|
+
"#{fbs_without_sig(data).join('&')}&sig=#{calculate_sig(data)}"
|
135
135
|
end
|
136
136
|
|
137
137
|
# facebook's new signed_request...
|
@@ -239,12 +239,11 @@ class RestGraph < RestGraphStruct
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def calculate_sig cookies
|
242
|
-
Digest::MD5.hexdigest(fbs_without_sig(cookies) + secret)
|
242
|
+
Digest::MD5.hexdigest(fbs_without_sig(cookies).join + secret)
|
243
243
|
end
|
244
244
|
|
245
245
|
def fbs_without_sig cookies
|
246
|
-
cookies.reject{ |(k, v)| k == 'sig' }.sort.
|
247
|
-
map{ |a| a.join('=') }.join
|
246
|
+
cookies.reject{ |(k, v)| k == 'sig' }.sort.map{ |a| a.join('=') }
|
248
247
|
end
|
249
248
|
|
250
249
|
def cache_key uri
|
data/test/test_parse.rb
CHANGED
@@ -98,4 +98,12 @@ describe RestGraph do
|
|
98
98
|
rg.parse_fbs!(rg.fbs.sub(/sig\=\w+/, 'sig=abc')).should == nil
|
99
99
|
end
|
100
100
|
|
101
|
+
it 'could generate correct fbs with additional parameters' do
|
102
|
+
rg = RestGraph.new(:access_token => 'a', :secret => 'z')
|
103
|
+
rg.data['expires'] = '1234'
|
104
|
+
rg.parse_fbs!(rg.fbs) .should.kind_of?(Hash)
|
105
|
+
rg.data['access_token'] .should == 'a'
|
106
|
+
rg.data['expires'] .should == '1234'
|
107
|
+
end
|
108
|
+
|
101
109
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 3
|
10
|
+
version: 1.4.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cardinal Blue
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-06 00:00:00 +08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- example/rails/script/server
|
178
178
|
- example/rails/test/functional/application_controller_test.rb
|
179
179
|
- example/rails/test/test_helper.rb
|
180
|
+
- example/rails/test/unit/rails_util_test.rb
|
180
181
|
- init.rb
|
181
182
|
- lib/rest-graph.rb
|
182
183
|
- lib/rest-graph/auto_load.rb
|