logstash-input-salesforce 3.0.7 → 3.1.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
  SHA256:
3
- metadata.gz: db087ab1accb44460fe213f85afbe02a0be14787b382047fb1b10bdb565ae3d9
4
- data.tar.gz: 1772d480c4978ac547462b4979a23ba994a153031978f7a56a110a3b2a3ccadb
3
+ metadata.gz: 870cd242d68339c41cf0429f54d50a4b7cdf52100bf751605c121ad7d30fec65
4
+ data.tar.gz: abb188afa3f9363a9b75d47bd104c24b6ad7c4f90770881ce4be41769eb61c77
5
5
  SHA512:
6
- metadata.gz: 4d87bf4eaf944c8d01e7d6219e70e41b270ec90868349d345818e5763a6f7b80d7d185b3df728d1a78054f1fc3d9dd83262313147d4b5346e062af3a192fdda2
7
- data.tar.gz: a2b3de959a4132f1e47d2209812c81df4cd104b2d4f7dc6941a1a2fbe28a50a435fbb295c985da00b4455933cd6bd0fc27f92e3f59a401af476b4973ff8ab1a1
6
+ metadata.gz: 01f2f0cc51b2db510684fb19d070ec057888a7e8b4a5026aa95a9d0beff079fa5173fa362e13693be9ed1d1132c659e762710954e2ea4ac4a2385099d7b54fb5
7
+ data.tar.gz: 7936c9f1b66d2db85f7f363c7e0114af9d3adbcacf8aeca6ab74678db769c2f23a4bb313d0fe5bc9fbb3d912b43d11d8aaa8021c96876e59cbe0f80a2dfbe80c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.1.0
2
+ - Added `sfdc_instance_url` configuration to connect to a specific url.
3
+ - Switch to restforce v5+ (for logstash 8.x compatibility)
4
+
1
5
  ## 3.0.7
2
6
  - Added description for `SALESFORCE_PROXY_URI` environment variable.
3
7
 
data/docs/index.asciidoc CHANGED
@@ -81,6 +81,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
81
81
  | <<plugins-{type}s-{plugin}-security_token>> |<<string,string>>|Yes
82
82
  | <<plugins-{type}s-{plugin}-sfdc_fields>> |<<array,array>>|No
83
83
  | <<plugins-{type}s-{plugin}-sfdc_filters>> |<<string,string>>|No
84
+ | <<plugins-{type}s-{plugin}-sfdc_instance_url>> |<<string,string>>|No
84
85
  | <<plugins-{type}s-{plugin}-sfdc_object_name>> |<<string,string>>|Yes
85
86
  | <<plugins-{type}s-{plugin}-to_underscores>> |<<boolean,boolean>>|No
86
87
  | <<plugins-{type}s-{plugin}-use_test_sandbox>> |<<boolean,boolean>>|No
@@ -161,6 +162,19 @@ These options will be added to the WHERE clause in the
161
162
  SOQL statement. Additional fields can be filtered on by
162
163
  adding field1 = value1 AND field2 = value2 AND...
163
164
 
165
+ [id="plugins-{type}s-{plugin}-sfdc_instance_url"]
166
+ ===== `sfdc_instance_url`
167
+
168
+ * Value type is <<string,string>>
169
+ * There is no default value for this setting.
170
+
171
+ The url of a Salesforce instance. Provide the url if you want to connect
172
+ to your Salesforce instance instead of
173
+ `login.salesforce.com` or `test.salesforce.com` at login.
174
+
175
+ Use either this or the `use_test_sandbox` configuration option
176
+ but not both to configure the url to which the plugin connects to.
177
+
164
178
  [id="plugins-{type}s-{plugin}-sfdc_object_name"]
165
179
  ===== `sfdc_object_name`
166
180
 
@@ -187,6 +201,10 @@ Setting this to true will convert SFDC's NamedFields__c to named_fields__c
187
201
  Set this to true to connect to a sandbox sfdc instance
188
202
  logging in through test.salesforce.com
189
203
 
204
+ Use either this or the `sfdc_instance_url` configuration option
205
+ but not both to configure the url to which the plugin connects to.
206
+
207
+
190
208
  [id="plugins-{type}s-{plugin}-username"]
191
209
  ===== `username`
192
210
 
@@ -52,6 +52,11 @@ class LogStash::Inputs::Salesforce < LogStash::Inputs::Base
52
52
  # Set this to true to connect to a sandbox sfdc instance
53
53
  # logging in through test.salesforce.com
54
54
  config :use_test_sandbox, :validate => :boolean, :default => false
55
+ # Set this to the instance url of the sfdc instance you want
56
+ # to connect to already during login. If you have configured
57
+ # a MyDomain in your sfdc instance you would provide
58
+ # <mydomain>.my.salesforce.com here.
59
+ config :sfdc_instance_url, :validate => :string, :required => false
55
60
  # By default, this uses the default Restforce API version.
56
61
  # To override this, set this to something like "32.0" for example
57
62
  config :api_version, :validate => :string, :required => false
@@ -131,7 +136,14 @@ class LogStash::Inputs::Salesforce < LogStash::Inputs::Base
131
136
  :client_id => @client_id,
132
137
  :client_secret => @client_secret
133
138
  }
134
- options.merge!({ :host => "test.salesforce.com" }) if @use_test_sandbox
139
+ # configure the endpoint to which restforce connects to for authentication
140
+ if @sfdc_instance_url && @use_test_sandbox
141
+ raise ::LogStash::ConfigurationError.new("Both \"use_test_sandbox\" and \"sfdc_instance_url\" can't be set simultaneously. Please specify either \"use_test_sandbox\" or \"sfdc_instance_url\"")
142
+ elsif @sfdc_instance_url
143
+ options.merge!({ :host => @sfdc_instance_url })
144
+ elsif @use_test_sandbox
145
+ options.merge!({ :host => "test.salesforce.com" })
146
+ end
135
147
  options.merge!({ :api_version => @api_version }) if @api_version
136
148
  return options
137
149
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-salesforce'
3
- s.version = '3.0.7'
3
+ s.version = '3.1.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Creates events based on a Salesforce SOQL query"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
19
19
 
20
20
  # Gem dependencies
21
21
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
22
- s.add_runtime_dependency 'logstash-codec-plain'
23
- s.add_runtime_dependency 'restforce', '>= 3.2', '< 5'
22
+ s.add_runtime_dependency "logstash-codec-plain"
23
+ s.add_runtime_dependency "restforce", ">= 5", "< 5.2"
24
24
  s.add_development_dependency 'logstash-devutils'
25
25
  s.add_development_dependency 'vcr'
26
26
  s.add_development_dependency 'webmock'
27
27
  s.add_development_dependency 'json'
28
- s.add_development_dependency 'public_suffix', '~> 1.4.6' # required due to ruby < 2.0
28
+ s.add_development_dependency 'public_suffix', '>= 1.4' # required due to ruby < 2.0
29
29
  end
@@ -0,0 +1,87 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://my-domain.my.salesforce.com/services/oauth2/token
6
+ body:
7
+ encoding: US-ASCII
8
+ string: grant_type=password&client_id=xxxx&client_secret=xxxx&username=xxxx&password=xxxx
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Thu, 27 Aug 2015 21:31:28 GMT
23
+ Set-Cookie:
24
+ - BrowserId=xxxx;Path=/;Domain=.salesforce.com;Expires=Mon, 26-Oct-2015 21:31:28 GMT
25
+ Expires:
26
+ - Thu, 01 Jan 1970 00:00:00 GMT
27
+ Pragma:
28
+ - no-cache
29
+ Cache-Control:
30
+ - no-cache, no-store
31
+ Content-Type:
32
+ - application/json;charset=UTF-8
33
+ Transfer-Encoding:
34
+ - chunked
35
+ body:
36
+ encoding: US-ASCII
37
+ string: '{"id":"https://login.salesforce.com/id/xxxx/xxxx","issued_at":"1440711088469","token_type":"Bearer","instance_url":"https://my-domain.my.salesforce.com","signature":"xxxx","access_token":"xxxx"}'
38
+ http_version:
39
+ recorded_at: Thu, 27 Aug 2015 21:31:28 GMT
40
+ - request:
41
+ method: get
42
+ uri: https://my-domain.my.salesforce.com/services/data/v26.0/sobjects/Lead/describe
43
+ body:
44
+ encoding: US-ASCII
45
+ string: ''
46
+ headers:
47
+ User-Agent:
48
+ - Faraday v0.9.1
49
+ Authorization:
50
+ - OAuth xxxx
51
+ Accept-Encoding:
52
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
53
+ Accept:
54
+ - '*/*'
55
+ response:
56
+ status:
57
+ code: 200
58
+ message: OK
59
+ headers:
60
+ Date:
61
+ - Thu, 27 Aug 2015 21:31:29 GMT
62
+ Set-Cookie:
63
+ - BrowserId=xxxx;Path=/;Domain=.salesforce.com;Expires=Mon, 26-Oct-2015 21:31:29 GMT
64
+ Expires:
65
+ - Thu, 01 Jan 1970 00:00:00 GMT
66
+ Sforce-Limit-Info:
67
+ - api-usage=204568/451000
68
+ Org.eclipse.jetty.server.include.etag:
69
+ - f3049665
70
+ Last-Modified:
71
+ - Thu, 27 Aug 2015 18:14:47 GMT
72
+ Content-Type:
73
+ - application/json;charset=UTF-8
74
+ Etag:
75
+ - f304966-gzip"
76
+ Transfer-Encoding:
77
+ - chunked
78
+ body:
79
+ encoding: UTF-8
80
+ string: '{"activateable":false,"childRelationships":[],"createable":true,"custom":false,"customSetting":false,"deletable":true,"deprecatedAndHidden":false,"feedEnabled":true,"fields":[{"autoNumber":false,"byteLength":18,"calculated":false,"calculatedFormula":null,"cascadeDelete":false,"caseSensitive":false,"controllerName":null,"createable":false,"custom":false,"defaultValue":null,"defaultValueFormula":null,"defaultedOnCreate":true,"dependentPicklist":false,"deprecatedAndHidden":false,"digits":0,"displayLocationInDecimal":false,"externalId":false,"filterable":true,"groupable":true,"htmlFormatted":false,"idLookup":true,"inlineHelpText":null,"label":"Lead
81
+ ID","length":18,"name":"Id","nameField":false,"namePointing":false,"nillable":false,"permissionable":false,"picklistValues":[],"precision":0,"referenceTo":[],"relationshipName":null,"relationshipOrder":null,"restrictedDelete":false,"restrictedPicklist":false,"scale":0,"soapType":"tns:ID","sortable":true,"type":"id","unique":false,"updateable":false,"writeRequiresMasterRead":false},{"autoNumber":false,"byteLength":0,"calculated":false,"calculatedFormula":null,"cascadeDelete":false,"caseSensitive":false,"controllerName":null,"createable":false,"custom":false,"defaultValue":null,"defaultValueFormula":null,"defaultedOnCreate":true,"dependentPicklist":false,"deprecatedAndHidden":false,"digits":0,"displayLocationInDecimal":false,"externalId":false,"filterable":true,"groupable":true,"htmlFormatted":false,"idLookup":false,"inlineHelpText":null,"label":"Deleted","length":0,"name":"IsDeleted","nameField":false,"namePointing":false,"nillable":false,"permissionable":false,"picklistValues":[],"precision":0,"referenceTo":[],"relationshipName":null,"relationshipOrder":null,"restrictedDelete":false,"restrictedPicklist":false,"scale":0,"soapType":"xsd:boolean","sortable":true,"type":"boolean","unique":false,"updateable":false,"writeRequiresMasterRead":false},{"autoNumber":false,"byteLength":240,"calculated":false,"calculatedFormula":null,"cascadeDelete":false,"caseSensitive":false,"controllerName":null,"createable":true,"custom":false,"defaultValue":null,"defaultValueFormula":null,"defaultedOnCreate":false,"dependentPicklist":false,"deprecatedAndHidden":false,"digits":0,"displayLocationInDecimal":false,"externalId":false,"filterable":true,"groupable":true,"htmlFormatted":false,"idLookup":false,"inlineHelpText":null,"label":"Last
82
+ Name","length":80,"name":"LastName","nameField":false,"namePointing":false,"nillable":false,"permissionable":false,"picklistValues":[],"precision":0,"referenceTo":[],"relationshipName":null,"relationshipOrder":null,"restrictedDelete":false,"restrictedPicklist":false,"scale":0,"soapType":"xsd:string","sortable":true,"type":"string","unique":false,"updateable":true,"writeRequiresMasterRead":false},{"autoNumber":false,"byteLength":120,"calculated":false,"calculatedFormula":null,"cascadeDelete":false,"caseSensitive":false,"controllerName":null,"createable":true,"custom":false,"defaultValue":null,"defaultValueFormula":null,"defaultedOnCreate":false,"dependentPicklist":false,"deprecatedAndHidden":false,"digits":0,"displayLocationInDecimal":false,"externalId":false,"filterable":true,"groupable":true,"htmlFormatted":false,"idLookup":false,"inlineHelpText":null,"label":"First
83
+ Name","length":40,"name":"FirstName","nameField":false,"namePointing":false,"nillable":true,"permissionable":false,"picklistValues":[],"precision":0,"referenceTo":[],"relationshipName":null,"relationshipOrder":null,"restrictedDelete":false,"restrictedPicklist":false,"scale":0,"soapType":"xsd:string","sortable":true,"type":"string","unique":false,"updateable":true,"writeRequiresMasterRead":false},{"autoNumber":false,"byteLength":120,"calculated":false,"calculatedFormula":null,"cascadeDelete":false,"caseSensitive":false,"controllerName":null,"createable":true,"custom":false,"defaultValue":null,"defaultValueFormula":null,"defaultedOnCreate":false,"dependentPicklist":false,"deprecatedAndHidden":false,"digits":0,"displayLocationInDecimal":false,"externalId":false,"filterable":true,"groupable":true,"htmlFormatted":false,"idLookup":false,"inlineHelpText":null,"label":"Salutation","length":40,"name":"Salutation","nameField":false,"namePointing":false,"nillable":true,"permissionable":false,"picklistValues":[{"active":true,"defaultValue":false,"label":"Mr.","validFor":null,"value":"Mr."},{"active":true,"defaultValue":false,"label":"Ms.","validFor":null,"value":"Ms."},{"active":true,"defaultValue":false,"label":"Mrs.","validFor":null,"value":"Mrs."},{"active":true,"defaultValue":false,"label":"Dr.","validFor":null,"value":"Dr."},{"active":true,"defaultValue":false,"label":"Prof.","validFor":null,"value":"Prof."}],"precision":0,"referenceTo":[],"relationshipName":null,"relationshipOrder":null,"restrictedDelete":false,"restrictedPicklist":false,"scale":0,"soapType":"xsd:string","sortable":true,"type":"picklist","unique":false,"updateable":true,"writeRequiresMasterRead":false}],"keyPrefix":"00Q","label":"Lead","labelPlural":"Leads","layoutable":true,"listviewable":null,"lookupLayoutable":null,"mergeable":true,"name":"Lead","queryable":true,"recordTypeInfos":[{"available":true,"defaultRecordTypeMapping":true,"name":"Marketing","recordTypeId":"xxxx"},{"available":true,"defaultRecordTypeMapping":false,"name":"Partner
84
+ Deal","recordTypeId":"xxxx"},{"available":true,"defaultRecordTypeMapping":false,"name":"Sales","recordTypeId":"xxxx"},{"available":true,"defaultRecordTypeMapping":false,"name":"Master","recordTypeId":"xxxx"}],"replicateable":true,"retrieveable":true,"searchLayoutable":null,"searchable":true,"triggerable":true,"undeletable":true,"updateable":true,"urls":{"uiEditTemplate":"https://xxx.salesforce.com/{ID}/e","sobject":"/services/data/v26.0/sobjects/Lead","uiDetailTemplate":"https://xxx.salesforce.com/{ID}","describe":"/services/data/v26.0/sobjects/Lead/describe","rowTemplate":"/services/data/v26.0/sobjects/Lead/{ID}","uiNewRecord":"https://xxx.salesforce.com/00Q/e"}}'
85
+ http_version:
86
+ recorded_at: Thu, 27 Aug 2015 21:31:30 GMT
87
+ recorded_with: VCR 2.9.3
@@ -119,5 +119,67 @@ RSpec.describe LogStash::Inputs::Salesforce do
119
119
  end
120
120
  end
121
121
  end
122
+
123
+ context "use sfdc instance url" do
124
+ VCR.configure do |config|
125
+ config.cassette_library_dir = File.join(File.dirname(__FILE__), '..', 'fixtures', 'vcr_cassettes')
126
+ config.hook_into :webmock
127
+ config.before_record do |i|
128
+ if i.response.body.encoding.to_s == 'ASCII-8BIT'
129
+ # required because sfdc doesn't send back the content encoding and it
130
+ # confuses the yaml parser
131
+ json_body = JSON.load(i.response.body.encode("ASCII-8BIT").force_encoding("utf-8"))
132
+ i.response.body = json_body.to_json
133
+ i.response.update_content_length_header
134
+ end
135
+ end
136
+ end
137
+ let(:options) do
138
+ {
139
+ "client_id" => "",
140
+ "client_secret" => "",
141
+ "username" => "",
142
+ "password" => "",
143
+ "security_token" => "",
144
+ "sfdc_instance_url" => "my-domain.my.salesforce.com",
145
+ "sfdc_object_name" => "Lead"
146
+ }
147
+ end
148
+ let (:input) { LogStash::Inputs::Salesforce.new(options) }
149
+ let(:expected_fields_result) { ["Id", "IsDeleted",
150
+ "LastName", "FirstName", "Salutation"] }
151
+ let(:expected_types_result) { [["FirstName", "string"],
152
+ ["Id", "id"],
153
+ ["IsDeleted", "boolean"],
154
+ ["LastName", "string"],
155
+ ["Salutation", "picklist"]] }
156
+ subject { input }
157
+ it "logs into sfdc instance url" do
158
+ VCR.use_cassette("login_into_mydomain", :decode_compressed_response => true) do
159
+ subject.register
160
+ expect(subject.instance_variable_get(:@sfdc_field_types)).to match_array(expected_types_result)
161
+ expect(subject.instance_variable_get(:@sfdc_fields)).to match_array(expected_fields_result)
162
+ end
163
+ end
164
+ context "...but not use_test_sandbox" do
165
+ let(:options) do
166
+ {
167
+ "client_id" => "",
168
+ "client_secret" => "",
169
+ "username" => "",
170
+ "password" => "",
171
+ "security_token" => "",
172
+ "sfdc_instance_url" => "my-domain.my.salesforce.com",
173
+ "sfdc_object_name" => "Lead",
174
+ "use_test_sandbox" => true
175
+ }
176
+ end
177
+ let (:input) { LogStash::Inputs::Salesforce.new(options) }
178
+ subject { input }
179
+ it "should raise a LogStash::ConfigurationError" do
180
+ expect { subject.register }.to raise_error(::LogStash::ConfigurationError)
181
+ end
182
+ end
183
+ end
122
184
  end
123
185
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russ Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-04 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -49,10 +49,10 @@ dependencies:
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '3.2'
52
+ version: '5'
53
53
  - - "<"
54
54
  - !ruby/object:Gem::Version
55
- version: '5'
55
+ version: '5.2'
56
56
  name: restforce
57
57
  prerelease: false
58
58
  type: :runtime
@@ -60,10 +60,10 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: '3.2'
63
+ version: '5'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '5'
66
+ version: '5.2'
67
67
  - !ruby/object:Gem::Dependency
68
68
  requirement: !ruby/object:Gem::Requirement
69
69
  requirements:
@@ -123,17 +123,17 @@ dependencies:
123
123
  - !ruby/object:Gem::Dependency
124
124
  requirement: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - "~>"
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: 1.4.6
128
+ version: '1.4'
129
129
  name: public_suffix
130
130
  prerelease: false
131
131
  type: :development
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - "~>"
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
- version: 1.4.6
136
+ version: '1.4'
137
137
  description: This gem is a Logstash plugin required to be installed on top of the
138
138
  Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
139
139
  gem is not a stand-alone program
@@ -153,6 +153,7 @@ files:
153
153
  - logstash-input-salesforce.gemspec
154
154
  - spec/fixtures/vcr_cassettes/describe_lead_object.yml
155
155
  - spec/fixtures/vcr_cassettes/load_some_lead_objects.yml
156
+ - spec/fixtures/vcr_cassettes/login_into_mydomain.yml
156
157
  - spec/inputs/salesforce_spec.rb
157
158
  - spec/spec_helper.rb
158
159
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
@@ -176,13 +177,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
177
  - !ruby/object:Gem::Version
177
178
  version: '0'
178
179
  requirements: []
179
- rubyforge_project:
180
- rubygems_version: 2.6.13
180
+ rubygems_version: 3.1.6
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Creates events based on a Salesforce SOQL query
184
184
  test_files:
185
185
  - spec/fixtures/vcr_cassettes/describe_lead_object.yml
186
186
  - spec/fixtures/vcr_cassettes/load_some_lead_objects.yml
187
+ - spec/fixtures/vcr_cassettes/login_into_mydomain.yml
187
188
  - spec/inputs/salesforce_spec.rb
188
189
  - spec/spec_helper.rb