logstash-input-http 2.2.3 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 369d5bdf4eb3849fe8c1c22be51872b77f306e99
4
- data.tar.gz: 7f4c99931dd5bbbd45afc51dd689bc3ddaf21291
3
+ metadata.gz: 75f2c566d1b23333d2705be8973004bc525a8ff1
4
+ data.tar.gz: c6f406a0effc8b4be87a1048d4a7a2f37103e4fb
5
5
  SHA512:
6
- metadata.gz: 8101c5b9b09393a672d4807bad8980265e5592dc9ba979e6cd70798ff02cd07919be12a9f1a6dfd5608447fe44aa5849f5a262eae417c93928c01a2564889678
7
- data.tar.gz: 4b8f65d565b7b49dfc0d31b09665fda3361b775b3816bddde7a2cd4e51f925333ae52f486176bf1b903c529b3fc22b194dc2e8f76678d852ef5dda8f68b9369c
6
+ metadata.gz: e4116f87e6ff47f554989b160c61ac3bcc8752e04e1d3d4573c4149848fc821b686c08e9630b60373101d2bc1fc1be345580beb7a7e8ff2fa3f4c0cf67159365
7
+ data.tar.gz: 31425ebc701bbefe30813879e40e1aa036c87457b9d570a1523c6985f18fb29671c32d21ce824acd9bb43fc30fa8919a4cff2f06c6c04a4de12d21dcb41fef64
data/CHANGELOG.md CHANGED
@@ -1,6 +1,5 @@
1
- # 2.2.3
2
- - fix hanging tests
3
- - added some meta documents to the repository like contributing guide and github templates
1
+ ## 3.0.0
2
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
4
3
  # 2.2.2
5
4
  - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
6
5
  # 2.2.1
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
+ gemspec
@@ -130,8 +130,8 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
130
130
  req = lowercase_keys(req)
131
131
  body = req.delete("rack.input")
132
132
  @codecs.fetch(req["content_type"], @codec).decode(body.read) do |event|
133
- event["host"] = remote_host
134
- event["headers"] = req
133
+ event.set("host", remote_host)
134
+ event.set("headers", req)
135
135
  decorate(event)
136
136
  queue << event
137
137
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-http'
3
- s.version = '2.2.3'
3
+ s.version = '3.0.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Logstash Input plugin that receives HTTP requests"
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"
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
19
19
 
20
20
  # Gem dependencies
21
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
21
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
22
22
  s.add_runtime_dependency 'logstash-codec-plain'
23
23
  s.add_runtime_dependency 'stud'
24
24
  s.add_runtime_dependency 'puma', '~> 2.16', '>= 2.16.0'
@@ -16,179 +16,149 @@ describe LogStash::Inputs::Http do
16
16
  let(:queue) { Queue.new }
17
17
  let(:port) { rand(5000) + 1025 }
18
18
 
19
- it_behaves_like "an interruptible input plugin" do
20
- let(:config) { { "port" => port } }
21
- end
22
-
23
19
  after :each do
24
20
  subject.stop
25
21
  end
26
22
 
27
- describe "request handling" do
23
+ it_behaves_like "an interruptible input plugin" do
24
+ let(:config) { { "port" => port } }
25
+ end
26
+
27
+ describe "#run" do
28
28
  subject { LogStash::Inputs::Http.new }
29
29
  before :each do
30
30
  subject.register
31
- t = Thread.new { subject.run(queue) }
32
- sleep 0.01 until subject.instance_variable_get(:@server).running == 0
31
+ Thread.new { subject.run(queue) }
33
32
  end
34
-
35
33
  it "should include remote host in \"host\" property" do
36
34
  agent.post!("http://localhost:8080/meh.json",
37
- :headers => { "content-type" => "text/plain" },
38
- :body => "hello")
35
+ :headers => { "content-type" => "text/plain" },
36
+ :body => "hello")
39
37
  event = queue.pop
40
- expect(event["host"]).to eq("127.0.0.1")
38
+ expect(event.get("host")).to eq("127.0.0.1")
41
39
  end
40
+ end
42
41
 
43
- context "with default codec" do
44
- subject { LogStash::Inputs::Http.new("port" => port) }
45
- context "when receiving a text/plain request" do
46
- it "should process the request normally" do
47
- agent.post!("http://localhost:#{port}/meh.json",
48
- :headers => { "content-type" => "text/plain" },
49
- :body => "hello")
50
- event = queue.pop
51
- expect(event["message"]).to eq("hello")
52
- end
53
- end
54
- context "when receiving a deflate compressed text/plain request" do
55
- it "should process the request normally" do
56
- agent.post!("http://localhost:#{port}/meh.json",
57
- :headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
58
- :body => Zlib::Deflate.deflate("hello"))
59
- event = queue.pop
60
- expect(event["message"]).to eq("hello")
61
- end
62
- end
63
- context "when receiving a deflate text/plain request that cannot be decompressed" do
64
- it "should respond with 400" do
65
- response = agent.post!("http://localhost:#{port}/meh.json",
66
- :headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
67
- :body => "hello")
68
- expect(response.status).to eq(400)
69
- end
70
- it "should respond with a decompression error" do
71
- response = agent.post!("http://localhost:#{port}/meh.json",
72
- :headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
73
- :body => "hello")
74
- expect(response.read_body).to eq("Failed to decompress body")
75
- end
76
- end
77
- context "when receiving a gzip compressed text/plain request" do
78
- it "should process the request normally" do
79
- z = StringIO.new ""
80
- w = Zlib::GzipWriter.new z
81
- w.write("hello")
82
- w.finish
83
- agent.post!("http://localhost:#{port}/meh.json",
84
- :headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
85
- :body => z.string)
86
- event = queue.pop
87
- expect(event["message"]).to eq("hello")
88
- end
89
- end
90
- context "when receiving a gzip text/plain request that cannot be decompressed" do
91
- let(:response) do
92
- agent.post!("http://localhost:#{port}/meh.json",
93
- :headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
94
- :body => "hello")
95
- end
96
- it "should respond with 400" do
97
- expect(response.status).to eq(400)
98
- end
99
- it "should respond with a decompression error" do
100
- expect(response.read_body).to eq("Failed to decompress body")
101
- end
102
- end
103
- context "when receiving an application/json request" do
104
- it "should parse the json body" do
105
- agent.post!("http://localhost:#{port}/meh.json",
106
- :headers => { "content-type" => "application/json" },
107
- :body => { "message_body" => "Hello" }.to_json)
108
- event = queue.pop
109
- expect(event["message_body"]).to eq("Hello")
110
- end
42
+ context "with default codec" do
43
+ subject { LogStash::Inputs::Http.new("port" => port) }
44
+ context "when receiving a text/plain request" do
45
+ it "should process the request normally" do
46
+ subject.register
47
+ Thread.new { subject.run(queue) }
48
+ agent.post!("http://localhost:#{port}/meh.json",
49
+ :headers => { "content-type" => "text/plain" },
50
+ :body => "hello")
51
+ event = queue.pop
52
+ expect(event.get("message")).to eq("hello")
111
53
  end
112
54
  end
113
- context "with json codec" do
114
- subject { LogStash::Inputs::Http.new("port" => port, "codec" => "json") }
115
- it "should parse the json body" do
116
- agent.post!("http://localhost:#{port}/meh.json", :body => { "message" => "Hello" }.to_json)
55
+ context "when receiving a deflate compressed text/plain request" do
56
+ it "should process the request normally" do
57
+ subject.register
58
+ Thread.new { subject.run(queue) }
59
+ agent.post!("http://localhost:#{port}/meh.json",
60
+ :headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
61
+ :body => Zlib::Deflate.deflate("hello"))
117
62
  event = queue.pop
118
- expect(event["message"]).to eq("Hello")
63
+ expect(event.get("message")).to eq("hello")
119
64
  end
120
65
  end
121
-
122
- context "when using a custom codec mapping" do
123
- subject { LogStash::Inputs::Http.new("port" => port,
124
- "additional_codecs" => { "application/json" => "plain" }) }
125
- it "should decode the message accordingly" do
126
- body = { "message" => "Hello" }.to_json
66
+ context "when receiving a deflate text/plain request that cannot be decompressed" do
67
+ let!(:response) do
68
+ subject.register
69
+ Thread.new { subject.run(queue) }
70
+ agent.post!("http://localhost:#{port}/meh.json",
71
+ :headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
72
+ :body => "hello")
73
+ end
74
+ it "should respond with 400" do
75
+ expect(response.status).to eq(400)
76
+ end
77
+ it "should respond with a decompression error" do
78
+ expect(response.read_body).to eq("Failed to decompress body")
79
+ end
80
+ end
81
+ context "when receiving a gzip compressed text/plain request" do
82
+ it "should process the request normally" do
83
+ subject.register
84
+ Thread.new { subject.run(queue) }
85
+ z = StringIO.new ""
86
+ w = Zlib::GzipWriter.new z
87
+ w.write("hello")
88
+ w.finish
89
+ agent.post!("http://localhost:#{port}/meh.json",
90
+ :headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
91
+ :body => z.string)
92
+ event = queue.pop
93
+ expect(event.get("message")).to eq("hello")
94
+ end
95
+ end
96
+ context "when receiving a gzip text/plain request that cannot be decompressed" do
97
+ let!(:response) do
98
+ subject.register
99
+ Thread.new { subject.run(queue) }
100
+ agent.post!("http://localhost:#{port}/meh.json",
101
+ :headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
102
+ :body => "hello")
103
+ end
104
+ it "should respond with 400" do
105
+ expect(response.status).to eq(400)
106
+ end
107
+ it "should respond with a decompression error" do
108
+ expect(response.read_body).to eq("Failed to decompress body")
109
+ end
110
+ end
111
+ context "when receiving an application/json request" do
112
+ it "should parse the json body" do
113
+ subject.register
114
+ Thread.new { subject.run(queue) }
127
115
  agent.post!("http://localhost:#{port}/meh.json",
128
116
  :headers => { "content-type" => "application/json" },
129
- :body => body)
117
+ :body => { "message_body" => "Hello" }.to_json)
130
118
  event = queue.pop
131
- expect(event["message"]).to eq(body)
119
+ expect(event.get("message_body")).to eq("Hello")
132
120
  end
133
121
  end
122
+ end
123
+
124
+ context "with json codec" do
125
+ subject { LogStash::Inputs::Http.new("port" => port, "codec" => "json") }
126
+ it "should parse the json body" do
127
+ subject.register
128
+ Thread.new { subject.run(queue) }
129
+ agent.post!("http://localhost:#{port}/meh.json", :body => { "message" => "Hello" }.to_json)
130
+ event = queue.pop
131
+ expect(event.get("message")).to eq("Hello")
132
+ end
133
+ end
134
+
135
+ context "when using a custom codec mapping" do
136
+ subject { LogStash::Inputs::Http.new("port" => port,
137
+ "additional_codecs" => { "application/json" => "plain" }) }
138
+ it "should decode the message accordingly" do
139
+ body = { "message" => "Hello" }.to_json
140
+ subject.register
141
+ Thread.new { subject.run(queue) }
142
+ agent.post!("http://localhost:#{port}/meh.json",
143
+ :headers => { "content-type" => "application/json" },
144
+ :body => body)
145
+ event = queue.pop
146
+ expect(event.get("message")).to eq(body)
147
+ end
148
+ end
134
149
 
135
- context "when using custom headers" do
136
- let(:custom_headers) { { 'access-control-allow-origin' => '*' } }
137
- subject { LogStash::Inputs::Http.new("port" => port, "response_headers" => custom_headers) }
150
+ context "when using custom headers" do
151
+ let(:custom_headers) { { 'access-control-allow-origin' => '*' } }
152
+ subject { LogStash::Inputs::Http.new("port" => port, "response_headers" => custom_headers) }
138
153
 
139
- describe "the response" do
140
- it "should include the custom headers" do
141
- response = agent.post!("http://localhost:#{port}/meh", :body => "hello")
142
- expect(response.headers.to_hash).to include(custom_headers)
143
- end
144
- end
145
- end
146
- describe "basic auth" do
147
- user = "test"; password = "pwd"
148
- subject { LogStash::Inputs::Http.new("port" => port, "user" => user, "password" => password) }
149
- let(:auth_token) { Base64.strict_encode64("#{user}:#{password}") }
150
- context "when client doesn't present auth token" do
151
- let!(:response) { agent.post!("http://localhost:#{port}/meh", :body => "hi") }
152
- it "should respond with 401" do
153
- expect(response.status).to eq(401)
154
- end
155
- it "should not generate an event" do
156
- expect(queue).to be_empty
157
- end
158
- end
159
- context "when client presents incorrect auth token" do
160
- let!(:response) do
161
- agent.post!("http://localhost:#{port}/meh",
162
- :headers => {
163
- "content-type" => "text/plain",
164
- "authorization" => "Basic meh"
165
- },
166
- :body => "hi")
167
- end
168
- it "should respond with 401" do
169
- expect(response.status).to eq(401)
170
- end
171
- it "should not generate an event" do
172
- expect(queue).to be_empty
173
- end
174
- end
175
- context "when client presents correct auth token" do
176
- let!(:response) do
177
- agent.post!("http://localhost:#{port}/meh",
178
- :headers => {
179
- "content-type" => "text/plain",
180
- "authorization" => "Basic #{auth_token}"
181
- }, :body => "hi")
182
- end
183
- it "should respond with 200" do
184
- expect(response.status).to eq(200)
185
- end
186
- it "should generate an event" do
187
- expect(queue).to_not be_empty
188
- end
154
+ describe "the response" do
155
+ it "should include the custom headers" do
156
+ subject.register
157
+ Thread.new { subject.run(queue) }
158
+ response = agent.post!("http://localhost:#{port}/meh", :body => "hello")
159
+ expect(response.headers.to_hash).to include(custom_headers)
189
160
  end
190
161
  end
191
-
192
162
  end
193
163
 
194
164
  context "with :ssl => false" do
@@ -214,4 +184,53 @@ describe LogStash::Inputs::Http do
214
184
  end
215
185
  end
216
186
  end
187
+ describe "basic auth" do
188
+ user = "test"; password = "pwd"
189
+ subject { LogStash::Inputs::Http.new("port" => port, "user" => user, "password" => password) }
190
+ let(:auth_token) { Base64.strict_encode64("#{user}:#{password}") }
191
+ before :each do
192
+ subject.register
193
+ Thread.new { subject.run(queue) }
194
+ end
195
+ context "when client doesn't present auth token" do
196
+ let!(:response) { agent.post!("http://localhost:#{port}/meh", :body => "hi") }
197
+ it "should respond with 401" do
198
+ expect(response.status).to eq(401)
199
+ end
200
+ it "should not generate an event" do
201
+ expect(queue).to be_empty
202
+ end
203
+ end
204
+ context "when client presents incorrect auth token" do
205
+ let!(:response) do
206
+ agent.post!("http://localhost:#{port}/meh",
207
+ :headers => {
208
+ "content-type" => "text/plain",
209
+ "authorization" => "Basic meh"
210
+ },
211
+ :body => "hi")
212
+ end
213
+ it "should respond with 401" do
214
+ expect(response.status).to eq(401)
215
+ end
216
+ it "should not generate an event" do
217
+ expect(queue).to be_empty
218
+ end
219
+ end
220
+ context "when client presents correct auth token" do
221
+ let!(:response) do
222
+ agent.post!("http://localhost:#{port}/meh",
223
+ :headers => {
224
+ "content-type" => "text/plain",
225
+ "authorization" => "Basic #{auth_token}"
226
+ }, :body => "hi")
227
+ end
228
+ it "should respond with 200" do
229
+ expect(response.status).to eq(200)
230
+ end
231
+ it "should generate an event" do
232
+ expect(queue).to_not be_empty
233
+ end
234
+ end
235
+ end
217
236
  end
metadata CHANGED
@@ -1,58 +1,59 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - "~>"
17
18
  - !ruby/object:Gem::Version
18
- version: '1.0'
19
- name: logstash-core-plugin-api
20
- prerelease: false
19
+ version: '2.0'
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: logstash-codec-plain
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
- name: logstash-codec-plain
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
+ name: stud
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- name: stud
48
- prerelease: false
49
48
  type: :runtime
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: puma
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - "~>"
@@ -61,9 +62,8 @@ dependencies:
61
62
  - - ">="
62
63
  - !ruby/object:Gem::Version
63
64
  version: 2.16.0
64
- name: puma
65
- prerelease: false
66
65
  type: :runtime
66
+ prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
@@ -73,62 +73,64 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: 2.16.0
75
75
  - !ruby/object:Gem::Dependency
76
+ name: rack
76
77
  requirement: !ruby/object:Gem::Requirement
77
78
  requirements:
78
79
  - - "~>"
79
80
  - !ruby/object:Gem::Version
80
81
  version: '1'
81
- name: rack
82
- prerelease: false
83
82
  type: :runtime
83
+ prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '1'
89
89
  - !ruby/object:Gem::Dependency
90
+ name: logstash-devutils
90
91
  requirement: !ruby/object:Gem::Requirement
91
92
  requirements:
92
93
  - - ">="
93
94
  - !ruby/object:Gem::Version
94
95
  version: '0'
95
- name: logstash-devutils
96
- prerelease: false
97
96
  type: :development
97
+ prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
+ name: logstash-codec-json
104
105
  requirement: !ruby/object:Gem::Requirement
105
106
  requirements:
106
107
  - - ">="
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
- name: logstash-codec-json
110
- prerelease: false
111
110
  type: :development
111
+ prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
+ name: ftw
118
119
  requirement: !ruby/object:Gem::Requirement
119
120
  requirements:
120
121
  - - ">="
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
- name: ftw
124
- prerelease: false
125
124
  type: :development
125
+ prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
- 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
131
+ description: This gem is a Logstash plugin required to be installed on top of the
132
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
133
+ gem is not a stand-alone program
132
134
  email: info@elastic.co
133
135
  executables: []
134
136
  extensions: []
@@ -150,7 +152,7 @@ licenses:
150
152
  metadata:
151
153
  logstash_plugin: 'true'
152
154
  logstash_group: input
153
- post_install_message:
155
+ post_install_message:
154
156
  rdoc_options: []
155
157
  require_paths:
156
158
  - lib
@@ -165,9 +167,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  - !ruby/object:Gem::Version
166
168
  version: '0'
167
169
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.6.3
170
- signing_key:
170
+ rubyforge_project:
171
+ rubygems_version: 2.5.1
172
+ signing_key:
171
173
  specification_version: 4
172
174
  summary: Logstash Input plugin that receives HTTP requests
173
175
  test_files: