Skip to content

Commit a1bfaea

Browse files
Add a fix to failing secured integration tests
Signed-off-by: Naveen Tatikonda <navtat@amazon.com>
1 parent a0afe99 commit a1bfaea

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
logstash: [ "7.16.3" ]
3636
opensearch: [ "1.2.1" ]
3737
integration: [ true ]
38-
secure: [ false ]
38+
secure: [ true, false ]
3939
name: Integration Test for logstash-input-opensearch against OpenSearch
4040
runs-on: ubuntu-latest
4141
env:
@@ -62,7 +62,7 @@ jobs:
6262
logstash: [ "7.16.3" ]
6363
opendistro: [ "1.13.3" ]
6464
integration: [ true ]
65-
secure: [ false ]
65+
secure: [ true, false ]
6666
name: Integration Test for logstash-input-opensearch against OpenDistro
6767
runs-on: ubuntu-latest
6868
env:

lib/logstash/inputs/opensearch.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ def hosts_default?(hosts)
347347
end
348348

349349
def setup_ssl
350-
@ssl && @ca_file ? { :ssl => true, :ca_file => @ca_file } : {}
350+
return { :ssl => true, :ca_file => @ca_file } if @ssl && @ca_file
351+
return { :ssl => true, :verify => false } if @ssl # Setting verify as false if ca_file is not provided
351352
end
352353

353354
def setup_hosts

spec/inputs/integration/opensearch_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,10 @@
5959
describe 'against a secured opensearch', :secure_integration => true do
6060
let(:user) { ENV['USER'] || 'admin' }
6161
let(:password) { ENV['PASSWORD'] || 'admin' }
62-
let(:ca_file) { "spec/fixtures/test_certs/ca.crt" }
6362

64-
let(:client_options) { { :ca_file => ca_file, :user => user, :password => password } }
63+
let(:client_options) { { :user => user, :password => password } }
6564

66-
let(:config) { super().merge('user' => user, 'password' => password, 'ssl' => true, 'ca_file' => ca_file) }
65+
let(:config) { super().merge('user' => user, 'password' => password, 'ssl' => true) }
6766

6867
it_behaves_like 'an opensearch index plugin'
6968

spec/opensearch_helper.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ def self.get_client(options)
1616
host_opts = { host: host, port: port, scheme: 'http' }
1717
ssl_opts = {}
1818

19+
if options[:user] && options[:password]
20+
host_opts[:user] = options[:user]
21+
host_opts[:password] = options[:password]
22+
host_opts[:scheme] = 'https'
23+
ssl_opts = { verify: false }
24+
end
25+
1926
if options[:ca_file]
2027
ssl_opts = { ca_file: options[:ca_file], version: 'TLSv1.2', verify: false }
2128
host_opts[:scheme] = 'https'
2229
end
2330

24-
if options[:user] && options[:password]
25-
host_opts[:user] = options[:user]
26-
host_opts[:password] = options[:password]
27-
end
31+
2832

2933
OpenSearch::Client.new(hosts: [host_opts],
3034
transport_options: { ssl: ssl_opts },

0 commit comments

Comments
 (0)