restforce 6.2.0 → 6.2.2
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/.github/workflows/faraday.yml +2 -2
- data/.gitignore +3 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -2
- data/README.md +8 -7
- data/lib/restforce/concerns/base.rb +5 -0
- data/lib/restforce/concerns/connection.rb +8 -1
- data/lib/restforce/config.rb +4 -0
- data/lib/restforce/error_code.rb +4 -0
- data/lib/restforce/file_part.rb +3 -1
- data/lib/restforce/middleware/gzip.rb +4 -0
- data/lib/restforce/version.rb +1 -1
- data/spec/unit/config_spec.rb +1 -1
- data/spec/unit/middleware/gzip_spec.rb +57 -22
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18f985dc2a3f2b1776f442009e24453e35c19d946f1d0f6ecdd42af56693c8ca
|
4
|
+
data.tar.gz: a9ab15688f2eaf7122b57bdca9bdbd54724983f6c38ee311aed095cd7ed3c950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22bdd50789784b18f20dabaa86358db0d05e37e630770ea70da379b5c3410059b8b003e7e8a26347c3ee0141f8b81dc1d422d796454e32bca7531b9f81f72041
|
7
|
+
data.tar.gz: 520de3d9f192d6f658fc8bca961975550432054b8c6db5710a5198bb7947c0b485b5a9ff112a1e4cf1848a13344f6cdc0adb2ef498a2ea5175c76582f4bdd395
|
@@ -10,7 +10,7 @@ jobs:
|
|
10
10
|
# For v2.0.x, we test v2.0.0 and v2.0.1 because v2.0.0 has a special behaviour where
|
11
11
|
# the Net::HTTP adapter is not included. See
|
12
12
|
# https://github.com/lostisland/faraday/blob/main/UPGRADING.md#faraday-20.
|
13
|
-
faraday_version: ['1.1.0', '1.2.0', '1.3.1', '1.4.
|
13
|
+
faraday_version: ['1.1.0', '1.2.0', '1.3.1', '1.4.3', '1.5.1', '1.6.0', '1.7.2', '1.8.0', '1.9.3', '1.10.3', '2.0.0', '2.0.1', '2.1.0', '2.2.0', '2.3.0', '2.4.0', '2.5.2', '2.6.0', '2.7.4']
|
14
14
|
env:
|
15
15
|
FARADAY_VERSION: ~> ${{ matrix.faraday_version }}
|
16
16
|
steps:
|
@@ -24,4 +24,4 @@ jobs:
|
|
24
24
|
- name: Install dependencies
|
25
25
|
run: bundle install
|
26
26
|
- name: Run RSpec tests
|
27
|
-
run: bundle exec rspec
|
27
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 6.2.2 (Mar 24 2023)
|
2
|
+
|
3
|
+
* Handle the `INSUFFICIENT_ACCESS` error returned by the Salesforce API (@timrogers, @nstuart-at-salesforce)
|
4
|
+
|
5
|
+
# 6.2.1 (Jan 18 2023)
|
6
|
+
|
7
|
+
* When a response claims to be gzipped but isn't, return the body as it is and don't explode (@timrogers)
|
8
|
+
|
1
9
|
# 6.2.0 (Jan 18 2023)
|
2
10
|
|
3
11
|
* Add support for `faraday` v2.7.x (@timrogers)
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ faraday_version = ENV.fetch('FARADAY_VERSION', '~> 2.7.3')
|
|
7
7
|
|
8
8
|
# Enable us to explicitly pick a Faraday version when running tests
|
9
9
|
gem 'faraday', faraday_version
|
10
|
-
gem 'faraday-typhoeus', '~> 0.
|
10
|
+
gem 'faraday-typhoeus', '~> 1.0.0' unless faraday_version.start_with?("~> 1")
|
11
11
|
gem 'faye' unless RUBY_PLATFORM == 'java'
|
12
12
|
gem 'guard-rspec'
|
13
13
|
gem 'guard-rubocop'
|
@@ -17,6 +17,6 @@ gem 'rspec', '~> 3.12.0'
|
|
17
17
|
gem 'rspec-collection_matchers', '~> 1.2.0'
|
18
18
|
gem 'rspec-its', '~> 1.3.0'
|
19
19
|
gem 'rspec_junit_formatter', '~> 0.6.0'
|
20
|
-
gem 'rubocop', '~> 1.
|
20
|
+
gem 'rubocop', '~> 1.48.0'
|
21
21
|
gem 'simplecov', '~> 0.22.0'
|
22
22
|
gem 'webmock', '~> 3.18.1'
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ Features include:
|
|
27
27
|
|
28
28
|
Add this line to your application's Gemfile:
|
29
29
|
|
30
|
-
gem 'restforce', '~> 6.2.
|
30
|
+
gem 'restforce', '~> 6.2.2'
|
31
31
|
|
32
32
|
And then execute:
|
33
33
|
|
@@ -112,12 +112,13 @@ The `id` field can be used to [uniquely identify](https://developer.salesforce.c
|
|
112
112
|
If you prefer to use a username and password to authenticate:
|
113
113
|
|
114
114
|
```ruby
|
115
|
-
client = Restforce.new(username: '
|
116
|
-
password: '
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
client = Restforce.new(username: config['username'],
|
116
|
+
password: config['password'],
|
117
|
+
instance_url: config['instance_url'],
|
118
|
+
host: config['host'], # https://test.salesforce.com for sandbox (optional)
|
119
|
+
client_id: config['client_key'], # Salesforce Client Key
|
120
|
+
client_secret: config['client_secret'], # Salesforce Client Secret
|
121
|
+
api_version: '55.0')
|
121
122
|
```
|
122
123
|
|
123
124
|
#### JWT Bearer Token
|
@@ -57,6 +57,11 @@ module Restforce
|
|
57
57
|
#
|
58
58
|
# :request_headers - A hash containing custom headers that will be
|
59
59
|
# appended to each request
|
60
|
+
#
|
61
|
+
# :clear_authorization_header - A boolean that when set to true will cause
|
62
|
+
# the Faraday::FollowRedirects middleware to
|
63
|
+
# omit the auth header when following
|
64
|
+
# redirects (default: false)
|
60
65
|
|
61
66
|
def initialize(opts = {})
|
62
67
|
raise ArgumentError, 'Please specify a hash of options' unless opts.is_a?(Hash)
|
@@ -20,6 +20,8 @@ module Restforce
|
|
20
20
|
private
|
21
21
|
|
22
22
|
# Internal: Internal faraday connection where all requests go through
|
23
|
+
# rubocop:disable Metrics/AbcSize
|
24
|
+
# rubocop:disable Metrics/BlockLength
|
23
25
|
def connection
|
24
26
|
@connection ||= Faraday.new(options[:instance_url],
|
25
27
|
connection_options) do |builder|
|
@@ -43,7 +45,10 @@ module Restforce
|
|
43
45
|
# Caches GET requests.
|
44
46
|
builder.use Restforce::Middleware::Caching, cache, options if cache
|
45
47
|
# Follows 30x redirects.
|
46
|
-
builder.use Faraday::FollowRedirects::Middleware
|
48
|
+
builder.use Faraday::FollowRedirects::Middleware, {
|
49
|
+
# Pass the option to clear or send the auth header on redirects through
|
50
|
+
clear_authorization_header: options[:clear_authorization_header]
|
51
|
+
}
|
47
52
|
# Raises errors for 40x responses.
|
48
53
|
builder.use Restforce::Middleware::RaiseError
|
49
54
|
# Parses returned JSON response into a hash.
|
@@ -64,6 +69,8 @@ module Restforce
|
|
64
69
|
builder.adapter adapter
|
65
70
|
end
|
66
71
|
end
|
72
|
+
# rubocop:enable Metrics/BlockLength
|
73
|
+
# rubocop:enable Metrics/AbcSize
|
67
74
|
|
68
75
|
def adapter
|
69
76
|
options[:adapter]
|
data/lib/restforce/config.rb
CHANGED
@@ -161,6 +161,10 @@ module Restforce
|
|
161
161
|
# Set use_cache to false to opt in to caching with client.with_caching
|
162
162
|
option :use_cache, default: true
|
163
163
|
|
164
|
+
# Set to true to have Faraday::FollowRedirects middleware omit the auth header
|
165
|
+
# when following redirects
|
166
|
+
option :clear_authorization_header, default: false
|
167
|
+
|
164
168
|
def options
|
165
169
|
self.class.options
|
166
170
|
end
|
data/lib/restforce/error_code.rb
CHANGED
@@ -171,6 +171,8 @@ module Restforce
|
|
171
171
|
|
172
172
|
class InsertUpdateDeleteNotAllowedDuringMaintenance < ResponseError; end
|
173
173
|
|
174
|
+
class InsufficientAccess < ResponseError; end
|
175
|
+
|
174
176
|
class InsufficientAccessOnCrossReferenceEntity < ResponseError; end
|
175
177
|
|
176
178
|
class InsufficientAccessOrReadonly < ResponseError; end
|
@@ -500,6 +502,8 @@ module Restforce
|
|
500
502
|
"INACTIVE_OWNER_OR_USER" => InactiveOwnerOrUser,
|
501
503
|
"INSERT_UPDATE_DELETE_NOT_ALLOWED_DURING_MAINTENANCE" =>
|
502
504
|
InsertUpdateDeleteNotAllowedDuringMaintenance,
|
505
|
+
"INSUFFICIENT_ACCESS" =>
|
506
|
+
InsufficientAccess,
|
503
507
|
"INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" =>
|
504
508
|
InsufficientAccessOnCrossReferenceEntity,
|
505
509
|
"INSUFFICIENT_ACCESS_OR_READONLY" => InsufficientAccessOrReadonly,
|
data/lib/restforce/file_part.rb
CHANGED
@@ -29,4 +29,6 @@ end
|
|
29
29
|
|
30
30
|
# This patch is only needed with multipart-post < 2.0.0
|
31
31
|
# 2.0.0 was released in 2013.
|
32
|
-
|
32
|
+
if defined?(Parts) && Parts::Part.method(:new).arity.abs != 4
|
33
|
+
require 'restforce/patches/parts'
|
34
|
+
end
|
@@ -28,6 +28,10 @@ module Restforce
|
|
28
28
|
# Internal: Decompresses a gzipped string.
|
29
29
|
def decompress(body)
|
30
30
|
Zlib::GzipReader.new(StringIO.new(body)).read
|
31
|
+
rescue Zlib::GzipFile::Error
|
32
|
+
# We thought the response was gzipped, but it wasn't. Return the original
|
33
|
+
# body back to the caller. See https://github.com/restforce/restforce/issues/761.
|
34
|
+
body
|
31
35
|
end
|
32
36
|
end
|
33
37
|
end
|
data/lib/restforce/version.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -62,7 +62,7 @@ describe Restforce do
|
|
62
62
|
%i[username password security_token client_id client_secret compress
|
63
63
|
timeout oauth_token refresh_token instance_url api_version host mashify
|
64
64
|
authentication_retries proxy_uri authentication_callback ssl
|
65
|
-
request_headers log_level logger].each do |attr|
|
65
|
+
request_headers log_level logger clear_authorization_header].each do |attr|
|
66
66
|
it "allows #{attr} to be set" do
|
67
67
|
Restforce.configure do |config|
|
68
68
|
config.send("#{attr}=", 'foobar')
|
@@ -17,38 +17,73 @@ describe Restforce::Middleware::Gzip do
|
|
17
17
|
describe '.call' do
|
18
18
|
subject { lambda { middleware.call(env) } }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
context 'when the response is gzipped' do
|
21
|
+
before do
|
22
|
+
app.should_receive(:on_complete) { middleware.on_complete(env) }
|
23
|
+
app.should_receive(:call) do
|
24
|
+
env[:body] = gzip fixture('sobject/query_success_response')
|
25
|
+
env[:response_headers]['Content-Encoding'] = 'gzip'
|
26
|
+
app
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'decompresses the body' do
|
31
|
+
expect { subject.call }.to change {
|
32
|
+
env[:body]
|
33
|
+
}.to(fixture('sobject/query_success_response'))
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when :compress is false' do
|
37
|
+
it 'does not set request headers to ask the response to be compressed' do
|
38
|
+
expect { subject.call }.
|
39
|
+
not_to(change { env[:request_headers]['Accept-Encoding'] })
|
40
|
+
end
|
26
41
|
end
|
27
|
-
end
|
28
42
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
43
|
+
context 'when :compress is true' do
|
44
|
+
before do
|
45
|
+
options[:compress] = true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'sets request headers to ask the response to be compressed' do
|
49
|
+
expect { subject.call }.to change {
|
50
|
+
env[:request_headers]['Accept-Encoding']
|
51
|
+
}.to('gzip')
|
52
|
+
end
|
53
|
+
end
|
33
54
|
end
|
34
55
|
|
35
|
-
context 'when
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
56
|
+
context 'when the response claims to be gzipped, but is not' do
|
57
|
+
before do
|
58
|
+
app.should_receive(:on_complete) { middleware.on_complete(env) }
|
59
|
+
app.should_receive(:call) do
|
60
|
+
env[:body] = fixture('sobject/query_success_response')
|
61
|
+
env[:response_headers]['Content-Encoding'] = 'gzip'
|
62
|
+
app
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'does not decompress the body' do
|
67
|
+
expect { subject.call }.to change {
|
68
|
+
env[:body]
|
69
|
+
}.to(fixture('sobject/query_success_response'))
|
70
|
+
end
|
40
71
|
end
|
41
72
|
|
42
|
-
context 'when
|
73
|
+
context 'when the response does not even claim to be gzipped' do
|
43
74
|
before do
|
44
|
-
|
75
|
+
app.should_receive(:on_complete) { middleware.on_complete(env) }
|
76
|
+
app.should_receive(:call) do
|
77
|
+
env[:body] = fixture('sobject/query_success_response')
|
78
|
+
app
|
79
|
+
end
|
45
80
|
end
|
46
81
|
|
47
|
-
it
|
82
|
+
it 'does not decompress the body' do
|
48
83
|
expect { subject.call }.to change {
|
49
|
-
env[:
|
50
|
-
}.to('
|
51
|
-
|
84
|
+
env[:body]
|
85
|
+
}.to(fixture('sobject/query_success_response'))
|
86
|
+
end
|
52
87
|
end
|
53
88
|
end
|
54
89
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.2.
|
4
|
+
version: 6.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Rogers
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
- !ruby/object:Gem::Version
|
294
294
|
version: '0'
|
295
295
|
requirements: []
|
296
|
-
rubygems_version: 3.4.
|
296
|
+
rubygems_version: 3.4.7
|
297
297
|
signing_key:
|
298
298
|
specification_version: 4
|
299
299
|
summary: A lightweight Ruby client for the Salesforce REST API
|