logstash-filter-rest2 0.5.4 → 0.5.5

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: 6cf9a1e09c6941b2d214fac84bb54bc91d452e7dcef9f6fc2212e815c899f172
4
- data.tar.gz: 8c77009ef3b15913d31e8044d7fde34825134bec97b1049887bb75ddfdbc28c6
3
+ metadata.gz: 73bc32f0f3dfe3e5d5595e824370ab60504c4e05fedeeddc95bbf22116f98d99
4
+ data.tar.gz: 753676d528768372a1caa807862e809d653ef04264eea27692b6c10425725324
5
5
  SHA512:
6
- metadata.gz: 1a4800859bc3398ae0d823b2afcb4121cf67e4ea6a605812ee4a3d19c57f6c3a84ba2a7f8eefcce65332da60cb3c725a91fcd832f901588822c4d1b36a713394
7
- data.tar.gz: 7d97464408fcb3b3152c0d9e14cf5f69295a7b76c0b08df9a2682bf844f8d7706fd71039c47d7ce0a9d4b12ba5585dc34664737afa21b384bba4a9764bc27892
6
+ metadata.gz: ade33bab3d69e1973e9136fa1bdceefc6cff78a019df97520a0fa05eaec25e6b3841f4cb04dd941cacce11d60dc031c1e00e1c8db5c90dfbf8596890335ceb8d
7
+ data.tar.gz: 51eb265f4a9d35bcd0238b386bb38cb04aa814914eaaba85183d48ec1a3cee13bae57d899efb0968e1b35eeb08a19672bb361c4c69a9e441a46dce62e52d1c0d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.4
2
+
3
+ - update `gemspec` to work with logstash 5.5
4
+
1
5
  ## 0.5.3
2
6
  - freeze all instance variables
3
7
  - fix parallel processing by creating a `deep_clone` for each event
@@ -128,6 +128,16 @@ class LogStash::Filters::Rest < LogStash::Filters::Base
128
128
  config :tag_on_rest_failure, :validate => :array, :default => ['_restfailure']
129
129
  config :tag_on_json_failure, :validate => :array, :default => ['_jsonparsefailure']
130
130
 
131
+ # If you need to use a custom truststore (`.jks`) specify that here. This does not work with .pem certs!
132
+ config :truststore, :validate => :path
133
+
134
+ # Specify the truststore password here.
135
+ # Note, most .jks files created with keytool require a password!
136
+ config :truststore_password, :validate => :password
137
+
138
+ # Specify the truststore type here. One of `JKS` or `PKCS12`. Default is `JKS`
139
+ config :truststore_type, :validate => :string, :default => "JKS"
140
+
131
141
  public
132
142
 
133
143
  def register
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-rest2'
3
- s.version = '0.5.4'
3
+ s.version = '0.5.5'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'This filter requests data from a RESTful Web Service.'
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 logstash-filter-rest2. This gem is not a stand-alone program'
@@ -7,8 +7,12 @@ describe LogStash::Filters::Rest do
7
7
  filter {
8
8
  rest {
9
9
  request => {
10
- url => 'http://jsonplaceholder.typicode.com/users/10'
10
+ url => 'https://sbt-otib.sigma.sbrf.ru/otib/rest/application/12'
11
+ truststore => "/var/app/ca2.jks"
12
+ truststore_password => "password"
11
13
  }
14
+ # truststore => "/var/app/ca2.jks"
15
+ # truststore_password => "password1"
12
16
  json => true
13
17
  target => 'rest'
14
18
  }
@@ -23,384 +27,405 @@ describe LogStash::Filters::Rest do
23
27
  expect(subject.get('rest')).to_not include('fallback')
24
28
  end
25
29
  end
26
- describe 'Set to Rest Filter Get without params custom target' do
27
- let(:config) do <<-CONFIG
28
- filter {
29
- rest {
30
- request => {
31
- url => 'http://jsonplaceholder.typicode.com/users/10'
32
- }
33
- json => true
34
- target => 'testing'
35
- }
36
- }
37
- CONFIG
38
- end
39
-
40
- sample('message' => 'some text') do
41
- expect(subject).to include('testing')
42
- expect(subject.get('testing')).to include('id')
43
- expect(subject.get('[testing][id]')).to eq(10)
44
- expect(subject.get('testing')).to_not include('fallback')
45
- end
46
- end
47
- describe 'Set to Rest Filter Get without params and sprintf' do
48
- let(:config) do <<-CONFIG
49
- filter {
50
- rest {
51
- request => {
52
- url => "http://jsonplaceholder.typicode.com/users/%{message}"
53
- }
54
- json => true
55
- sprintf => true
56
- target => 'rest'
57
- }
58
- }
59
- CONFIG
60
- end
61
-
62
- sample('message' => '10') do
63
- expect(subject).to include('rest')
64
- expect(subject.get('rest')).to include('id')
65
- expect(subject.get('[rest][id]')).to eq(10)
66
- expect(subject.get('rest')).to_not include('fallback')
67
- end
68
- sample('message' => '9') do
69
- expect(subject).to include('rest')
70
- expect(subject.get('rest')).to include('id')
71
- expect(subject.get('[rest][id]')).to eq(9)
72
- expect(subject.get('rest')).to_not include('fallback')
73
- end
74
- end
75
- describe 'Set to Rest Filter Get without params http error' do
76
- let(:config) do <<-CONFIG
77
- filter {
78
- rest {
79
- request => {
80
- url => 'http://httpstat.us/404'
81
- }
82
- json => true
83
- target => 'rest'
84
- }
85
- }
86
- CONFIG
87
- end
88
-
89
- sample('message' => 'some text') do
90
- expect(subject).to_not include('rest')
91
- expect(subject.get('tags')).to include('_restfailure')
92
- end
93
- end
94
- describe 'Set to Rest Filter Get with params' do
95
- let(:config) do <<-CONFIG
96
- filter {
97
- rest {
98
- request => {
99
- url => 'https://jsonplaceholder.typicode.com/posts'
100
- params => {
101
- userId => 10
102
- }
103
- headers => {
104
- 'Content-Type' => 'application/json'
105
- }
106
- }
107
- json => true
108
- target => 'rest'
109
- }
110
- }
111
- CONFIG
112
- end
113
-
114
- sample('message' => 'some text') do
115
- expect(subject).to include('rest')
116
- expect(subject.get('[rest][0]')).to include('userId')
117
- expect(subject.get('[rest][0][userId]')).to eq(10)
118
- expect(subject.get('rest')).to_not include('fallback')
119
- end
120
- end
121
- describe 'empty response' do
122
- let(:config) do <<-CONFIG
123
- filter {
124
- rest {
125
- request => {
126
- url => 'https://jsonplaceholder.typicode.com/posts'
127
- params => {
128
- userId => 0
129
- }
130
- headers => {
131
- 'Content-Type' => 'application/json'
132
- }
133
- }
134
- target => 'rest'
135
- }
136
- }
137
- CONFIG
138
- end
139
-
140
- sample('message' => 'some text') do
141
- expect(subject).to_not include('rest')
142
- expect(subject.get('tags')).to include('_restfailure')
143
- end
144
- end
145
- describe 'Set to Rest Filter Get with params sprintf' do
146
- let(:config) do <<-CONFIG
147
- filter {
148
- rest {
149
- request => {
150
- url => 'https://jsonplaceholder.typicode.com/posts'
151
- params => {
152
- userId => "%{message}"
153
- id => "%{message}"
154
- }
155
- headers => {
156
- 'Content-Type' => 'application/json'
157
- }
158
- }
159
- json => true
160
- target => 'rest'
161
- }
162
- }
163
- CONFIG
164
- end
165
-
166
- sample('message' => '1') do
167
- expect(subject).to include('rest')
168
- expect(subject.get('[rest][0]')).to include('userId')
169
- expect(subject.get('[rest][0][userId]')).to eq(1)
170
- expect(subject.get('[rest][0][id]')).to eq(1)
171
- expect(subject.get('rest').length).to eq(1)
172
- expect(subject.get('rest')).to_not include('fallback')
173
- end
174
- end
175
- describe 'Set to Rest Filter Post with params' do
176
- let(:config) do <<-CONFIG
177
- filter {
178
- rest {
179
- request => {
180
- url => 'https://jsonplaceholder.typicode.com/posts'
181
- method => 'post'
182
- params => {
183
- title => 'foo'
184
- body => 'bar'
185
- userId => 42
186
- }
187
- headers => {
188
- 'Content-Type' => 'application/json'
189
- }
190
- }
191
- json => true
192
- target => 'rest'
193
- }
194
- }
195
- CONFIG
196
- end
197
-
198
- sample('message' => 'some text') do
199
- expect(subject).to include('rest')
200
- expect(subject.get('rest')).to include('id')
201
- expect(subject.get('[rest][userId]')).to eq(42)
202
- expect(subject.get('rest')).to_not include('fallback')
203
- end
204
- end
205
- describe 'Set to Rest Filter Post with params sprintf' do
206
- let(:config) do <<-CONFIG
207
- filter {
208
- rest {
209
- request => {
210
- url => 'https://jsonplaceholder.typicode.com/posts'
211
- method => 'post'
212
- params => {
213
- title => '%{message}'
214
- body => 'bar'
215
- userId => "%{message}"
216
- }
217
- headers => {
218
- 'Content-Type' => 'application/json'
219
- }
220
- }
221
- json => true
222
- target => 'rest'
223
- }
224
- }
225
- CONFIG
226
- end
227
-
228
- sample('message' => '42') do
229
- expect(subject).to include('rest')
230
- expect(subject.get('rest')).to include('id')
231
- expect(subject.get('[rest][title]')).to eq(42)
232
- expect(subject.get('[rest][userId]')).to eq(42)
233
- expect(subject.get('rest')).to_not include('fallback')
234
- end
235
- sample('message' => ':5e?#!-_') do
236
- expect(subject).to include('rest')
237
- expect(subject.get('rest')).to include('id')
238
- expect(subject.get('[rest][title]')).to eq(':5e?#!-_')
239
- expect(subject.get('[rest][userId]')).to eq(':5e?#!-_')
240
- expect(subject.get('rest')).to_not include('fallback')
241
- end
242
- sample('message' => ':4c43=>') do
243
- expect(subject).to include('rest')
244
- expect(subject.get('rest')).to include('id')
245
- expect(subject.get('[rest][title]')).to eq(':4c43=>')
246
- expect(subject.get('[rest][userId]')).to eq(':4c43=>')
247
- expect(subject.get('rest')).to_not include('fallback')
248
- end
249
- end
250
- describe 'Set to Rest Filter Post with body sprintf' do
251
- let(:config) do <<-CONFIG
252
- filter {
253
- rest {
254
- request => {
255
- url => 'https://jsonplaceholder.typicode.com/posts'
256
- method => 'post'
257
- body => {
258
- title => 'foo'
259
- body => 'bar'
260
- userId => "%{message}"
261
- }
262
- headers => {
263
- 'Content-Type' => 'application/json'
264
- }
265
- }
266
- json => true
267
- target => 'rest'
268
- }
269
- }
270
- CONFIG
271
- end
272
-
273
- sample('message' => '42') do
274
- expect(subject).to include('rest')
275
- expect(subject.get('rest')).to include('id')
276
- expect(subject.get('[rest][userId]')).to eq(42)
277
- expect(subject.get('rest')).to_not include('fallback')
278
- end
279
- end
280
- describe 'Set to Rest Filter Post with body sprintf nested params' do
281
- let(:config) do <<-CONFIG
282
- filter {
283
- rest {
284
- request => {
285
- url => 'https://jsonplaceholder.typicode.com/posts'
286
- method => 'post'
287
- body => {
288
- key1 => [
289
- {
290
- "filterType" => "text"
291
- "text" => "salmon"
292
- "boolean" => false
293
- },
294
- {
295
- "filterType" => "unique"
296
- }
297
- ]
298
- key2 => [
299
- {
300
- "message" => "123%{message}"
301
- "boolean" => true
302
- }
303
- ]
304
- key3 => [
305
- {
306
- "text" => "%{message}123"
307
- "filterType" => "text"
308
- "number" => 44
309
- },
310
- {
311
- "filterType" => "unique"
312
- "null" => nil
313
- }
314
- ]
315
- userId => "%{message}"
316
- }
317
- headers => {
318
- 'Content-Type' => 'application/json'
319
- }
320
- }
321
- target => 'rest'
322
- }
323
- }
324
- CONFIG
325
- end
326
-
327
- sample('message' => '42') do
328
- expect(subject).to include('rest')
329
- expect(subject.get('rest')).to include('key1')
330
- expect(subject.get('[rest][key1][0][boolean]')).to eq('false')
331
- expect(subject.get('[rest][key1][1][filterType]')).to eq('unique')
332
- expect(subject.get('[rest][key2][0][message]')).to eq('12342')
333
- expect(subject.get('[rest][key2][0][boolean]')).to eq('true')
334
- expect(subject.get('[rest][key3][0][text]')).to eq('42123')
335
- expect(subject.get('[rest][key3][0][filterType]')).to eq('text')
336
- expect(subject.get('[rest][key3][0][number]')).to eq(44)
337
- expect(subject.get('[rest][key3][1][filterType]')).to eq('unique')
338
- expect(subject.get('[rest][key3][1][null]')).to eq('nil')
339
- expect(subject.get('[rest][userId]')).to eq(42)
340
- expect(subject.get('rest')).to_not include('fallback')
341
- end
342
- end
343
- describe 'fallback' do
344
- let(:config) do <<-CONFIG
345
- filter {
346
- rest {
347
- request => {
348
- url => 'http://jsonplaceholder.typicode.com/users/0'
349
- }
350
- json => true
351
- fallback => {
352
- 'fallback1' => true
353
- 'fallback2' => true
354
- }
355
- target => 'rest'
356
- }
357
- }
358
- CONFIG
359
- end
360
-
361
- sample('message' => 'some text') do
362
- expect(subject).to include('rest')
363
- expect(subject.get('rest')).to include('fallback1')
364
- expect(subject.get('rest')).to include('fallback2')
365
- expect(subject.get('rest')).to_not include('id')
366
- end
367
- end
368
- describe 'empty target exception' do
369
- let(:config) do <<-CONFIG
370
- filter {
371
- rest {
372
- request => {
373
- url => 'http://jsonplaceholder.typicode.com/users/0'
374
- }
375
- json => true
376
- fallback => {
377
- 'fallback1' => true
378
- 'fallback2' => true
379
- }
380
- target => ''
381
- }
382
- }
383
- CONFIG
384
- end
385
- sample('message' => 'some text') do
386
- expect { subject }.to raise_error(LogStash::ConfigurationError)
387
- end
388
- end
389
- describe 'http client throws exception' do
390
- let(:config) do <<-CONFIG
391
- filter {
392
- rest {
393
- request => {
394
- url => 'invalid_url'
395
- }
396
- target => 'rest'
397
- }
398
- }
399
- CONFIG
400
- end
401
- sample('message' => 'some text') do
402
- expect(subject).to_not include('rest')
403
- expect(subject.get('tags')).to include('_restfailure')
404
- end
405
- end
30
+ # describe 'Set to Rest Filter Get without params' do
31
+ # let(:config) do <<-CONFIG
32
+ # filter {
33
+ # rest {
34
+ # request => {
35
+ # url => 'http://jsonplaceholder.typicode.com/users/10'
36
+ # }
37
+ # json => true
38
+ # target => 'rest'
39
+ # }
40
+ # }
41
+ # CONFIG
42
+ # end
43
+ #
44
+ # sample('message' => 'some text') do
45
+ # expect(subject).to include('rest')
46
+ # expect(subject.get('rest')).to include('id')
47
+ # expect(subject.get('[rest][id]')).to eq(10)
48
+ # expect(subject.get('rest')).to_not include('fallback')
49
+ # end
50
+ # end
51
+ # describe 'Set to Rest Filter Get without params custom target' do
52
+ # let(:config) do <<-CONFIG
53
+ # filter {
54
+ # rest {
55
+ # request => {
56
+ # url => 'http://jsonplaceholder.typicode.com/users/10'
57
+ # }
58
+ # json => true
59
+ # target => 'testing'
60
+ # }
61
+ # }
62
+ # CONFIG
63
+ # end
64
+ #
65
+ # sample('message' => 'some text') do
66
+ # expect(subject).to include('testing')
67
+ # expect(subject.get('testing')).to include('id')
68
+ # expect(subject.get('[testing][id]')).to eq(10)
69
+ # expect(subject.get('testing')).to_not include('fallback')
70
+ # end
71
+ # end
72
+ # describe 'Set to Rest Filter Get without params and sprintf' do
73
+ # let(:config) do <<-CONFIG
74
+ # filter {
75
+ # rest {
76
+ # request => {
77
+ # url => "http://jsonplaceholder.typicode.com/users/%{message}"
78
+ # }
79
+ # json => true
80
+ # sprintf => true
81
+ # target => 'rest'
82
+ # }
83
+ # }
84
+ # CONFIG
85
+ # end
86
+ #
87
+ # sample('message' => '10') do
88
+ # expect(subject).to include('rest')
89
+ # expect(subject.get('rest')).to include('id')
90
+ # expect(subject.get('[rest][id]')).to eq(10)
91
+ # expect(subject.get('rest')).to_not include('fallback')
92
+ # end
93
+ # sample('message' => '9') do
94
+ # expect(subject).to include('rest')
95
+ # expect(subject.get('rest')).to include('id')
96
+ # expect(subject.get('[rest][id]')).to eq(9)
97
+ # expect(subject.get('rest')).to_not include('fallback')
98
+ # end
99
+ # end
100
+ # describe 'Set to Rest Filter Get without params http error' do
101
+ # let(:config) do <<-CONFIG
102
+ # filter {
103
+ # rest {
104
+ # request => {
105
+ # url => 'http://httpstat.us/404'
106
+ # }
107
+ # json => true
108
+ # target => 'rest'
109
+ # }
110
+ # }
111
+ # CONFIG
112
+ # end
113
+ #
114
+ # sample('message' => 'some text') do
115
+ # expect(subject).to_not include('rest')
116
+ # expect(subject.get('tags')).to include('_restfailure')
117
+ # end
118
+ # end
119
+ # describe 'Set to Rest Filter Get with params' do
120
+ # let(:config) do <<-CONFIG
121
+ # filter {
122
+ # rest {
123
+ # request => {
124
+ # url => 'https://jsonplaceholder.typicode.com/posts'
125
+ # params => {
126
+ # userId => 10
127
+ # }
128
+ # headers => {
129
+ # 'Content-Type' => 'application/json'
130
+ # }
131
+ # }
132
+ # json => true
133
+ # target => 'rest'
134
+ # }
135
+ # }
136
+ # CONFIG
137
+ # end
138
+ #
139
+ # sample('message' => 'some text') do
140
+ # expect(subject).to include('rest')
141
+ # expect(subject.get('[rest][0]')).to include('userId')
142
+ # expect(subject.get('[rest][0][userId]')).to eq(10)
143
+ # expect(subject.get('rest')).to_not include('fallback')
144
+ # end
145
+ # end
146
+ # describe 'empty response' do
147
+ # let(:config) do <<-CONFIG
148
+ # filter {
149
+ # rest {
150
+ # request => {
151
+ # url => 'https://jsonplaceholder.typicode.com/posts'
152
+ # params => {
153
+ # userId => 0
154
+ # }
155
+ # headers => {
156
+ # 'Content-Type' => 'application/json'
157
+ # }
158
+ # }
159
+ # target => 'rest'
160
+ # }
161
+ # }
162
+ # CONFIG
163
+ # end
164
+ #
165
+ # sample('message' => 'some text') do
166
+ # expect(subject).to_not include('rest')
167
+ # expect(subject.get('tags')).to include('_restfailure')
168
+ # end
169
+ # end
170
+ # describe 'Set to Rest Filter Get with params sprintf' do
171
+ # let(:config) do <<-CONFIG
172
+ # filter {
173
+ # rest {
174
+ # request => {
175
+ # url => 'https://jsonplaceholder.typicode.com/posts'
176
+ # params => {
177
+ # userId => "%{message}"
178
+ # id => "%{message}"
179
+ # }
180
+ # headers => {
181
+ # 'Content-Type' => 'application/json'
182
+ # }
183
+ # }
184
+ # json => true
185
+ # target => 'rest'
186
+ # }
187
+ # }
188
+ # CONFIG
189
+ # end
190
+ #
191
+ # sample('message' => '1') do
192
+ # expect(subject).to include('rest')
193
+ # expect(subject.get('[rest][0]')).to include('userId')
194
+ # expect(subject.get('[rest][0][userId]')).to eq(1)
195
+ # expect(subject.get('[rest][0][id]')).to eq(1)
196
+ # expect(subject.get('rest').length).to eq(1)
197
+ # expect(subject.get('rest')).to_not include('fallback')
198
+ # end
199
+ # end
200
+ # describe 'Set to Rest Filter Post with params' do
201
+ # let(:config) do <<-CONFIG
202
+ # filter {
203
+ # rest {
204
+ # request => {
205
+ # url => 'https://jsonplaceholder.typicode.com/posts'
206
+ # method => 'post'
207
+ # params => {
208
+ # title => 'foo'
209
+ # body => 'bar'
210
+ # userId => 42
211
+ # }
212
+ # headers => {
213
+ # 'Content-Type' => 'application/json'
214
+ # }
215
+ # }
216
+ # json => true
217
+ # target => 'rest'
218
+ # }
219
+ # }
220
+ # CONFIG
221
+ # end
222
+ #
223
+ # sample('message' => 'some text') do
224
+ # expect(subject).to include('rest')
225
+ # expect(subject.get('rest')).to include('id')
226
+ # expect(subject.get('[rest][userId]')).to eq(42)
227
+ # expect(subject.get('rest')).to_not include('fallback')
228
+ # end
229
+ # end
230
+ # describe 'Set to Rest Filter Post with params sprintf' do
231
+ # let(:config) do <<-CONFIG
232
+ # filter {
233
+ # rest {
234
+ # request => {
235
+ # url => 'https://jsonplaceholder.typicode.com/posts'
236
+ # method => 'post'
237
+ # params => {
238
+ # title => '%{message}'
239
+ # body => 'bar'
240
+ # userId => "%{message}"
241
+ # }
242
+ # headers => {
243
+ # 'Content-Type' => 'application/json'
244
+ # }
245
+ # }
246
+ # json => true
247
+ # target => 'rest'
248
+ # }
249
+ # }
250
+ # CONFIG
251
+ # end
252
+ #
253
+ # sample('message' => '42') do
254
+ # expect(subject).to include('rest')
255
+ # expect(subject.get('rest')).to include('id')
256
+ # expect(subject.get('[rest][title]')).to eq(42)
257
+ # expect(subject.get('[rest][userId]')).to eq(42)
258
+ # expect(subject.get('rest')).to_not include('fallback')
259
+ # end
260
+ # sample('message' => ':5e?#!-_') do
261
+ # expect(subject).to include('rest')
262
+ # expect(subject.get('rest')).to include('id')
263
+ # expect(subject.get('[rest][title]')).to eq(':5e?#!-_')
264
+ # expect(subject.get('[rest][userId]')).to eq(':5e?#!-_')
265
+ # expect(subject.get('rest')).to_not include('fallback')
266
+ # end
267
+ # sample('message' => ':4c43=>') do
268
+ # expect(subject).to include('rest')
269
+ # expect(subject.get('rest')).to include('id')
270
+ # expect(subject.get('[rest][title]')).to eq(':4c43=>')
271
+ # expect(subject.get('[rest][userId]')).to eq(':4c43=>')
272
+ # expect(subject.get('rest')).to_not include('fallback')
273
+ # end
274
+ # end
275
+ # describe 'Set to Rest Filter Post with body sprintf' do
276
+ # let(:config) do <<-CONFIG
277
+ # filter {
278
+ # rest {
279
+ # request => {
280
+ # url => 'https://jsonplaceholder.typicode.com/posts'
281
+ # method => 'post'
282
+ # body => {
283
+ # title => 'foo'
284
+ # body => 'bar'
285
+ # userId => "%{message}"
286
+ # }
287
+ # headers => {
288
+ # 'Content-Type' => 'application/json'
289
+ # }
290
+ # }
291
+ # json => true
292
+ # target => 'rest'
293
+ # }
294
+ # }
295
+ # CONFIG
296
+ # end
297
+ #
298
+ # sample('message' => '42') do
299
+ # expect(subject).to include('rest')
300
+ # expect(subject.get('rest')).to include('id')
301
+ # expect(subject.get('[rest][userId]')).to eq(42)
302
+ # expect(subject.get('rest')).to_not include('fallback')
303
+ # end
304
+ # end
305
+ # describe 'Set to Rest Filter Post with body sprintf nested params' do
306
+ # let(:config) do <<-CONFIG
307
+ # filter {
308
+ # rest {
309
+ # request => {
310
+ # url => 'https://jsonplaceholder.typicode.com/posts'
311
+ # method => 'post'
312
+ # body => {
313
+ # key1 => [
314
+ # {
315
+ # "filterType" => "text"
316
+ # "text" => "salmon"
317
+ # "boolean" => false
318
+ # },
319
+ # {
320
+ # "filterType" => "unique"
321
+ # }
322
+ # ]
323
+ # key2 => [
324
+ # {
325
+ # "message" => "123%{message}"
326
+ # "boolean" => true
327
+ # }
328
+ # ]
329
+ # key3 => [
330
+ # {
331
+ # "text" => "%{message}123"
332
+ # "filterType" => "text"
333
+ # "number" => 44
334
+ # },
335
+ # {
336
+ # "filterType" => "unique"
337
+ # "null" => nil
338
+ # }
339
+ # ]
340
+ # userId => "%{message}"
341
+ # }
342
+ # headers => {
343
+ # 'Content-Type' => 'application/json'
344
+ # }
345
+ # }
346
+ # target => 'rest'
347
+ # }
348
+ # }
349
+ # CONFIG
350
+ # end
351
+ #
352
+ # sample('message' => '42') do
353
+ # expect(subject).to include('rest')
354
+ # expect(subject.get('rest')).to include('key1')
355
+ # expect(subject.get('[rest][key1][0][boolean]')).to eq('false')
356
+ # expect(subject.get('[rest][key1][1][filterType]')).to eq('unique')
357
+ # expect(subject.get('[rest][key2][0][message]')).to eq('12342')
358
+ # expect(subject.get('[rest][key2][0][boolean]')).to eq('true')
359
+ # expect(subject.get('[rest][key3][0][text]')).to eq('42123')
360
+ # expect(subject.get('[rest][key3][0][filterType]')).to eq('text')
361
+ # expect(subject.get('[rest][key3][0][number]')).to eq(44)
362
+ # expect(subject.get('[rest][key3][1][filterType]')).to eq('unique')
363
+ # expect(subject.get('[rest][key3][1][null]')).to eq('nil')
364
+ # expect(subject.get('[rest][userId]')).to eq(42)
365
+ # expect(subject.get('rest')).to_not include('fallback')
366
+ # end
367
+ # end
368
+ # describe 'fallback' do
369
+ # let(:config) do <<-CONFIG
370
+ # filter {
371
+ # rest {
372
+ # request => {
373
+ # url => 'http://jsonplaceholder.typicode.com/users/0'
374
+ # }
375
+ # json => true
376
+ # fallback => {
377
+ # 'fallback1' => true
378
+ # 'fallback2' => true
379
+ # }
380
+ # target => 'rest'
381
+ # }
382
+ # }
383
+ # CONFIG
384
+ # end
385
+ #
386
+ # sample('message' => 'some text') do
387
+ # expect(subject).to include('rest')
388
+ # expect(subject.get('rest')).to include('fallback1')
389
+ # expect(subject.get('rest')).to include('fallback2')
390
+ # expect(subject.get('rest')).to_not include('id')
391
+ # end
392
+ # end
393
+ # describe 'empty target exception' do
394
+ # let(:config) do <<-CONFIG
395
+ # filter {
396
+ # rest {
397
+ # request => {
398
+ # url => 'http://jsonplaceholder.typicode.com/users/0'
399
+ # }
400
+ # json => true
401
+ # fallback => {
402
+ # 'fallback1' => true
403
+ # 'fallback2' => true
404
+ # }
405
+ # target => ''
406
+ # }
407
+ # }
408
+ # CONFIG
409
+ # end
410
+ # sample('message' => 'some text') do
411
+ # expect { subject }.to raise_error(LogStash::ConfigurationError)
412
+ # end
413
+ # end
414
+ # describe 'http client throws exception' do
415
+ # let(:config) do <<-CONFIG
416
+ # filter {
417
+ # rest {
418
+ # request => {
419
+ # url => 'invalid_url'
420
+ # }
421
+ # target => 'rest'
422
+ # }
423
+ # }
424
+ # CONFIG
425
+ # end
426
+ # sample('message' => 'some text') do
427
+ # expect(subject).to_not include('rest')
428
+ # expect(subject.get('tags')).to include('_restfailure')
429
+ # end
430
+ # end
406
431
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-rest2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Henning
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-28 00:00:00.000000000 Z
13
+ date: 2017-09-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement