Skip to content

Commit bbca3d1

Browse files
andrewvcjordansissel
authored andcommitted
Auth should use 'password' not 'pass'
Fixes #17
1 parent 6bb3a72 commit bbca3d1

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

examples/ha_proxy.conf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ input {
33
urls => {
44
haproxy => {
55
method => get
6-
url => "http://A_Username:YourPassword@localhost:9201/haproxy?stats;csv"
6+
url => "http://localhost:9201/haproxy?stats;csv"
7+
auth => {
8+
user => "myuser"
9+
password => "mypass"
10+
}
711
}
812
}
913
request_timeout => 60

lib/logstash/inputs/http_poller.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# }
2424
# auth => {
2525
# user => "AzureDiamond"
26-
# pass => "hunter2"
26+
# password => "hunter2"
2727
# }
2828
# }
2929
# }
@@ -89,7 +89,7 @@ def normalize_request(url_or_spec)
8989
url = spec.delete(:url)
9090

9191
# We need these strings to be keywords!
92-
spec[:auth] = {user: spec[:auth]["user"], pass: spec[:auth]["pass"]} if spec[:auth]
92+
spec[:auth] = {user: spec[:auth]["user"], pass: spec[:auth]["password"]} if spec[:auth]
9393

9494
res = [method, url, spec]
9595
else
@@ -112,7 +112,7 @@ def validate_request!(url_or_spec, request)
112112
raise LogStash::ConfigurationError, "Auth was specified, but 'user' was not!"
113113
end
114114
if !spec[:auth][:pass]
115-
raise LogStash::ConfigurationError, "Auth was specified, but 'pass' was not!"
115+
raise LogStash::ConfigurationError, "Auth was specified, but 'password' was not!"
116116
end
117117
end
118118

@@ -136,6 +136,8 @@ def run_once(queue)
136136
# Some exceptions are only returned here! There is no callback,
137137
# for example, if there is a bad port number.
138138
# https://github.com/cheald/manticore/issues/22
139+
# This issue is now fixed, but we'll leave this code in for older versions
140+
# of manticore. Once the plugin ecosystem is more updated we can kill this.
139141
client.execute!.each_with_index do |resp, i|
140142
if resp.is_a?(java.lang.Exception) || resp.is_a?(StandardError)
141143
name = @requests.keys[i]
@@ -152,8 +154,8 @@ def request_async(queue, name, request)
152154
@logger.debug? && @logger.debug("Fetching URL", :name => name, :url => request)
153155
started = Time.now
154156

155-
method, request_opts = request
156-
client.async.send(method, request_opts).
157+
method, *request_opts = request
158+
client.async.send(method, *request_opts).
157159
on_success {|response| handle_success(queue, name, request, response, Time.now - started)}.
158160
on_failure {|exception|
159161
handle_failure(queue, name, request, exception, Time.now - started)

spec/inputs/http_poller_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,20 @@
111111
end
112112

113113
context "with auth enabled, a path, but no user" do
114-
let(:url) { {"method" => "get", "auth" => {"pass" => "bar"}} }
114+
let(:url) { {"method" => "get", "auth" => {"password" => "bar"}} }
115115
it "should raise an error" do
116116
expect { normalized }.to raise_error(LogStash::ConfigurationError)
117117
end
118118
end
119119
context "with auth enabled correctly" do
120-
let(:auth) { {"user" => "foo", "pass" => "bar"} }
120+
let(:auth) { {"user" => "foo", "password" => "bar"} }
121121

122122
it "should raise an error" do
123123
expect { normalized }.not_to raise_error
124124
end
125125

126126
it "should properly set the auth parameter" do
127-
expect(normalized[2][:auth]).to eql({:user => auth["user"], :pass => auth["pass"]})
127+
expect(normalized[2][:auth]).to eql({:user => auth["user"], :pass => auth["password"]})
128128
end
129129
end
130130
end

0 commit comments

Comments
 (0)