koala 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +32 -0
- data/Gemfile +3 -2
- data/changelog.md +38 -0
- data/koala.gemspec +2 -1
- data/lib/koala/api.rb +1 -1
- data/lib/koala/configuration.rb +4 -0
- data/lib/koala/http_service.rb +13 -2
- data/lib/koala/version.rb +1 -1
- data/readme.md +2 -2
- data/spec/cases/http_service_spec.rb +41 -2
- data/spec/fixtures/vcr_cassettes/app_test_accounts.yml +1 -1
- data/spec/support/mock_http_service.rb +2 -2
- metadata +26 -45
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3209d60dbf8ab51fac40f7b990f221076bb453329641194dce55b800d0611856
|
4
|
+
data.tar.gz: 9dfb75f13c1b1e187c325453793b6dfcdc085a0f42e119d40df7a30d7b492250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aa7c4c61594d111e5654788712a56eea9005e4e3f6ce133536de6d2089f6014a6a0f5a059012b3bccf2204862b6c28212b517a4a264ea4b2cc272530d11cb4f
|
7
|
+
data.tar.gz: 318d505d832d0d2e70cd9df39040254c1eea64bdf3c743cf29c6311e8fe2cd68159f3237a27a6a066136b5d3306029771fae2935fc4c768860a2c12525f29137
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
name: on ruby ${{matrix.ruby}}
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby: [2.5, 2.6, 2.7, "3.0", 3.1, head]
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- name: Checkout repository
|
17
|
+
uses: actions/checkout@v2
|
18
|
+
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{matrix.ruby}}
|
23
|
+
|
24
|
+
- name: Install dependencies
|
25
|
+
run: bundle install --jobs 4 --retry 3
|
26
|
+
|
27
|
+
- name: Specs & Coverage
|
28
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
29
|
+
env:
|
30
|
+
CC_TEST_REPORTER_ID: 7af99d9225b4c14640f9ec3cb2e24d2f7103ac49417b0bd989188fb6c25f2909
|
31
|
+
with:
|
32
|
+
coverageCommand: bundle exec rspec
|
data/Gemfile
CHANGED
@@ -7,15 +7,16 @@ group :development do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
group :development, :test do
|
10
|
+
gem "psych", '< 4.0.0' # safe_load signature not compatible with older rubies
|
10
11
|
gem "rake"
|
11
12
|
gem "typhoeus" unless defined? JRUBY_VERSION
|
12
13
|
end
|
13
14
|
|
14
15
|
group :test do
|
15
16
|
gem "rspec", '~> 3.4'
|
16
|
-
gem "vcr"
|
17
|
+
gem "vcr", github: 'vcr/vcr', ref: '8ced6c96e01737a418cd270e0382a8c2c6d85f7f' # needs https://github.com/vcr/vcr/pull/907 for ruby 3.1
|
17
18
|
gem "webmock"
|
18
|
-
gem "
|
19
|
+
gem "simplecov"
|
19
20
|
end
|
20
21
|
|
21
22
|
gem "jruby-openssl" if defined? JRUBY_VERSION
|
data/changelog.md
CHANGED
@@ -1,3 +1,41 @@
|
|
1
|
+
Unreleased
|
2
|
+
==========
|
3
|
+
|
4
|
+
**Key breaking changes:**
|
5
|
+
|
6
|
+
New features:
|
7
|
+
|
8
|
+
Updated features:
|
9
|
+
|
10
|
+
Removed features:
|
11
|
+
|
12
|
+
Internal improvements:
|
13
|
+
|
14
|
+
Testing improvements:
|
15
|
+
|
16
|
+
Others:
|
17
|
+
|
18
|
+
v3.1.0 (2022-18-01)
|
19
|
+
======
|
20
|
+
|
21
|
+
New features:
|
22
|
+
|
23
|
+
* mask_tokens config (default: true) to mask tokens in logs
|
24
|
+
|
25
|
+
Updated features:
|
26
|
+
|
27
|
+
* Log before and after sending request
|
28
|
+
|
29
|
+
Internal improvements:
|
30
|
+
|
31
|
+
* Lock Faraday to < 2
|
32
|
+
* Compatibility with ruby 3.x
|
33
|
+
|
34
|
+
Testing improvements:
|
35
|
+
|
36
|
+
* Use Github actions for CI
|
37
|
+
* Run CI on latest rubies
|
38
|
+
|
1
39
|
v3.0.0 (2017-03-17)
|
2
40
|
======
|
3
41
|
|
data/koala.gemspec
CHANGED
@@ -23,7 +23,8 @@ Gem::Specification.new do |gem|
|
|
23
23
|
|
24
24
|
gem.required_ruby_version = '>= 2.1'
|
25
25
|
|
26
|
-
gem.add_runtime_dependency("faraday")
|
26
|
+
gem.add_runtime_dependency("faraday", "< 2")
|
27
27
|
gem.add_runtime_dependency("addressable")
|
28
28
|
gem.add_runtime_dependency("json", ">= 1.8")
|
29
|
+
gem.add_runtime_dependency("rexml")
|
29
30
|
end
|
data/lib/koala/api.rb
CHANGED
@@ -102,7 +102,7 @@ module Koala
|
|
102
102
|
args = sanitize_request_parameters(args) unless preserve_form_arguments?(options)
|
103
103
|
|
104
104
|
# add a leading / if needed...
|
105
|
-
path = "/#{path}" unless path =~ /^\//
|
105
|
+
path = "/#{path}" unless path.to_s =~ /^\//
|
106
106
|
|
107
107
|
# make the request via the provided service
|
108
108
|
result = Koala.make_request(path, args, verb, options)
|
data/lib/koala/configuration.rb
CHANGED
@@ -28,6 +28,9 @@ class Koala::Configuration
|
|
28
28
|
# The server to use when constructing dialog URLs.
|
29
29
|
attr_accessor :dialog_host
|
30
30
|
|
31
|
+
# Whether or not to mask tokens
|
32
|
+
attr_accessor :mask_tokens
|
33
|
+
|
31
34
|
# Certain Facebook services (beta, video) require you to access different
|
32
35
|
# servers. If you're using your own servers, for instance, for a proxy,
|
33
36
|
# you can change both the matcher (what value to change when updating the URL) and the
|
@@ -45,5 +48,6 @@ class Koala::Configuration
|
|
45
48
|
Koala::HTTPService::DEFAULT_SERVERS.each_pair do |key, value|
|
46
49
|
self.public_send("#{key}=", value)
|
47
50
|
end
|
51
|
+
self.mask_tokens = true
|
48
52
|
end
|
49
53
|
end
|
data/lib/koala/http_service.rb
CHANGED
@@ -49,6 +49,18 @@ module Koala
|
|
49
49
|
# set up our Faraday connection
|
50
50
|
conn = Faraday.new(request.server, faraday_options(request.options), &(faraday_middleware || DEFAULT_MIDDLEWARE))
|
51
51
|
|
52
|
+
filtered_args = request.raw_args.dup.transform_keys(&:to_s)
|
53
|
+
|
54
|
+
if Koala.config.mask_tokens
|
55
|
+
%w(access_token input_token).each do |arg_token|
|
56
|
+
if (token = filtered_args[arg_token])
|
57
|
+
filtered_args[arg_token] = token[0, 10] + '*****' + token[-5, 5]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Koala::Utils.debug "STARTED => #{request.verb.upcase}: #{request.path} params: #{filtered_args.inspect}"
|
63
|
+
|
52
64
|
if request.verb == "post" && request.json?
|
53
65
|
# JSON requires a bit more handling
|
54
66
|
# remember, all non-GET requests are turned into POSTs, so this covers everything but GETs
|
@@ -62,8 +74,7 @@ module Koala
|
|
62
74
|
response = conn.send(request.verb, request.path, request.post_args)
|
63
75
|
end
|
64
76
|
|
65
|
-
#
|
66
|
-
Koala::Utils.debug "#{request.verb.upcase}: #{request.path} params: #{request.raw_args.inspect}"
|
77
|
+
Koala::Utils.debug "FINISHED => #{request.verb.upcase}: #{request.path} params: #{filtered_args.inspect}"
|
67
78
|
Koala::HTTPService::Response.new(response.status.to_i, response.body, response.headers)
|
68
79
|
end
|
69
80
|
|
data/lib/koala/version.rb
CHANGED
data/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
Koala [![Version](https://img.shields.io/gem/v/koala.svg)](https://rubygems.org/gems/koala) [![
|
1
|
+
Koala [![Version](https://img.shields.io/gem/v/koala.svg)](https://rubygems.org/gems/koala) [![Build Status](https://img.shields.io/travis/arsduo/koala.svg)](http://travis-ci.org/arsduo/koala) [![Code Climate](https://img.shields.io/codeclimate/coverage-letter/arsduo/koala.svg)](https://codeclimate.com/github/arsduo/koala) [![Code Coverage](https://img.shields.io/codeclimate/coverage/arsduo/koala.svg)](https://codeclimate.com/github/arsduo/koala)
|
2
2
|
====
|
3
|
-
[Koala](http://github.com/arsduo/koala) is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), realtime updates, test users, and OAuth validation. We wrote Koala with four goals:
|
3
|
+
[Koala](http://github.com/arsduo/koala) is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the Marketing API, the Atlas API, realtime updates, test users, and OAuth validation. We wrote Koala with four goals:
|
4
4
|
|
5
5
|
* Lightweight: Koala should be as light and simple as Facebook’s own libraries, providing API accessors and returning simple JSON.
|
6
6
|
* Fast: Koala should, out of the box, be quick. Out of the box, we use Facebook's faster read-only servers when possible and if available, the Typhoeus gem to make snappy Facebook requests. Of course, that brings us to our next topic:
|
@@ -122,7 +122,8 @@ describe Koala::HTTPService do
|
|
122
122
|
|
123
123
|
let(:verb) { "get" }
|
124
124
|
let(:options) { {} }
|
125
|
-
let(:
|
125
|
+
let(:args) { {"an" => :arg } }
|
126
|
+
let(:request) { Koala::HTTPService::Request.new(path: "/foo", verb: verb, args: args, options: options) }
|
126
127
|
|
127
128
|
shared_examples_for :making_a_request do
|
128
129
|
before :each do
|
@@ -153,7 +154,8 @@ describe Koala::HTTPService do
|
|
153
154
|
|
154
155
|
it "logs verb, url and params to debug" do
|
155
156
|
log_message = "#{verb.upcase}: #{request.path} params: #{request.raw_args.inspect}"
|
156
|
-
expect(Koala::Utils.logger).to receive(:debug).with(log_message)
|
157
|
+
expect(Koala::Utils.logger).to receive(:debug).with("STARTED => #{log_message}")
|
158
|
+
expect(Koala::Utils.logger).to receive(:debug).with("FINISHED => #{log_message}")
|
157
159
|
|
158
160
|
Koala::HTTPService.make_request(request)
|
159
161
|
end
|
@@ -230,5 +232,42 @@ describe Koala::HTTPService do
|
|
230
232
|
|
231
233
|
Koala::HTTPService.make_request(request)
|
232
234
|
end
|
235
|
+
|
236
|
+
context 'log_tokens configuration' do
|
237
|
+
let(:args) { { "an" => :arg, "access_token" => "myvisbleaccesstoken" } }
|
238
|
+
|
239
|
+
before(:each) do
|
240
|
+
allow_any_instance_of(Faraday::Connection).to receive(:get) { double(status: '200', body: 'ok', headers: {}) }
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'logs tokens' do
|
244
|
+
allow(Koala.config).to receive(:mask_tokens) { false }
|
245
|
+
|
246
|
+
expect(Koala::Utils).to receive(:debug).with('STARTED => GET: /foo params: {"an"=>:arg, "access_token"=>"myvisbleaccesstoken"}')
|
247
|
+
expect(Koala::Utils).to receive(:debug).with('FINISHED => GET: /foo params: {"an"=>:arg, "access_token"=>"myvisbleaccesstoken"}')
|
248
|
+
|
249
|
+
Koala::HTTPService.make_request(request)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'doesnt log tokens' do
|
253
|
+
allow(Koala.config).to receive(:mask_tokens) { true }
|
254
|
+
|
255
|
+
expect(Koala::Utils).to receive(:debug).with('STARTED => GET: /foo params: {"an"=>:arg, "access_token"=>"myvisbleac*****token"}')
|
256
|
+
expect(Koala::Utils).to receive(:debug).with('FINISHED => GET: /foo params: {"an"=>:arg, "access_token"=>"myvisbleac*****token"}')
|
257
|
+
|
258
|
+
Koala::HTTPService.make_request(request)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'hides the token for the debug_token api endpoint' do
|
262
|
+
request = Koala::HTTPService::Request.new(path: "/debug_token", verb: verb, args: { input_token: 'myvisibleaccesstoken', 'access_token' => 'myvisibleaccesstoken' }, options: options)
|
263
|
+
|
264
|
+
allow(Koala.config).to receive(:mask_tokens) { true }
|
265
|
+
|
266
|
+
expect(Koala::Utils).to receive(:debug).with('STARTED => GET: /debug_token params: {"input_token"=>"myvisiblea*****token", "access_token"=>"myvisiblea*****token"}')
|
267
|
+
expect(Koala::Utils).to receive(:debug).with('FINISHED => GET: /debug_token params: {"input_token"=>"myvisiblea*****token", "access_token"=>"myvisiblea*****token"}')
|
268
|
+
|
269
|
+
Koala::HTTPService.make_request(request)
|
270
|
+
end
|
271
|
+
end
|
233
272
|
end
|
234
273
|
end
|
@@ -8,7 +8,7 @@ module Koala
|
|
8
8
|
# Mocks all HTTP requests for with koala_spec_with_mocks.rb
|
9
9
|
# Mocked values to be included in TEST_DATA used in specs
|
10
10
|
ACCESS_TOKEN = '*'
|
11
|
-
APP_ACCESS_TOKEN = "
|
11
|
+
APP_ACCESS_TOKEN = "********************"
|
12
12
|
OAUTH_CODE = 'OAUTHCODE'
|
13
13
|
|
14
14
|
# Loads testing data
|
@@ -30,7 +30,7 @@ module Koala
|
|
30
30
|
|
31
31
|
# Loads the mock response data via ERB to substitue values for TEST_DATA (see oauth/access_token)
|
32
32
|
mock_response_file_path = File.join(File.dirname(__FILE__), '..', 'fixtures', 'mock_facebook_responses.yml')
|
33
|
-
RESPONSES = YAML.
|
33
|
+
RESPONSES = YAML.safe_load(ERB.new(IO.read(mock_response_file_path)).result(binding), [], [], true)
|
34
34
|
|
35
35
|
def self.make_request(request)
|
36
36
|
if response = match_response(request.raw_path, request.raw_args, request.raw_verb, request.raw_options)
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koala
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Koppel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
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: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: addressable
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rexml
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
|
56
70
|
access to the social graph via the Graph and REST APIs, as well as support for realtime
|
57
71
|
updates and OAuth and Facebook Connect authentication. Koala is fully tested and
|
@@ -64,9 +78,9 @@ extra_rdoc_files:
|
|
64
78
|
- readme.md
|
65
79
|
- changelog.md
|
66
80
|
files:
|
81
|
+
- ".github/workflows/test.yml"
|
67
82
|
- ".gitignore"
|
68
83
|
- ".rspec"
|
69
|
-
- ".travis.yml"
|
70
84
|
- ".yardopts"
|
71
85
|
- Gemfile
|
72
86
|
- ISSUE_TEMPLATE
|
@@ -132,7 +146,7 @@ homepage: http://github.com/arsduo/koala
|
|
132
146
|
licenses:
|
133
147
|
- MIT
|
134
148
|
metadata: {}
|
135
|
-
post_install_message:
|
149
|
+
post_install_message:
|
136
150
|
rdoc_options:
|
137
151
|
- "--line-numbers"
|
138
152
|
- "--inline-source"
|
@@ -151,42 +165,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0'
|
153
167
|
requirements: []
|
154
|
-
|
155
|
-
|
156
|
-
signing_key:
|
168
|
+
rubygems_version: 3.0.0
|
169
|
+
signing_key:
|
157
170
|
specification_version: 4
|
158
171
|
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
159
172
|
the REST API, realtime updates, and OAuth authentication.
|
160
|
-
test_files:
|
161
|
-
- spec/cases/api_spec.rb
|
162
|
-
- spec/cases/configuration_spec.rb
|
163
|
-
- spec/cases/error_spec.rb
|
164
|
-
- spec/cases/graph_api_batch_spec.rb
|
165
|
-
- spec/cases/graph_api_spec.rb
|
166
|
-
- spec/cases/graph_collection_spec.rb
|
167
|
-
- spec/cases/graph_error_checker_spec.rb
|
168
|
-
- spec/cases/http_service/request_spec.rb
|
169
|
-
- spec/cases/http_service/response_spec.rb
|
170
|
-
- spec/cases/http_service_spec.rb
|
171
|
-
- spec/cases/koala_spec.rb
|
172
|
-
- spec/cases/koala_test_spec.rb
|
173
|
-
- spec/cases/multipart_request_spec.rb
|
174
|
-
- spec/cases/oauth_spec.rb
|
175
|
-
- spec/cases/realtime_updates_spec.rb
|
176
|
-
- spec/cases/test_users_spec.rb
|
177
|
-
- spec/cases/uploadable_io_spec.rb
|
178
|
-
- spec/cases/utils_spec.rb
|
179
|
-
- spec/fixtures/beach.jpg
|
180
|
-
- spec/fixtures/cat.m4v
|
181
|
-
- spec/fixtures/facebook_data.yml
|
182
|
-
- spec/fixtures/mock_facebook_responses.yml
|
183
|
-
- spec/fixtures/vcr_cassettes/app_test_accounts.yml
|
184
|
-
- spec/fixtures/vcr_cassettes/friend_list_next_page.yml
|
185
|
-
- spec/integration/graph_collection_spec.rb
|
186
|
-
- spec/spec_helper.rb
|
187
|
-
- spec/support/custom_matchers.rb
|
188
|
-
- spec/support/graph_api_shared_examples.rb
|
189
|
-
- spec/support/koala_test.rb
|
190
|
-
- spec/support/mock_http_service.rb
|
191
|
-
- spec/support/uploadable_io_shared_examples.rb
|
192
|
-
has_rdoc:
|
173
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
# MRI
|
6
|
-
- 2.1
|
7
|
-
- 2.2
|
8
|
-
- 2.3.1
|
9
|
-
- 2.4.0
|
10
|
-
# Rubinius is failing due to segfaults on Travis (and takes significantly longer to run)
|
11
|
-
# those builds will be restored later
|
12
|
-
# jruby
|
13
|
-
# - jruby-19mode
|
14
|
-
bundler_args: --without development
|
15
|
-
addons:
|
16
|
-
code_climate:
|
17
|
-
repo_token: 7af99d9225b4c14640f9ec3cb2e24d2f7103ac49417b0bd989188fb6c25f2909
|
18
|
-
after_success:
|
19
|
-
- bundle exec codeclimate-test-reporter
|