koala 0.7.1 → 0.7.3
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/CHANGELOG +18 -0
- data/LICENSE +22 -0
- data/Manifest +19 -4
- data/Rakefile +2 -1
- data/examples/oauth_playground/Capfile +2 -0
- data/examples/oauth_playground/LICENSE +22 -0
- data/examples/oauth_playground/Rakefile +4 -0
- data/examples/oauth_playground/config/deploy.rb +39 -0
- data/examples/oauth_playground/config/facebook.yml +13 -0
- data/examples/oauth_playground/config.ru +27 -0
- data/examples/oauth_playground/lib/load_facebook.rb +3 -0
- data/examples/oauth_playground/lib/oauth_playground.rb +187 -0
- data/examples/oauth_playground/readme.md +8 -0
- data/examples/oauth_playground/spec/oauth_playground_spec.rb +35 -0
- data/examples/oauth_playground/spec/spec_helper.rb +36 -0
- data/examples/oauth_playground/tmp/restart.txt +0 -0
- data/examples/oauth_playground/views/index.erb +206 -0
- data/examples/oauth_playground/views/layout.erb +39 -0
- data/koala.gemspec +4 -4
- data/lib/{graph_api.rb → koala/graph_api.rb} +4 -4
- data/lib/koala.rb +95 -12
- data/readme.md +4 -1
- data/spec/facebook_data.yml +8 -3
- data/spec/koala/api_base_tests.rb +69 -2
- data/spec/koala/graph_api/graph_api_no_access_token_tests.rb +4 -0
- data/spec/koala/graph_api/graph_api_with_access_token_tests.rb +4 -0
- data/spec/koala/net_http_service_tests.rb +169 -5
- data/spec/koala/oauth/oauth_tests.rb +193 -40
- data/spec/mock_facebook_responses.yml +21 -1
- data/spec/mock_http_service.rb +6 -1
- metadata +27 -11
- /data/lib/{http_services.rb → koala/http_services.rb} +0 -0
- /data/lib/{realtime_updates.rb → koala/realtime_updates.rb} +0 -0
- /data/lib/{rest_api.rb → koala/rest_api.rb} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require 'http_services'
|
|
1
|
+
require 'koala/http_services'
|
|
2
2
|
|
|
3
3
|
class NetHTTPServiceTests < Test::Unit::TestCase
|
|
4
4
|
module Bear
|
|
@@ -8,10 +8,174 @@ class NetHTTPServiceTests < Test::Unit::TestCase
|
|
|
8
8
|
it "should define a make_request static module method" do
|
|
9
9
|
Bear.respond_to?(:make_request).should be_true
|
|
10
10
|
end
|
|
11
|
-
|
|
12
|
-
it "should return a string for location header"
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
describe "when making a request" do
|
|
13
|
+
before(:each) do
|
|
14
|
+
# Setup stubs for make_request to execute without exceptions
|
|
15
|
+
@mock_http_response = stub('Net::HTTPResponse', :code => 1)
|
|
16
|
+
@mock_body = stub('Net::HTTPResponse body')
|
|
17
|
+
@http_request_result = [@mock_http_response, @mock_body]
|
|
18
|
+
|
|
19
|
+
@http_yield_mock = mock('Net::HTTP start yielded object')
|
|
20
|
+
|
|
21
|
+
@http_yield_mock.stub(:post).and_return(@http_request_result)
|
|
22
|
+
@http_yield_mock.stub(:get).and_return(@http_request_result)
|
|
23
|
+
|
|
24
|
+
@http_mock = stub('Net::HTTP object', 'use_ssl=' => true, 'verify_mode=' => true)
|
|
25
|
+
@http_mock.stub(:start).and_yield(@http_yield_mock)
|
|
26
|
+
|
|
27
|
+
Net::HTTP.stub(:new).and_return(@http_mock)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should use POST if verb is not GET" do
|
|
31
|
+
@http_yield_mock.should_receive(:post).and_return(@mock_http_response)
|
|
32
|
+
@http_mock.should_receive(:start).and_yield(@http_yield_mock)
|
|
33
|
+
|
|
34
|
+
Bear.make_request('anything', {}, 'anything')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should use port 443" do
|
|
38
|
+
Net::HTTP.should_receive(:new).with(anything, 443).and_return(@http_mock)
|
|
39
|
+
|
|
40
|
+
Bear.make_request('anything', {}, 'anything')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it "should use SSL" do
|
|
44
|
+
@http_mock.should_receive('use_ssl=').with(true)
|
|
45
|
+
|
|
46
|
+
Bear.make_request('anything', {}, 'anything')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should use the graph server by default" do
|
|
50
|
+
Net::HTTP.should_receive(:new).with(Koala::Facebook::GRAPH_SERVER, anything).and_return(@http_mock)
|
|
51
|
+
Bear.make_request('anything', {}, 'anything')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should use the REST server if the :rest_api option is true" do
|
|
55
|
+
Net::HTTP.should_receive(:new).with(Koala::Facebook::REST_SERVER, anything).and_return(@http_mock)
|
|
56
|
+
Bear.make_request('anything', {}, 'anything', :rest_api => true)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should turn off vertificate validaiton warnings" do
|
|
60
|
+
@http_mock.should_receive('verify_mode=').with(OpenSSL::SSL::VERIFY_NONE)
|
|
61
|
+
|
|
62
|
+
Bear.make_request('anything', {}, 'anything')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should start an HTTP connection" do
|
|
66
|
+
@http_mock.should_receive(:start).and_yield(@http_yield_mock)
|
|
67
|
+
Bear.make_request('anything', {}, 'anything')
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
describe "via POST" do
|
|
71
|
+
it "should use Net::HTTP to make a POST request" do
|
|
72
|
+
@http_yield_mock.should_receive(:post).and_return(@http_request_result)
|
|
73
|
+
|
|
74
|
+
Bear.make_request('anything', {}, 'post')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should go to the specified path" do
|
|
78
|
+
path = mock('Path')
|
|
79
|
+
@http_yield_mock.should_receive(:post).with(path, anything).and_return(@http_request_result)
|
|
80
|
+
|
|
81
|
+
Bear.make_request(path, {}, 'post')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should use encoded parameters" do
|
|
85
|
+
args = {}
|
|
86
|
+
params = mock('Encoded parameters')
|
|
87
|
+
Bear.should_receive(:encode_params).with(args).and_return(params)
|
|
88
|
+
|
|
89
|
+
@http_yield_mock.should_receive(:post).with(anything, params).and_return(@http_request_result)
|
|
90
|
+
|
|
91
|
+
Bear.make_request('anything', args, 'post')
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "via GET" do
|
|
96
|
+
it "should use Net::HTTP to make a GET request" do
|
|
97
|
+
@http_yield_mock.should_receive(:get).and_return(@http_request_result)
|
|
98
|
+
|
|
99
|
+
Bear.make_request('anything', {}, 'get')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should use the correct path, including arguments" do
|
|
103
|
+
path = mock('Path')
|
|
104
|
+
params = mock('Encoded parameters')
|
|
105
|
+
args = {}
|
|
106
|
+
|
|
107
|
+
Bear.should_receive(:encode_params).with(args).and_return(params)
|
|
108
|
+
@http_yield_mock.should_receive(:get).with("#{path}?#{params}").and_return(@http_request_result)
|
|
109
|
+
|
|
110
|
+
Bear.make_request(path, args, 'get')
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "the returned value" do
|
|
115
|
+
before(:each) do
|
|
116
|
+
@response = Bear.make_request('anything', {}, 'anything')
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should return a Koala::Response object" do
|
|
120
|
+
@response.class.should == Koala::Response
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it "should return a Koala::Response with the right status" do
|
|
124
|
+
@response.status.should == @mock_http_response.code
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "should reutrn a Koala::Response with the right body" do
|
|
128
|
+
@response.body.should == @mock_body
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "should return a Koala::Response with the Net::HTTPResponse object as headers" do
|
|
132
|
+
@response.headers.should == @mock_http_response
|
|
133
|
+
end
|
|
134
|
+
end # describe return value
|
|
135
|
+
end # describe when making a request
|
|
15
136
|
|
|
16
|
-
|
|
137
|
+
describe "when encoding parameters" do
|
|
138
|
+
it "should return an empty string if param_hash evaluates to false" do
|
|
139
|
+
Bear.encode_params(nil).should == ''
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should convert values to JSON if the value is not a String" do
|
|
143
|
+
val = 'json_value'
|
|
144
|
+
not_a_string = 'not_a_string'
|
|
145
|
+
not_a_string.stub(:class).and_return('NotAString')
|
|
146
|
+
not_a_string.should_receive(:to_json).and_return(val)
|
|
147
|
+
|
|
148
|
+
string = "hi"
|
|
149
|
+
|
|
150
|
+
args = {
|
|
151
|
+
not_a_string => not_a_string,
|
|
152
|
+
string => string
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
result = Bear.encode_params(args)
|
|
156
|
+
result.split('&').find do |key_and_val|
|
|
157
|
+
key_and_val.match("#{not_a_string}=#{val}")
|
|
158
|
+
end.should be_true
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "should escape all values" do
|
|
162
|
+
args = Hash[*(1..4).map {|i| [i.to_s, "Value #{i}($"]}.flatten]
|
|
163
|
+
|
|
164
|
+
result = Bear.encode_params(args)
|
|
165
|
+
result.split('&').each do |key_val|
|
|
166
|
+
key, val = key_val.split('=')
|
|
167
|
+
val.should == CGI.escape(args[key])
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "should convert all keys to Strings" do
|
|
172
|
+
args = Hash[*(1..4).map {|i| [i, "val#{i}"]}.flatten]
|
|
173
|
+
|
|
174
|
+
result = Bear.encode_params(args)
|
|
175
|
+
result.split('&').each do |key_val|
|
|
176
|
+
key, val = key_val.split('=')
|
|
177
|
+
key.should == args.find{|key_val_arr| key_val_arr.last == val}.first.to_s
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
17
181
|
end
|
|
@@ -51,41 +51,66 @@ class FacebookOAuthTests < Test::Unit::TestCase
|
|
|
51
51
|
@oauth.oauth_callback_url == nil).should be_true
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
describe "cookie parsing" do
|
|
55
|
+
describe "get_user_info_from_cookies" do
|
|
56
|
+
it "should properly parse valid cookies" do
|
|
57
|
+
result = @oauth.get_user_info_from_cookies(@oauth_data["valid_cookies"])
|
|
58
|
+
result.should be_a(Hash)
|
|
59
|
+
end
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
it "should return all the cookie components from valid cookie string" do
|
|
62
|
+
cookie_data = @oauth_data["valid_cookies"]
|
|
63
|
+
parsing_results = @oauth.get_user_info_from_cookies(cookie_data)
|
|
64
|
+
number_of_components = cookie_data["fbs_#{@app_id.to_s}"].scan(/\=/).length
|
|
65
|
+
parsing_results.length.should == number_of_components
|
|
66
|
+
end
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
it "should properly parse valid offline access cookies (e.g. no expiration)" do
|
|
69
|
+
result = @oauth.get_user_info_from_cookies(@oauth_data["offline_access_cookies"])
|
|
70
|
+
result["uid"].should
|
|
71
|
+
end
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
it "should return all the cookie components from offline access cookies" do
|
|
74
|
+
cookie_data = @oauth_data["offline_access_cookies"]
|
|
75
|
+
parsing_results = @oauth.get_user_info_from_cookies(cookie_data)
|
|
76
|
+
number_of_components = cookie_data["fbs_#{@app_id.to_s}"].scan(/\=/).length
|
|
77
|
+
parsing_results.length.should == number_of_components
|
|
78
|
+
end
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
it "shouldn't parse expired cookies" do
|
|
81
|
+
result = @oauth.get_user_info_from_cookies(@oauth_data["expired_cookies"])
|
|
82
|
+
result.should be_nil
|
|
83
|
+
end
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
it "shouldn't parse invalid cookies" do
|
|
86
|
+
# make an invalid string by replacing some values
|
|
87
|
+
bad_cookie_hash = @oauth_data["valid_cookies"].inject({}) { |hash, value| hash[value[0]] = value[1].gsub(/[0-9]/, "3") }
|
|
88
|
+
result = @oauth.get_user_info_from_cookies(bad_cookie_hash)
|
|
89
|
+
result.should be_nil
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe "get_user_from_cookies" do
|
|
94
|
+
it "should use get_user_info_from_cookies to parse the cookies" do
|
|
95
|
+
data = @oauth_data["valid_cookies"]
|
|
96
|
+
@oauth.should_receive(:get_user_info_from_cookies).with(data).and_return({})
|
|
97
|
+
@oauth.get_user_from_cookies(data)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it "should use return a string" do
|
|
101
|
+
result = @oauth.get_user_from_cookies(@oauth_data["valid_cookies"])
|
|
102
|
+
result.should be_a(String)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
describe "backward compatibility" do
|
|
106
|
+
before :each do
|
|
107
|
+
@result = @oauth.get_user_from_cookies(@oauth_data["valid_cookies"])
|
|
108
|
+
@key = "uid"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it_should_behave_like "methods that return overloaded strings"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
89
114
|
end
|
|
90
115
|
|
|
91
116
|
# OAuth URLs
|
|
@@ -157,21 +182,149 @@ class FacebookOAuthTests < Test::Unit::TestCase
|
|
|
157
182
|
out.should_not be_nil
|
|
158
183
|
end
|
|
159
184
|
|
|
160
|
-
|
|
185
|
+
describe "get_access_token_info" do
|
|
186
|
+
it "should properly get and parse an access token token results into a hash" do
|
|
187
|
+
result = @oauth.get_access_token_info(@code)
|
|
188
|
+
result.should be_a(Hash)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "should properly include the access token results" do
|
|
192
|
+
result = @oauth.get_access_token_info(@code)
|
|
193
|
+
result["access_token"].should
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "should raise an error when get_access_token is called with a bad code" do
|
|
197
|
+
lambda { @oauth.get_access_token_info("foo") }.should raise_error(Koala::Facebook::APIError)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
describe "get_access_token" do
|
|
202
|
+
it "should use get_access_token_info to get and parse an access token token results" do
|
|
203
|
+
result = @oauth.get_access_token(@code)
|
|
204
|
+
result.should be_a(String)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should return the access token as a string" do
|
|
208
|
+
result = @oauth.get_access_token(@code)
|
|
209
|
+
original = @oauth.get_access_token_info(@code)
|
|
210
|
+
result.should == original["access_token"]
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "should raise an error when get_access_token is called with a bad code" do
|
|
214
|
+
lambda { @oauth.get_access_token("foo") }.should raise_error(Koala::Facebook::APIError)
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
describe "backwards compatibility" do
|
|
218
|
+
before :each do
|
|
219
|
+
@result = @oauth.get_access_token(@code)
|
|
220
|
+
end
|
|
161
221
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
result = @oauth.get_access_token(@code)
|
|
165
|
-
result["access_token"].should
|
|
222
|
+
it_should_behave_like "methods that return overloaded strings"
|
|
223
|
+
end
|
|
166
224
|
end
|
|
167
225
|
|
|
168
|
-
|
|
169
|
-
|
|
226
|
+
describe "get_app_access_token_info" do
|
|
227
|
+
it "should properly get and parse an app's access token as a hash" do
|
|
228
|
+
result = @oauth.get_app_access_token_info
|
|
229
|
+
result.should be_a(Hash)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
it "should include the access token" do
|
|
233
|
+
result = @oauth.get_app_access_token_info
|
|
234
|
+
result["access_token"].should
|
|
235
|
+
end
|
|
170
236
|
end
|
|
171
237
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
238
|
+
describe "get_app_acess_token" do
|
|
239
|
+
it "should use get_access_token_info to get and parse an access token token results" do
|
|
240
|
+
result = @oauth.get_app_access_token
|
|
241
|
+
result.should be_a(String)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
it "should return the access token as a string" do
|
|
245
|
+
result = @oauth.get_app_access_token
|
|
246
|
+
original = @oauth.get_app_access_token_info
|
|
247
|
+
result.should == original["access_token"]
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
describe "backwards compatibility" do
|
|
251
|
+
before :each do
|
|
252
|
+
@result = @oauth.get_app_access_token
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
it_should_behave_like "methods that return overloaded strings"
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
describe "exchanging session keys" do
|
|
260
|
+
describe "with get_token_info_from_session_keys" do
|
|
261
|
+
it "should get an array of session keys from Facebook when passed a single key" do
|
|
262
|
+
result = @oauth.get_tokens_from_session_keys([@oauth_data["session_key"]])
|
|
263
|
+
result.should be_an(Array)
|
|
264
|
+
result.length.should == 1
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "should get an array of session keys from Facebook when passed multiple keys" do
|
|
268
|
+
result = @oauth.get_tokens_from_session_keys(@oauth_data["multiple_session_keys"])
|
|
269
|
+
result.should be_an(Array)
|
|
270
|
+
result.length.should == 2
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it "should return the original hashes" do
|
|
274
|
+
result = @oauth.get_token_info_from_session_keys(@oauth_data["multiple_session_keys"])
|
|
275
|
+
result[0].should be_a(Hash)
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
describe "with get_tokens_from_session_keys" do
|
|
280
|
+
it "should call get_token_info_from_session_keys" do
|
|
281
|
+
args = @oauth_data["multiple_session_keys"]
|
|
282
|
+
@oauth.should_receive(:get_token_info_from_session_keys).with(args).and_return([])
|
|
283
|
+
@oauth.get_tokens_from_session_keys(args)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
it "should return an array of strings" do
|
|
287
|
+
args = @oauth_data["multiple_session_keys"]
|
|
288
|
+
result = @oauth.get_tokens_from_session_keys(args)
|
|
289
|
+
result.each {|r| r.should be_a(String) }
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
describe "backwards compatibility" do
|
|
293
|
+
before :each do
|
|
294
|
+
args = @oauth_data["multiple_session_keys"]
|
|
295
|
+
@result = @oauth.get_tokens_from_session_keys(args)[0]
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it_should_behave_like "methods that return overloaded strings"
|
|
299
|
+
end
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
describe "get_token_from_session_key" do
|
|
303
|
+
it "should call get_tokens_from_session_keys when the get_token_from_session_key is called" do
|
|
304
|
+
key = @oauth_data["session_key"]
|
|
305
|
+
@oauth.should_receive(:get_tokens_from_session_keys).with([key]).and_return([])
|
|
306
|
+
@oauth.get_token_from_session_key(key)
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
it "should get back the access token string from get_token_from_session_key" do
|
|
310
|
+
result = @oauth.get_token_from_session_key(@oauth_data["session_key"])
|
|
311
|
+
result.should be_a(String)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
it "should be the first value in the array" do
|
|
315
|
+
result = @oauth.get_token_from_session_key(@oauth_data["session_key"])
|
|
316
|
+
array = @oauth.get_tokens_from_session_keys([@oauth_data["session_key"]])
|
|
317
|
+
result.should == array[0]
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
describe "backwards compatibility" do
|
|
321
|
+
before :each do
|
|
322
|
+
@result = @oauth.get_token_from_session_key(@oauth_data["session_key"])
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it_should_behave_like "methods that return overloaded strings"
|
|
326
|
+
end
|
|
327
|
+
end
|
|
175
328
|
end
|
|
176
329
|
|
|
177
330
|
# protected methods
|
|
@@ -114,6 +114,18 @@ graph_api:
|
|
|
114
114
|
code: 302
|
|
115
115
|
headers:
|
|
116
116
|
Location: http://facebook.com/
|
|
117
|
+
type=large:
|
|
118
|
+
get:
|
|
119
|
+
no_token:
|
|
120
|
+
code: 302
|
|
121
|
+
headers:
|
|
122
|
+
Location: http://facebook.com/large
|
|
123
|
+
with_token:
|
|
124
|
+
code: 302
|
|
125
|
+
headers:
|
|
126
|
+
Location: http://facebook.com/large
|
|
127
|
+
|
|
128
|
+
|
|
117
129
|
search:
|
|
118
130
|
q=facebook:
|
|
119
131
|
get:
|
|
@@ -136,7 +148,15 @@ graph_api:
|
|
|
136
148
|
client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
|
|
137
149
|
post:
|
|
138
150
|
no_token: access_token=<%= ACCESS_TOKEN %>
|
|
139
|
-
|
|
151
|
+
oauth/exchange_sessions:
|
|
152
|
+
client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred:
|
|
153
|
+
post:
|
|
154
|
+
no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
|
|
155
|
+
client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["multiple_session_keys"].join(",") %>&type=client_cred:
|
|
156
|
+
post:
|
|
157
|
+
no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
|
|
158
|
+
|
|
159
|
+
|
|
140
160
|
|
|
141
161
|
# -- Subscription Responses --
|
|
142
162
|
<%= APP_ID %>/subscriptions:
|
data/spec/mock_http_service.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'erb'
|
|
2
|
+
require 'yaml'
|
|
2
3
|
|
|
3
4
|
module Koala
|
|
4
5
|
module MockHTTPService
|
|
@@ -15,7 +16,11 @@ module Koala
|
|
|
15
16
|
|
|
16
17
|
# Useful in mock_facebook_responses.yml
|
|
17
18
|
OAUTH_DATA = TEST_DATA['oauth_test_data']
|
|
18
|
-
OAUTH_DATA.merge!(
|
|
19
|
+
OAUTH_DATA.merge!({
|
|
20
|
+
'app_access_token' => Koala::MockHTTPService::ACCESS_TOKEN,
|
|
21
|
+
'session_key' => "session_key",
|
|
22
|
+
'multiple_session_keys' => ["session_key", "session_key_2"]
|
|
23
|
+
})
|
|
19
24
|
APP_ID = OAUTH_DATA['app_id']
|
|
20
25
|
SECRET = OAUTH_DATA['secret']
|
|
21
26
|
SUBSCRIPTION_DATA = TEST_DATA["subscription_test_data"]
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 7
|
|
8
|
-
-
|
|
9
|
-
version: 0.7.
|
|
8
|
+
- 3
|
|
9
|
+
version: 0.7.3
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-06-22 00:00:00 -07:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies: []
|
|
20
20
|
|
|
@@ -26,21 +26,37 @@ extensions: []
|
|
|
26
26
|
|
|
27
27
|
extra_rdoc_files:
|
|
28
28
|
- CHANGELOG
|
|
29
|
-
-
|
|
30
|
-
- lib/http_services.rb
|
|
29
|
+
- LICENSE
|
|
31
30
|
- lib/koala.rb
|
|
32
|
-
- lib/
|
|
33
|
-
- lib/
|
|
31
|
+
- lib/koala/graph_api.rb
|
|
32
|
+
- lib/koala/http_services.rb
|
|
33
|
+
- lib/koala/realtime_updates.rb
|
|
34
|
+
- lib/koala/rest_api.rb
|
|
34
35
|
files:
|
|
35
36
|
- CHANGELOG
|
|
37
|
+
- LICENSE
|
|
36
38
|
- Manifest
|
|
37
39
|
- Rakefile
|
|
40
|
+
- examples/oauth_playground/Capfile
|
|
41
|
+
- examples/oauth_playground/LICENSE
|
|
42
|
+
- examples/oauth_playground/Rakefile
|
|
43
|
+
- examples/oauth_playground/config.ru
|
|
44
|
+
- examples/oauth_playground/config/deploy.rb
|
|
45
|
+
- examples/oauth_playground/config/facebook.yml
|
|
46
|
+
- examples/oauth_playground/lib/load_facebook.rb
|
|
47
|
+
- examples/oauth_playground/lib/oauth_playground.rb
|
|
48
|
+
- examples/oauth_playground/readme.md
|
|
49
|
+
- examples/oauth_playground/spec/oauth_playground_spec.rb
|
|
50
|
+
- examples/oauth_playground/spec/spec_helper.rb
|
|
51
|
+
- examples/oauth_playground/tmp/restart.txt
|
|
52
|
+
- examples/oauth_playground/views/index.erb
|
|
53
|
+
- examples/oauth_playground/views/layout.erb
|
|
38
54
|
- init.rb
|
|
39
|
-
- lib/graph_api.rb
|
|
40
|
-
- lib/http_services.rb
|
|
41
55
|
- lib/koala.rb
|
|
42
|
-
- lib/
|
|
43
|
-
- lib/
|
|
56
|
+
- lib/koala/graph_api.rb
|
|
57
|
+
- lib/koala/http_services.rb
|
|
58
|
+
- lib/koala/realtime_updates.rb
|
|
59
|
+
- lib/koala/rest_api.rb
|
|
44
60
|
- readme.md
|
|
45
61
|
- spec/facebook_data.yml
|
|
46
62
|
- spec/koala/api_base_tests.rb
|
|
File without changes
|
|
File without changes
|
|
File without changes
|