koala 2.5.0 → 3.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +5 -3
- data/Gemfile +1 -1
- data/ISSUE_TEMPLATE +25 -0
- data/PULL_REQUEST_TEMPLATE +11 -0
- data/changelog.md +66 -4
- data/code_of_conduct.md +64 -12
- data/koala.gemspec +3 -0
- data/lib/koala/api/batch_operation.rb +3 -6
- data/lib/koala/api/{graph_api.rb → graph_api_methods.rb} +13 -102
- data/lib/koala/api/graph_batch_api.rb +112 -65
- data/lib/koala/api/graph_collection.rb +19 -12
- data/lib/koala/api/graph_error_checker.rb +1 -1
- data/lib/koala/api.rb +49 -25
- data/lib/koala/configuration.rb +49 -0
- data/lib/koala/errors.rb +1 -1
- data/lib/koala/http_service/multipart_request.rb +6 -10
- data/lib/koala/http_service/request.rb +135 -0
- data/lib/koala/http_service/response.rb +6 -4
- data/lib/koala/http_service/uploadable_io.rb +0 -4
- data/lib/koala/http_service.rb +18 -76
- data/lib/koala/oauth.rb +7 -7
- data/lib/koala/realtime_updates.rb +26 -21
- data/lib/koala/test_users.rb +9 -8
- data/lib/koala/version.rb +1 -1
- data/lib/koala.rb +6 -8
- data/readme.md +50 -109
- data/spec/cases/api_spec.rb +99 -69
- data/spec/cases/configuration_spec.rb +11 -0
- data/spec/cases/graph_api_batch_spec.rb +73 -42
- data/spec/cases/graph_api_spec.rb +15 -29
- data/spec/cases/graph_collection_spec.rb +47 -34
- data/spec/cases/graph_error_checker_spec.rb +6 -1
- data/spec/cases/http_service/request_spec.rb +242 -0
- data/spec/cases/http_service/response_spec.rb +24 -0
- data/spec/cases/http_service_spec.rb +102 -296
- data/spec/cases/koala_spec.rb +7 -5
- data/spec/cases/oauth_spec.rb +40 -1
- data/spec/cases/realtime_updates_spec.rb +51 -13
- data/spec/cases/test_users_spec.rb +56 -2
- data/spec/cases/uploadable_io_spec.rb +31 -31
- data/spec/fixtures/cat.m4v +0 -0
- data/spec/fixtures/facebook_data.yml +4 -6
- data/spec/fixtures/mock_facebook_responses.yml +29 -69
- data/spec/fixtures/vcr_cassettes/app_test_accounts.yml +97 -0
- data/spec/integration/graph_collection_spec.rb +8 -5
- data/spec/spec_helper.rb +2 -2
- data/spec/support/graph_api_shared_examples.rb +143 -336
- data/spec/support/koala_test.rb +8 -10
- data/spec/support/mock_http_service.rb +9 -9
- data/spec/support/uploadable_io_shared_examples.rb +4 -4
- metadata +31 -11
- data/.autotest +0 -12
- data/Guardfile +0 -6
- data/autotest/discover.rb +0 -1
- data/lib/koala/api/rest_api.rb +0 -135
- data/spec/support/rest_api_shared_examples.rb +0 -168
|
@@ -40,12 +40,52 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
40
40
|
expect(test_users).to be_a(Koala::Facebook::TestUsers)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
context "with global defaults" do
|
|
44
|
+
let(:app_id) { :app_id }
|
|
45
|
+
let(:app_secret) { :app_secret }
|
|
46
|
+
let(:app_access_token) { :app_access_token }
|
|
47
|
+
|
|
48
|
+
before :each do
|
|
49
|
+
Koala.configure do |config|
|
|
50
|
+
config.app_id = app_id
|
|
51
|
+
config.app_secret = app_secret
|
|
52
|
+
config.app_access_token = app_access_token
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "defaults to the configured data if not otherwise provided" do
|
|
57
|
+
test_users = Koala::Facebook::TestUsers.new
|
|
58
|
+
expect(test_users.app_id).to eq(app_id)
|
|
59
|
+
expect(test_users.secret).to eq(app_secret)
|
|
60
|
+
expect(test_users.app_access_token).to eq(app_access_token)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "lets you override app_id" do
|
|
64
|
+
other_value = :another_id
|
|
65
|
+
test_users = Koala::Facebook::TestUsers.new(app_id: other_value)
|
|
66
|
+
expect(test_users.app_id).to eq(other_value)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "lets you override secret" do
|
|
70
|
+
other_value = :another_secret
|
|
71
|
+
test_users = Koala::Facebook::TestUsers.new(secret: other_value)
|
|
72
|
+
expect(test_users.secret).to eq(other_value)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it "lets you override app_id" do
|
|
76
|
+
other_value = :another_token
|
|
77
|
+
test_users = Koala::Facebook::TestUsers.new(app_access_token: other_value)
|
|
78
|
+
expect(test_users.app_access_token).to eq(other_value)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
43
83
|
it "uses the OAuth class to fetch a token when provided an app_id and a secret" do
|
|
44
84
|
oauth = Koala::Facebook::OAuth.new(@app_id, @secret)
|
|
45
85
|
token = oauth.get_app_access_token
|
|
46
86
|
expect(oauth).to receive(:get_app_access_token).and_return(token)
|
|
47
87
|
expect(Koala::Facebook::OAuth).to receive(:new).with(@app_id, @secret).and_return(oauth)
|
|
48
|
-
|
|
88
|
+
Koala::Facebook::TestUsers.new(:app_id => @app_id, :secret => @secret)
|
|
49
89
|
end
|
|
50
90
|
|
|
51
91
|
# attributes
|
|
@@ -265,9 +305,23 @@ describe "Koala::Facebook::TestUsers" do
|
|
|
265
305
|
options = {:some_http_option => true}
|
|
266
306
|
# should come twice, once for each user
|
|
267
307
|
@stubbed = true
|
|
268
|
-
expect(Koala.http_service).to receive(:make_request).
|
|
308
|
+
expect(Koala.http_service).to receive(:make_request).twice do |request|
|
|
309
|
+
expect(request.raw_options).to eq(options)
|
|
310
|
+
Koala::HTTPService::Response.new(200, "{}", {})
|
|
311
|
+
end
|
|
269
312
|
@test_users.befriend(@user1, @user2, options)
|
|
270
313
|
end
|
|
314
|
+
|
|
315
|
+
it "includes the secret, generating the appsecret_proof in both calls if provided" do
|
|
316
|
+
# should come twice, once for each user
|
|
317
|
+
@stubbed = true
|
|
318
|
+
test_users = Koala::Facebook::TestUsers.new({:secret => @secret, :app_id => @app_id})
|
|
319
|
+
expect(Koala.http_service).to receive(:make_request).twice do |request|
|
|
320
|
+
expect(request.post_args).to include("appsecret_proof")
|
|
321
|
+
Koala::HTTPService::Response.new(200, "{}", {})
|
|
322
|
+
end
|
|
323
|
+
test_users.befriend(@user1, @user2)
|
|
324
|
+
end
|
|
271
325
|
end
|
|
272
326
|
end # when used without network
|
|
273
327
|
|
|
@@ -8,7 +8,7 @@ module Koala::MIME
|
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
describe "Koala::UploadableIO" do
|
|
11
|
+
describe "Koala::HTTPService::UploadableIO" do
|
|
12
12
|
def rails_3_mocks
|
|
13
13
|
tempfile = double('Tempfile', :path => "foo")
|
|
14
14
|
uploaded_file = double('ActionDispatch::Http::UploadedFile',
|
|
@@ -39,15 +39,15 @@ describe "Koala::UploadableIO" do
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
it "returns an UploadIO with the same file path" do
|
|
42
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@path)
|
|
42
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@path)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "returns an UploadIO with the same content type" do
|
|
46
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(@stub_type)
|
|
46
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).content_type).to eq(@stub_type)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "returns an UploadIO with the file's name" do
|
|
50
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@path))
|
|
50
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@path))
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -68,16 +68,16 @@ describe "Koala::UploadableIO" do
|
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
it "returns an UploadIO with the same io" do
|
|
71
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
|
|
71
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "returns an UploadableIO with the same content_type" do
|
|
75
75
|
content_stub = @koala_io_params[1] = double('Content Type')
|
|
76
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
76
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it "returns an UploadableIO with the right filename" do
|
|
80
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
|
|
80
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -100,16 +100,16 @@ describe "Koala::UploadableIO" do
|
|
|
100
100
|
|
|
101
101
|
it "returns an UploadIO with the same io" do
|
|
102
102
|
#Problem comparing Tempfile in Ruby 1.8, REE and Rubinius mode 1.8
|
|
103
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path.path).to eq(@koala_io_params[0].path)
|
|
103
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).io_or_path.path).to eq(@koala_io_params[0].path)
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it "returns an UploadableIO with the same content_type" do
|
|
107
107
|
content_stub = @koala_io_params[1] = double('Content Type')
|
|
108
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
108
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
it "returns an UploadableIO with the right filename" do
|
|
112
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
|
|
112
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).filename).to eq(File.basename(@file.path))
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
|
@@ -130,18 +130,18 @@ describe "Koala::UploadableIO" do
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "returns an UploadableIO with the same io" do
|
|
133
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
|
|
133
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).io_or_path).to eq(@koala_io_params[0])
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
it "returns an UploadableIO with the same content_type" do
|
|
137
137
|
content_stub = @koala_io_params[1] = double('Content Type')
|
|
138
|
-
expect(Koala::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
138
|
+
expect(Koala::HTTPService::UploadableIO.new(*@koala_io_params).content_type).to eq(content_stub)
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
describe "and no content type" do
|
|
143
143
|
it "raises an exception" do
|
|
144
|
-
expect { Koala::UploadableIO.new(*@koala_io_params) }.to raise_exception(Koala::KoalaError)
|
|
144
|
+
expect { Koala::HTTPService::UploadableIO.new(*@koala_io_params) }.to raise_exception(Koala::KoalaError)
|
|
145
145
|
end
|
|
146
146
|
end
|
|
147
147
|
end
|
|
@@ -154,17 +154,17 @@ describe "Koala::UploadableIO" do
|
|
|
154
154
|
it "gets the path from the tempfile associated with the UploadedFile" do
|
|
155
155
|
expected_path = double('Tempfile')
|
|
156
156
|
expect(@tempfile).to receive(:path).and_return(expected_path)
|
|
157
|
-
expect(Koala::UploadableIO.new(@uploaded_file).io_or_path).to eq(expected_path)
|
|
157
|
+
expect(Koala::HTTPService::UploadableIO.new(@uploaded_file).io_or_path).to eq(expected_path)
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
it "gets the content type via the content_type method" do
|
|
161
161
|
expected_content_type = double('Content Type')
|
|
162
162
|
expect(@uploaded_file).to receive(:content_type).and_return(expected_content_type)
|
|
163
|
-
expect(Koala::UploadableIO.new(@uploaded_file).content_type).to eq(expected_content_type)
|
|
163
|
+
expect(Koala::HTTPService::UploadableIO.new(@uploaded_file).content_type).to eq(expected_content_type)
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
it "gets the filename from the UploadedFile" do
|
|
167
|
-
expect(Koala::UploadableIO.new(@uploaded_file).filename).to eq(@uploaded_file.original_filename)
|
|
167
|
+
expect(Koala::HTTPService::UploadableIO.new(@uploaded_file).filename).to eq(@uploaded_file.original_filename)
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
|
|
@@ -177,7 +177,7 @@ describe "Koala::UploadableIO" do
|
|
|
177
177
|
expected_file = double('File')
|
|
178
178
|
@file_hash[:tempfile] = expected_file
|
|
179
179
|
|
|
180
|
-
uploadable = Koala::UploadableIO.new(@file_hash)
|
|
180
|
+
uploadable = Koala::HTTPService::UploadableIO.new(@file_hash)
|
|
181
181
|
expect(uploadable.io_or_path).to eq(expected_file)
|
|
182
182
|
end
|
|
183
183
|
|
|
@@ -185,12 +185,12 @@ describe "Koala::UploadableIO" do
|
|
|
185
185
|
expected_content_type = double('Content Type')
|
|
186
186
|
@file_hash[:type] = expected_content_type
|
|
187
187
|
|
|
188
|
-
uploadable = Koala::UploadableIO.new(@file_hash)
|
|
188
|
+
uploadable = Koala::HTTPService::UploadableIO.new(@file_hash)
|
|
189
189
|
expect(uploadable.content_type).to eq(expected_content_type)
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
it "gets the content type from the :type key" do
|
|
193
|
-
uploadable = Koala::UploadableIO.new(@file_hash)
|
|
193
|
+
uploadable = Koala::HTTPService::UploadableIO.new(@file_hash)
|
|
194
194
|
expect(uploadable.filename).to eq(@file_hash[:filename])
|
|
195
195
|
end
|
|
196
196
|
end
|
|
@@ -199,12 +199,12 @@ describe "Koala::UploadableIO" do
|
|
|
199
199
|
# what that means is tested below
|
|
200
200
|
it "should accept a file object alone" do
|
|
201
201
|
params = [BEACH_BALL_PATH]
|
|
202
|
-
expect { Koala::UploadableIO.new(*params) }.not_to raise_exception
|
|
202
|
+
expect { Koala::HTTPService::UploadableIO.new(*params) }.not_to raise_exception
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
it "should accept a file path alone" do
|
|
206
206
|
params = [BEACH_BALL_PATH]
|
|
207
|
-
expect { Koala::UploadableIO.new(*params) }.not_to raise_exception
|
|
207
|
+
expect { Koala::HTTPService::UploadableIO.new(*params) }.not_to raise_exception
|
|
208
208
|
end
|
|
209
209
|
end
|
|
210
210
|
end
|
|
@@ -218,7 +218,7 @@ describe "Koala::UploadableIO" do
|
|
|
218
218
|
context "if no filename was provided" do
|
|
219
219
|
it "should call the constructor with the content type, file name, and a dummy file name" do
|
|
220
220
|
expect(UploadIO).to receive(:new).with(BEACH_BALL_PATH, "content/type", anything).and_return(@upload_io)
|
|
221
|
-
expect(Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type").to_upload_io).to eq(@upload_io)
|
|
221
|
+
expect(Koala::HTTPService::UploadableIO.new(BEACH_BALL_PATH, "content/type").to_upload_io).to eq(@upload_io)
|
|
222
222
|
end
|
|
223
223
|
end
|
|
224
224
|
|
|
@@ -226,7 +226,7 @@ describe "Koala::UploadableIO" do
|
|
|
226
226
|
it "should call the constructor with the content type, file name, and the filename" do
|
|
227
227
|
filename = "file"
|
|
228
228
|
expect(UploadIO).to receive(:new).with(BEACH_BALL_PATH, "content/type", filename).and_return(@upload_io)
|
|
229
|
-
Koala::UploadableIO.new(BEACH_BALL_PATH, "content/type", filename).to_upload_io
|
|
229
|
+
Koala::HTTPService::UploadableIO.new(BEACH_BALL_PATH, "content/type", filename).to_upload_io
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
end
|
|
@@ -234,33 +234,33 @@ describe "Koala::UploadableIO" do
|
|
|
234
234
|
describe "getting a file" do
|
|
235
235
|
it "returns the File if initialized with a file" do
|
|
236
236
|
f = File.new(BEACH_BALL_PATH)
|
|
237
|
-
expect(Koala::UploadableIO.new(f).to_file).to eq(f)
|
|
237
|
+
expect(Koala::HTTPService::UploadableIO.new(f).to_file).to eq(f)
|
|
238
238
|
end
|
|
239
239
|
|
|
240
240
|
it "should open up and return a file corresponding to the path if io_or_path is a path" do
|
|
241
241
|
result = double("File")
|
|
242
242
|
expect(File).to receive(:open).with(BEACH_BALL_PATH).and_return(result)
|
|
243
|
-
expect(Koala::UploadableIO.new(BEACH_BALL_PATH).to_file).to eq(result)
|
|
243
|
+
expect(Koala::HTTPService::UploadableIO.new(BEACH_BALL_PATH).to_file).to eq(result)
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
describe ".binary_content?" do
|
|
248
248
|
it "returns true for Rails 3 file uploads" do
|
|
249
|
-
expect(Koala::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
|
|
249
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
it "returns true for Sinatra file uploads" do
|
|
253
|
-
expect(Koala::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
|
|
253
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(rails_3_mocks.last)).to be_truthy
|
|
254
254
|
end
|
|
255
255
|
|
|
256
256
|
it "returns true for File objects" do
|
|
257
|
-
expect(Koala::UploadableIO.binary_content?(File.open(BEACH_BALL_PATH))).to be_truthy
|
|
257
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(File.open(BEACH_BALL_PATH))).to be_truthy
|
|
258
258
|
end
|
|
259
259
|
|
|
260
260
|
it "returns false for everything else" do
|
|
261
|
-
expect(Koala::UploadableIO.binary_content?(StringIO.new)).to be_falsey
|
|
262
|
-
expect(Koala::UploadableIO.binary_content?(BEACH_BALL_PATH)).to be_falsey
|
|
263
|
-
expect(Koala::UploadableIO.binary_content?(nil)).to be_falsey
|
|
261
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(StringIO.new)).to be_falsey
|
|
262
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(BEACH_BALL_PATH)).to be_falsey
|
|
263
|
+
expect(Koala::HTTPService::UploadableIO.binary_content?(nil)).to be_falsey
|
|
264
264
|
end
|
|
265
265
|
end
|
|
266
266
|
end # describe UploadableIO
|
data/spec/fixtures/cat.m4v
CHANGED
|
Binary file
|
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
# by enter an OAuth token, code, and session_key (for real users) or changing the app_id and secret (for test users)
|
|
6
6
|
# (note for real users: this will leave some photos and videos posted to your wall, since they can't be deleted through the API)
|
|
7
7
|
|
|
8
|
-
# These values are configured to work with
|
|
9
|
-
# Of course, you can change this to work with your own app.
|
|
10
|
-
# Check out http://oauth.twoalex.com/ to easily generate tokens, cookies, etc.
|
|
8
|
+
# These values are configured to work with a test app. If you want, you can change this to work with your own app.
|
|
11
9
|
|
|
12
10
|
# Your OAuth token should have the read_stream, publish_stream, user_photos, user_videos, and read_insights permissions.
|
|
13
11
|
oauth_token:
|
|
@@ -22,7 +20,7 @@ oauth_test_data:
|
|
|
22
20
|
# These values will work out of the box
|
|
23
21
|
app_id: 119908831367602
|
|
24
22
|
secret: e45e55a333eec232d4206d2703de1307
|
|
25
|
-
callback_url: http://
|
|
23
|
+
callback_url: http://testdomain.koalatest.test/
|
|
26
24
|
app_access_token: 119908831367602|o3wswWQ88LYjEC9-ukR_gjRIOMw.
|
|
27
25
|
raw_token_string: "access_token=119908831367602|2.6GneoQbnEqtSiPppZzDU4Q__.3600.1273366800-2905623|3OLa3w0x1K4C1S5cOgbs07TytAk.&expires=6621"
|
|
28
26
|
raw_offline_access_token_string: access_token=119908831367602|2.6GneoQbnEqtSiPppZzDU4Q__.3600.1273366800-2905623|3OLa3w0x1K4C1S5cOgbs07TytAk.
|
|
@@ -54,7 +52,7 @@ oauth_test_data:
|
|
|
54
52
|
issued_at: 1301917299
|
|
55
53
|
|
|
56
54
|
subscription_test_data:
|
|
57
|
-
subscription_path:
|
|
55
|
+
subscription_path: https://testdomain.koalatest.test/subscriptions
|
|
58
56
|
verify_token: "myverificationtoken|1f54545d5f722733e17faae15377928f"
|
|
59
57
|
challenge_data:
|
|
60
58
|
"hub.challenge": "1290024882"
|
|
@@ -62,4 +60,4 @@ subscription_test_data:
|
|
|
62
60
|
"hub.mode": "subscribe"
|
|
63
61
|
|
|
64
62
|
vcr_data:
|
|
65
|
-
oauth_token: CAACEdEose0cBAKuiUM40KZBEsq2l0iggaMGZBPI74svGQRMmZCPXb7eZCYPhNUbVXnnYZCjXKFKIc7HgYllr4RDIKrANHm6kKncOx0Y3UpDqLliRGZAnSEUypyFworUnBMOQJBlAuB1wlwYJZB7LIZCobCcnT2q9QwrZBpK3qAZB3u7ZAJaZAdsMZBsyALkAXatoj75leWXhgXfT1QiJHZBGoRlz07Q85z1dZBReK4ZD
|
|
63
|
+
oauth_token: CAACEdEose0cBAKuiUM40KZBEsq2l0iggaMGZBPI74svGQRMmZCPXb7eZCYPhNUbVXnnYZCjXKFKIc7HgYllr4RDIKrANHm6kKncOx0Y3UpDqLliRGZAnSEUypyFworUnBMOQJBlAuB1wlwYJZB7LIZCobCcnT2q9QwrZBpK3qAZB3u7ZAJaZAdsMZBsyALkAXatoj75leWXhgXfT1QiJHZBGoRlz07Q85z1dZBReK4ZD
|
|
@@ -10,22 +10,6 @@
|
|
|
10
10
|
# with_token:
|
|
11
11
|
# no_token:
|
|
12
12
|
|
|
13
|
-
# ====== REST API =====
|
|
14
|
-
rest_api:
|
|
15
|
-
|
|
16
|
-
# -- Stubbed Responses --
|
|
17
|
-
/method/admin.setAppProperties:
|
|
18
|
-
'properties={"desktop":0}':
|
|
19
|
-
post:
|
|
20
|
-
with_token: 'true'
|
|
21
|
-
/method/fql.query: # for testing the beta tier
|
|
22
|
-
query=select first_name from user where uid = 2901279:
|
|
23
|
-
get:
|
|
24
|
-
no_token: '[{"first_name":"Luke"}]'
|
|
25
|
-
with_token: '[{"first_name":"Luke"}]'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
13
|
# ====== GRAPH API =====
|
|
30
14
|
graph_api:
|
|
31
15
|
|
|
@@ -40,7 +24,7 @@ graph_api:
|
|
|
40
24
|
# Common mock item responses
|
|
41
25
|
item_deleted: &item_deleted
|
|
42
26
|
delete:
|
|
43
|
-
with_token: 'true'
|
|
27
|
+
with_token: '{"success":true}'
|
|
44
28
|
|
|
45
29
|
# OAuth error response
|
|
46
30
|
oauth_error: &oauth_error
|
|
@@ -68,42 +52,39 @@ graph_api:
|
|
|
68
52
|
|
|
69
53
|
# -- Stubbed Responses --
|
|
70
54
|
root:
|
|
71
|
-
ids=facebook,
|
|
55
|
+
ids=facebook,barackobama:
|
|
72
56
|
get:
|
|
73
|
-
with_token: '{"facebook":"{}","
|
|
74
|
-
no_token: '{"facebook":"{}","
|
|
57
|
+
with_token: '{"facebook":"{}","barackobama":"{}"}'
|
|
58
|
+
no_token: '{"facebook":"{}","barackobama":"{}"}'
|
|
75
59
|
|
|
76
60
|
# Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here
|
|
77
|
-
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "
|
|
61
|
+
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "barackobama"}]) %>:
|
|
78
62
|
post:
|
|
79
63
|
with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"id\":\"456\"}"}]'
|
|
80
64
|
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/picture"}]) %>:
|
|
81
65
|
post:
|
|
82
|
-
with_token: '[{"code": 302, "headers":[{"name":"Location","value":"
|
|
66
|
+
with_token: '[{"code": 302, "headers":[{"name":"Location","value":"https://google.com"}]}]'
|
|
83
67
|
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/picture?redirect=false"}]) %>:
|
|
84
68
|
post:
|
|
85
|
-
with_token: '[{"code": 200, "body":"{\"data\":{\"is_silhouette\":false,\"url\":\"
|
|
69
|
+
with_token: '[{"code": 200, "body":"{\"data\":{\"is_silhouette\":false,\"url\":\"https:\/\/google.com\"}}"}]'
|
|
86
70
|
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
|
|
87
71
|
post:
|
|
88
|
-
with_token: '[{"code": 200, "body":"{\"id\":\"
|
|
89
|
-
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/
|
|
72
|
+
with_token: '[{"code": 200, "body":"{\"id\":\"barackobama\"}"}, {"code": 200, "body":"{\"data\":[{\"id\":\"koppel\"}],\"paging\":{}}"}]'
|
|
73
|
+
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/app_event_types?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
|
|
90
74
|
post:
|
|
91
75
|
with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"data\":[],\"paging\":{}}"}]'
|
|
92
|
-
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection"}, {"method"=>"get", "relative_url"=>"
|
|
76
|
+
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection"}, {"method"=>"get", "relative_url"=>"barackobama?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
|
|
93
77
|
post:
|
|
94
78
|
with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"code": 200, "body":"{\"id\":\"123\"}"}]'
|
|
95
79
|
batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
|
|
96
80
|
post:
|
|
97
|
-
with_token: '[{"code": 200, "body": "{\"id\": \"MOCK_LIKE\"}"},{"code": 200, "body":true}]'
|
|
98
|
-
batch=<%= JSON.dump([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
|
|
99
|
-
post:
|
|
100
|
-
with_token: '[{"code": 200, "body":"[{\"first_name\":\"Alex\"}]"}]'
|
|
81
|
+
with_token: '[{"code": 200, "body": "{\"id\": \"MOCK_LIKE\"}"},{"code": 200, "body":"{\"success\":true}"}]'
|
|
101
82
|
|
|
102
83
|
# dependencies
|
|
103
|
-
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"
|
|
84
|
+
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"barackobama", "depends_on" => "getme"}]) %>:
|
|
104
85
|
post:
|
|
105
86
|
with_token: '[null,{"code": 200, "body":"{\"id\":\"123\"}"}]'
|
|
106
|
-
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"
|
|
87
|
+
batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"barackobama", "depends_on" => "getdata"}]) %>:
|
|
107
88
|
post:
|
|
108
89
|
with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
|
|
109
90
|
batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
|
|
@@ -125,7 +106,7 @@ graph_api:
|
|
|
125
106
|
batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
|
|
126
107
|
post:
|
|
127
108
|
with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
|
|
128
|
-
batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"
|
|
109
|
+
batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"barackobama/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
|
|
129
110
|
post:
|
|
130
111
|
with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}, {"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
|
|
131
112
|
|
|
@@ -163,10 +144,10 @@ graph_api:
|
|
|
163
144
|
message=Hello, world, from the test suite batch API!:
|
|
164
145
|
post:
|
|
165
146
|
with_token: '{"id": "FEED_ITEM_BATCH"}'
|
|
166
|
-
link=http://
|
|
147
|
+
link=http://testdomain.koalatest.test/&message=Hello, world, from the test suite again!&name=OAuth Playground:
|
|
167
148
|
post:
|
|
168
149
|
with_token: '{"id": "FEED_ITEM_CONTEXT"}'
|
|
169
|
-
link=http://
|
|
150
|
+
link=http://testdomain.koalatest.test/&message=body&name=It's a big question&picture=http://testdomain.koalatest.test//images/logo.png&properties=<%= JSON.dump({"Link1"=>{"text"=>"Left", "href"=>"http://testdomain.koalatest.test/"}, "other" => {"text"=>"Straight ahead", "href"=>"http://testdomain.koalatest.test/?"}}) %>&type=link:
|
|
170
151
|
post:
|
|
171
152
|
with_token: '{"id": "FEED_ITEM_DICTIONARY"}'
|
|
172
153
|
|
|
@@ -211,14 +192,14 @@ graph_api:
|
|
|
211
192
|
<<: *token_required
|
|
212
193
|
with_token: '{"id": "MOCK_PHOTO_FROM_URL"}'
|
|
213
194
|
|
|
214
|
-
/
|
|
195
|
+
/barackobama:
|
|
215
196
|
no_args:
|
|
216
197
|
get:
|
|
217
198
|
with_token: '{"id": 1, "name": 1, "updated_time": 1}'
|
|
218
199
|
no_token: '{"id": 1, "name": 1}'
|
|
219
200
|
metadata=1:
|
|
220
201
|
get:
|
|
221
|
-
with_token: '{"name": "
|
|
202
|
+
with_token: '{"name": "Barack Obama","metadata": {"fields": [{"name": "id"}],"type": "user","connections": {}},"id": "44"}'
|
|
222
203
|
|
|
223
204
|
/facebook:
|
|
224
205
|
no_args:
|
|
@@ -226,19 +207,19 @@ graph_api:
|
|
|
226
207
|
with_token: '{"id": 1, "name": 1}'
|
|
227
208
|
no_token: '{"id": 1, "name": 1}'
|
|
228
209
|
|
|
229
|
-
/facebook/
|
|
210
|
+
/facebook/events:
|
|
230
211
|
no_args:
|
|
231
212
|
get:
|
|
232
|
-
with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/
|
|
233
|
-
no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/
|
|
213
|
+
with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/events?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/events?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
|
214
|
+
no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/events?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/events?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
|
234
215
|
|
|
235
|
-
/
|
|
216
|
+
/koppel/likes:
|
|
236
217
|
no_args:
|
|
237
218
|
get:
|
|
238
219
|
<<: *token_required
|
|
239
220
|
with_token: '{"data": [{}], "paging": {}}'
|
|
240
221
|
|
|
241
|
-
/
|
|
222
|
+
/koppel/picture:
|
|
242
223
|
no_args:
|
|
243
224
|
get:
|
|
244
225
|
no_token:
|
|
@@ -287,33 +268,12 @@ graph_api:
|
|
|
287
268
|
body: '{"error": {"type": "Exception","message": "No node specified"}}'
|
|
288
269
|
|
|
289
270
|
/search:
|
|
290
|
-
q=facebook:
|
|
271
|
+
q=facebook&type=page:
|
|
291
272
|
get:
|
|
292
273
|
with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
|
293
|
-
|
|
294
|
-
"limit=25&q=facebook&until=<%= TEST_DATA['search_time'] %>":
|
|
274
|
+
"limit=25&q=facebook&type=page&until=<%= TEST_DATA['search_time'] %>":
|
|
295
275
|
get:
|
|
296
276
|
with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
|
297
|
-
no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
|
|
298
|
-
|
|
299
|
-
/fql:
|
|
300
|
-
q=select uid, first_name from user where uid = 2901279:
|
|
301
|
-
get:
|
|
302
|
-
no_token: '[{"uid":2901279,"first_name":"Luke"}]'
|
|
303
|
-
with_token: '[{"uid":2901279,"first_name":"Luke"}]'
|
|
304
|
-
q=select read_stream from permissions where uid = 2901279:
|
|
305
|
-
get:
|
|
306
|
-
<<: *token_required
|
|
307
|
-
with_token: '[{"read_stream":1}]'
|
|
308
|
-
'q=<%= JSON.dump({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>':
|
|
309
|
-
get:
|
|
310
|
-
<<: *token_required
|
|
311
|
-
with_token: '[{"name":"query1", "fql_result_set":[]},{"name":"query2", "fql_result_set":[]},{"name":"query3", "fql_result_set":[]}]'
|
|
312
|
-
'q=<%= JSON.dump({"query1" => "select uid, first_name from user where uid = 2901279", "query2" => "select uid, first_name from user where uid = 2905623"}) %>':
|
|
313
|
-
get:
|
|
314
|
-
with_token: '[{"name":"query1", "fql_result_set":[{"uid":2901279,"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"uid":"2905623","first_name":"Alex"}]}]'
|
|
315
|
-
no_token: '[{"name":"query1", "fql_result_set":[{"uid":2901279,"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"uid":"2905623","first_name":"Alex"}]}]'
|
|
316
|
-
|
|
317
277
|
|
|
318
278
|
'/115349521819193_113815981982767':
|
|
319
279
|
no_args:
|
|
@@ -407,12 +367,12 @@ graph_api:
|
|
|
407
367
|
with_token:
|
|
408
368
|
code: 200
|
|
409
369
|
get:
|
|
410
|
-
with_token: '{"data":[{"callback_url":"
|
|
370
|
+
with_token: '{"data":[{"callback_url":"https://testdomain.koalatest.test/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
|
|
411
371
|
|
|
412
372
|
|
|
413
373
|
callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
|
|
414
374
|
get:
|
|
415
|
-
with_token: '{"data":[{"callback_url":"
|
|
375
|
+
with_token: '{"data":[{"callback_url":"https://testdomain.koalatest.test/subscriptions", "fields":["name"], "object":"user", "active":true}]}'
|
|
416
376
|
|
|
417
377
|
# -- Mock Item Responses --
|
|
418
378
|
|
|
@@ -434,13 +394,13 @@ graph_api:
|
|
|
434
394
|
no_args:
|
|
435
395
|
<<: *item_deleted
|
|
436
396
|
get:
|
|
437
|
-
with_token: '{"link":"http://
|
|
397
|
+
with_token: '{"link":"http://testdomain.koalatest.test/", "name": "OAuth Playground"}'
|
|
438
398
|
|
|
439
399
|
/FEED_ITEM_DICTIONARY:
|
|
440
400
|
no_args:
|
|
441
401
|
<<: *item_deleted
|
|
442
402
|
get:
|
|
443
|
-
with_token: '{"link":"http://
|
|
403
|
+
with_token: '{"link":"http://testdomain.koalatest.test/", "name": "OAuth Playground", "properties": {}}'
|
|
444
404
|
|
|
445
405
|
/FEED_ITEM_CATS:
|
|
446
406
|
no_args:
|