logstash-input-http 2.2.2 → 2.2.3

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: cbc7e81f1a5fc2c27958a9f46a7d393d1501d322
4
- data.tar.gz: c254a7c14edd9f9ba1556cbe80d65654df407485
3
+ metadata.gz: 369d5bdf4eb3849fe8c1c22be51872b77f306e99
4
+ data.tar.gz: 7f4c99931dd5bbbd45afc51dd689bc3ddaf21291
5
5
  SHA512:
6
- metadata.gz: 283e1fd41c4c9be3707800bf842752ba3cf55c93ff574ab3578112e88d9b4c85b6433d00c7035683132bab2a8501883c5083ee51c6ea5b8f49d0c6a82e59db97
7
- data.tar.gz: 239407e99e311d48694844a16e35ee89adff91e5c6a861b96ac8264aeebc403773717d56ede69fb68a123e2ebd3c01a1f7bc032f6376bbd4ab9617d352d7fc80
6
+ metadata.gz: 8101c5b9b09393a672d4807bad8980265e5592dc9ba979e6cd70798ff02cd07919be12a9f1a6dfd5608447fe44aa5849f5a262eae417c93928c01a2564889678
7
+ data.tar.gz: 4b8f65d565b7b49dfc0d31b09665fda3361b775b3816bddde7a2cd4e51f925333ae52f486176bf1b903c529b3fc22b194dc2e8f76678d852ef5dda8f68b9369c
@@ -1,3 +1,6 @@
1
+ # 2.2.3
2
+ - fix hanging tests
3
+ - added some meta documents to the repository like contributing guide and github templates
1
4
  # 2.2.2
2
5
  - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
3
6
  # 2.2.1
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
1
+ Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Build
4
- Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-http-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-http-unit/)
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-input-http.svg)](https://travis-ci.org/logstash-plugins/logstash-input-http)
5
4
 
6
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
6
 
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
55
  ```
57
56
  - Install plugin
58
57
  ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
59
62
  bin/plugin install --no-verify
63
+
60
64
  ```
61
65
  - Run Logstash with your plugin
62
66
  ```sh
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
74
78
  ```
75
79
  - Install the plugin from the Logstash home
76
80
  ```sh
77
- bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
78
87
  ```
79
88
  - Start Logstash and proceed to test the plugin
80
89
 
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-http'
3
- s.version = '2.2.2'
3
+ s.version = '2.2.3'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Logstash Input plugin that receives HTTP requests"
6
- s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
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"
7
7
  s.authors = ["Elastic"]
8
8
  s.email = 'info@elastic.co'
9
9
  s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
@@ -16,149 +16,179 @@ describe LogStash::Inputs::Http do
16
16
  let(:queue) { Queue.new }
17
17
  let(:port) { rand(5000) + 1025 }
18
18
 
19
- after :each do
20
- subject.stop
21
- end
22
-
23
19
  it_behaves_like "an interruptible input plugin" do
24
20
  let(:config) { { "port" => port } }
25
21
  end
26
22
 
27
- describe "#run" do
23
+ after :each do
24
+ subject.stop
25
+ end
26
+
27
+ describe "request handling" do
28
28
  subject { LogStash::Inputs::Http.new }
29
29
  before :each do
30
30
  subject.register
31
- Thread.new { subject.run(queue) }
31
+ t = Thread.new { subject.run(queue) }
32
+ sleep 0.01 until subject.instance_variable_get(:@server).running == 0
32
33
  end
34
+
33
35
  it "should include remote host in \"host\" property" do
34
36
  agent.post!("http://localhost:8080/meh.json",
35
- :headers => { "content-type" => "text/plain" },
36
- :body => "hello")
37
+ :headers => { "content-type" => "text/plain" },
38
+ :body => "hello")
37
39
  event = queue.pop
38
40
  expect(event["host"]).to eq("127.0.0.1")
39
41
  end
40
- end
41
42
 
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["message"]).to eq("hello")
53
- end
54
- end
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"))
62
- event = queue.pop
63
- expect(event["message"]).to eq("hello")
64
- end
65
- end
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")
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
79
111
  end
80
112
  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)
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)
92
117
  event = queue.pop
93
- expect(event["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")
118
+ expect(event["message"]).to eq("Hello")
109
119
  end
110
120
  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) }
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
115
127
  agent.post!("http://localhost:#{port}/meh.json",
116
128
  :headers => { "content-type" => "application/json" },
117
- :body => { "message_body" => "Hello" }.to_json)
129
+ :body => body)
118
130
  event = queue.pop
119
- expect(event["message_body"]).to eq("Hello")
131
+ expect(event["message"]).to eq(body)
120
132
  end
121
133
  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["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["message"]).to eq(body)
147
- end
148
- end
149
134
 
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) }
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) }
153
138
 
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)
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
160
189
  end
161
190
  end
191
+
162
192
  end
163
193
 
164
194
  context "with :ssl => false" do
@@ -184,53 +214,4 @@ describe LogStash::Inputs::Http do
184
214
  end
185
215
  end
186
216
  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
236
217
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-24 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,7 @@ dependencies:
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/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 Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
132
132
  email: info@elastic.co
133
133
  executables: []
134
134
  extensions: []
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.4.8
169
+ rubygems_version: 2.6.3
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Logstash Input plugin that receives HTTP requests