logstash-mixin-http_client 5.0.0 → 5.1.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: 3407598b8fe0c863cdf83991df712acadb5156d2
4
- data.tar.gz: 597f3f3b3dfd3da2db551b4071c429c44fc1b4a0
3
+ metadata.gz: accbc8d73a9e83d972f9e0a8fb4e559af7190943
4
+ data.tar.gz: 81084e1fa78f82fcd72572bdb0c94f03a3ee3e36
5
5
  SHA512:
6
- metadata.gz: c6d5cafaeb158d80ec39b621127676eeee1dfbb2494835ec59e7e98f4c7f3735023d7b8ba0086fc9376279b996195f5452fac13c03eb9c33d94c1450e917df0a
7
- data.tar.gz: 1d511a3e32b178592bb27772f4de3edae4638911f2a61cf0e9da995f5bec5ded738ad728c599062ce6201d7dcf7155a3fd1c0799ad88d42843aa1ff96077ae24
6
+ metadata.gz: e1be836f270f3e1023645a22f5f6bbcd7c3c854c440492315a0ae5501087e41dc6b4b0a37c37f040fff1b7beddbad353b0931da81e1d23530e2654c577aaac6d
7
+ data.tar.gz: d64fb9c5ab678cb1411584ad0382a2277b94a28883114f251f20752f0ad37500b79444670b663b99eb5975795145ce2962c8f4c11b65c4e159868e7928b6770d
@@ -1,3 +1,6 @@
1
+ # 5.1.0
2
+ - Add user / password options for HTTP auth
3
+
1
4
  ## 5.0.0
2
5
  - Obsolete ssl_certificate_verify option that didn't actually work
3
6
 
data/README.md CHANGED
@@ -64,6 +64,13 @@ config :proxy
64
64
  config :client_cert, :validate => :path
65
65
  # If you'd like to use a client certificate (note, most people don't want this) set the path to the x509 key here
66
66
  config :client_key, :validate => :path
67
+
68
+ # If you'd like to use authentication. Options available include:
69
+ #
70
+ # user - username to be used
71
+ # password - password to be used
72
+ # eager - eagerly offer the Authorization header before the server challenges for it
73
+ config :auth
67
74
  ```
68
75
 
69
76
  ## Documentation
@@ -92,6 +92,12 @@ module LogStash::PluginMixins::HttpClient
92
92
  # 2. Proxy host in form: `{host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}`
93
93
  # 3. Proxy host in form: `{url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}`
94
94
  config :proxy
95
+
96
+ # Username to use for HTTP auth.
97
+ config :user, :validate => :string
98
+
99
+ # Password to use for HTTP auth
100
+ config :password, :validate => :password
95
101
  end
96
102
 
97
103
  public
@@ -117,6 +123,19 @@ module LogStash::PluginMixins::HttpClient
117
123
  @proxy
118
124
  end
119
125
 
126
+ if @user
127
+ if !@password || !@password.value
128
+ raise ::LogStash::ConfigurationError, "User '#{@user}' specified without password!"
129
+ end
130
+
131
+ # Symbolize keys if necessary
132
+ c[:auth] = {
133
+ :user => @user,
134
+ :password => @password.value,
135
+ :eager => true
136
+ }
137
+ end
138
+
120
139
  c[:ssl] = {}
121
140
  if @cacert
122
141
  c[:ssl][:ca_file] = @cacert
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-mixin-http_client'
3
- s.version = '5.0.0'
3
+ s.version = '5.1.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "AWS mixins to provide a unified interface for Amazon Webservice"
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"
@@ -85,6 +85,42 @@ describe LogStash::PluginMixins::HttpClient do
85
85
  end
86
86
  end
87
87
 
88
+ describe "http auth" do
89
+ subject { Dummy.new(client_config).send(:client_config)[:auth] }
90
+
91
+ let(:user) { "myuser" }
92
+ let(:password) { "mypassword" }
93
+ let(:client_config) { basic_config.merge("user" => user, "password" => password )}
94
+
95
+ it "should set the user correctly in the auth settings" do
96
+ expect(subject[:user]).to eq(user)
97
+ end
98
+
99
+ it "should set the password correctly in the auth settings" do
100
+ expect(subject[:password]).to eq(password)
101
+ end
102
+
103
+ it "should always enable eager auth" do
104
+ expect(subject[:eager]).to eq(true)
105
+ end
106
+
107
+ context "with no user or password" do
108
+ let(:client_config) { basic_config }
109
+
110
+ it "should not set the auth parameter" do
111
+ expect(subject).to be_nil
112
+ end
113
+ end
114
+
115
+ context "with a user but no password specified" do
116
+ let(:client_config) { c = super; c.delete("password"); c }
117
+
118
+ it "should raise a configuration error" do
119
+ expect { subject }.to raise_error(::LogStash::ConfigurationError)
120
+ end
121
+ end
122
+ end
123
+
88
124
  ["keystore", "truststore"].each do |store|
89
125
  describe "with a custom #{store}" do
90
126
  let(:file) { Stud::Temporary.file }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-mixin-http_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-05 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement