koala 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2df6e7ef56616b6120136f096dbea0d3b24aa4bc
4
- data.tar.gz: 558317b99886f2aab38e2d1b414d713ea915b9cc
3
+ metadata.gz: aa79bc7b848a2513d2f1aac248d1aac70d8a392c
4
+ data.tar.gz: edfd57c54b0b96a4682cf23af9e388ed59e4aa3d
5
5
  SHA512:
6
- metadata.gz: 2149fedb633aaa21dbb3f2852a4aca1275bec57e09e70be0d958d817071400bdfd15c733a111f3496c43b1eb41e29e41e4f2a4a74432b8a8e1cefaa9ec397841
7
- data.tar.gz: 8e399264b110efb9660ebb58ec985046a9a61424d70c4373decbe9cf95a2b42cbba6b6e5e687349ab8aff04780b687edb57b4dbc9cdab0dce2a902d06b3fa2a9
6
+ metadata.gz: ed4e62ff0f2d70c17cf0301be06e552940fd14654b1dc715f10477f63da89d2b6aa14b21105e2b9e90ca88ee1ff7a60e737f2f24744ab6cb86cf4b9f6aac80ce
7
+ data.tar.gz: 7a5b55d226afdd6f8e6d8af440b7e714a1cb8ffd68c35a0f80dfdb61d042d988b8b7eb8fad95d30e3cff094a0a3ecfc07fe418d2ec61826a7338b027933d1636
@@ -3,10 +3,10 @@ sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
5
  # MRI
6
- - 1.9.3
7
6
  - 2.0
8
7
  - 2.1
9
8
  - 2.2
9
+ - 2.3.0
10
10
  # Rubinius is failing due to segfaults on Travis (and takes significantly longer to run)
11
11
  # those builds will be restored later
12
12
  # jruby
@@ -1,3 +1,26 @@
1
+ v2.4.0
2
+ ======
3
+
4
+ **Note:** Koala is no longer officially supported on Ruby 1.9.3 (which was [end-of-lifed back in
5
+ 2015](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/)). Versions may
6
+ still work (until version 3.0, when we may start using keyword arguments), but will not be tested
7
+ on 1.9.3.
8
+
9
+ Updated features:
10
+
11
+ * Batch API requests will now properly calculate appsecret_proofs for multiple access tokens
12
+ (thanks, mwpastore!)
13
+
14
+ Internal improvements:
15
+
16
+ * Koala now explicitly depends on MultiJson >= 1.3.0, since it uses methods introduced in that
17
+ version
18
+
19
+ Testing improvements:
20
+
21
+ * Test Koala against Ruby 2.3.0
22
+
23
+
1
24
  v2.3.0
2
25
  ======
3
26
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.extra_rdoc_files = ["readme.md", "changelog.md"]
22
22
  gem.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Koala"]
23
23
 
24
- gem.add_runtime_dependency("multi_json")
24
+ gem.add_runtime_dependency("multi_json", ">= 1.3.0")
25
25
  gem.add_runtime_dependency("faraday")
26
26
  gem.add_runtime_dependency("addressable")
27
27
  end
@@ -28,9 +28,15 @@ module Koala
28
28
  raise AuthenticationError.new(nil, nil, "Batch operations require an access token, none provided.") unless @access_token
29
29
  end
30
30
 
31
- def to_batch_params(main_access_token)
31
+ def to_batch_params(main_access_token, app_secret)
32
32
  # set up the arguments
33
- args_string = Koala.http_service.encode_params(@access_token == main_access_token ? @args : @args.merge(:access_token => @access_token))
33
+ if @access_token != main_access_token
34
+ @args[:access_token] = @access_token
35
+ if app_secret
36
+ @args[:appsecret_proof] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), app_secret, @access_token)
37
+ end
38
+ end
39
+ args_string = Koala.http_service.encode_params(@args)
34
40
 
35
41
  response = {
36
42
  :method => @method.to_s,
@@ -46,7 +46,7 @@ module Koala
46
46
  args = {}
47
47
  args["batch"] = MultiJson.dump(batch_calls.map { |batch_op|
48
48
  args.merge!(batch_op.files) if batch_op.files
49
- batch_op.to_batch_params(access_token)
49
+ batch_op.to_batch_params(access_token, app_secret)
50
50
  })
51
51
 
52
52
  batch_result = graph_call_outside_batch('/', args, 'post', http_options) do |response|
@@ -1,3 +1,3 @@
1
1
  module Koala
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
@@ -38,7 +38,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
38
38
  it "doesn't change the original http_options" do
39
39
  @args[:http_options][:name] = "baz2"
40
40
  expected = @args[:http_options].dup
41
- Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)
41
+ Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)
42
42
  expect(@args[:http_options]).to eq(expected)
43
43
  end
44
44
 
@@ -102,7 +102,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
102
102
 
103
103
  it "removes the value from the arguments" do
104
104
  @args[:args].merge!("source" => @binary)
105
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:body]).not_to match(/source=/)
105
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:body]).not_to match(/source=/)
106
106
  end
107
107
  end
108
108
 
@@ -116,7 +116,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
116
116
  @args[:url] = url = "/"
117
117
  allow(Koala.http_service).to receive(:encode_params).and_return(test_args)
118
118
 
119
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:relative_url]).to eq("#{url}?#{test_args}")
119
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:relative_url]).to eq("#{url}?#{test_args}")
120
120
  end
121
121
 
122
122
  it "adds the args to the URL string, with & if args previously present" do
@@ -124,16 +124,16 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
124
124
  @args[:url] = url = "/?a=2"
125
125
  allow(Koala.http_service).to receive(:encode_params).and_return(test_args)
126
126
 
127
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:relative_url]).to eq("#{url}&#{test_args}")
127
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:relative_url]).to eq("#{url}&#{test_args}")
128
128
  end
129
129
 
130
130
  it "adds nothing to the URL string if there are no args to be added" do
131
131
  @args[:args] = {}
132
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token])[:relative_url]).to eq(@args[:url])
132
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token], nil)[:relative_url]).to eq(@args[:url])
133
133
  end
134
134
 
135
135
  it "adds nothing to the body" do
136
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:body]).to be_nil
136
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:body]).to be_nil
137
137
  end
138
138
  end
139
139
 
@@ -142,13 +142,13 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
142
142
  test_args = "foo"
143
143
  allow(Koala.http_service).to receive(:encode_params).and_return(test_args)
144
144
 
145
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:body]).to eq(test_args)
145
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:body]).to eq(test_args)
146
146
  end
147
147
 
148
148
  it "does not set the body if there are no args" do
149
149
  test_args = ""
150
150
  allow(Koala.http_service).to receive(:encode_params).and_return(test_args)
151
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:body]).to be_nil
151
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:body]).to be_nil
152
152
  end
153
153
 
154
154
 
@@ -156,7 +156,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
156
156
  test_args = "foo"
157
157
  allow(Koala.http_service).to receive(:encode_params).and_return(test_args)
158
158
 
159
- expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)[:relative_url]).to eq(@args[:url])
159
+ expect(Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)[:relative_url]).to eq(@args[:url])
160
160
  end
161
161
  end
162
162
 
@@ -194,45 +194,50 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
194
194
  end
195
195
 
196
196
  it "includes the access token if the token is not the main one for the request" do
197
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)
197
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)
198
198
  expect(params[:relative_url]).to match(/access_token=#{@args[:access_token]}/)
199
199
  end
200
200
 
201
+ it "re-signs the access token if the token is not the main one for the request" do
202
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, '1234')
203
+ expect(params[:relative_url]).to match(/appsecret_proof=[^?&]+/)
204
+ end
205
+
201
206
  it "includes the other arguments if the token is not the main one for the request" do
202
207
  @args[:args] = {:a => 2}
203
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)
208
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)
204
209
  expect(params[:relative_url]).to match(/a=2/)
205
210
  end
206
211
 
207
212
  it "does not include the access token if the token is the main one for the request" do
208
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token])
213
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token], nil)
209
214
  expect(params[:relative_url]).not_to match(/access_token=#{@args[:access_token]}/)
210
215
  end
211
216
 
212
217
  it "includes the other arguments if the token is the main one for the request" do
213
218
  @args[:args] = {:a => 2}
214
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token])
219
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token], nil)
215
220
  expect(params[:relative_url]).to match(/a=2/)
216
221
  end
217
222
 
218
223
  it "includes any arguments passed as http_options[:batch_args]" do
219
224
  batch_args = {:name => "baz", :headers => {:some_param => true}}
220
225
  @args[:http_options][:batch_args] = batch_args
221
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil)
226
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(nil, nil)
222
227
  expect(params).to include(batch_args)
223
228
  end
224
229
 
225
230
  it "includes the method" do
226
- params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token])
231
+ params = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args).to_batch_params(@args[:access_token], nil)
227
232
  expect(params[:method]).to eq(@args[:method].to_s)
228
233
  end
229
234
 
230
235
  it "works with nil http_options" do
231
- expect { Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args.merge(:http_options => nil)).to_batch_params(nil) }.not_to raise_exception
236
+ expect { Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args.merge(:http_options => nil)).to_batch_params(nil, nil) }.not_to raise_exception
232
237
  end
233
238
 
234
239
  it "works with nil args" do
235
- expect { Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args.merge(:args => nil)).to_batch_params(nil) }.not_to raise_exception
240
+ expect { Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args.merge(:args => nil)).to_batch_params(nil, nil) }.not_to raise_exception
236
241
  end
237
242
 
238
243
  describe "with binary files" do
@@ -254,7 +259,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
254
259
  @args[:args].merge!("source" => @binary, "source2" => @binary)
255
260
  batch_op = Koala::Facebook::GraphBatchAPI::BatchOperation.new(@args)
256
261
  file_ids = batch_op.files.find_all {|k, v| v == @uploadable_io}.map {|k, v| k}
257
- params = batch_op.to_batch_params(nil)
262
+ params = batch_op.to_batch_params(nil, nil)
258
263
  expect(params[:attached_files]).to eq(file_ids.join(","))
259
264
  end
260
265
  end
@@ -317,7 +322,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
317
322
  allow(Koala::Facebook::GraphBatchAPI::BatchOperation).to receive(:new).and_return(op)
318
323
 
319
324
  # two requests should generate two batch operations
320
- expected = MultiJson.dump([op.to_batch_params(access_token), op.to_batch_params(access_token)])
325
+ expected = MultiJson.dump([op.to_batch_params(access_token, nil), op.to_batch_params(access_token, nil)])
321
326
  expect(Koala).to receive(:make_request).with(anything, hash_including("batch" => expected), anything, anything).and_return(@fake_response)
322
327
  Koala::Facebook::API.new(access_token).batch do |batch_api|
323
328
  batch_api.get_object('me')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koala
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koppel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-10 00:00:00.000000000 Z
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement