Skip to content

Commit

Permalink
Fix: logstash-keystore failing with an error (elastic#12784)
Browse files Browse the repository at this point in the history
* Fix: missing password dependency require

which causes `bin/logstash-keystore` to fail with an error:
```
ERROR: Failed to load settings file from "path.settings". Aborting...
path.setting=/logstash-7.12.0/config, exception=NameError,
message=>uninitialized constant LogStash::Util::Password

```

* Fix: review all LS parts depending on Password

* Test: bin/logstash-keystore create/list
  • Loading branch information
kares committed Apr 8, 2021
1 parent c4cb8f4 commit e8e393b
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions logstash-core/lib/logstash/elasticsearch_client.rb
Expand Up @@ -18,6 +18,7 @@
require "elasticsearch"
require "elasticsearch/transport/transport/http/manticore"
require 'logstash/util/manticore_ssl_config_helper'
require 'logstash/util/password'

module LogStash class ElasticsearchClient
include LogStash::Util::Loggable
Expand Down
1 change: 1 addition & 0 deletions logstash-core/lib/logstash/modules/kibana_client.rb
Expand Up @@ -18,6 +18,7 @@
require "logstash/json"
require "manticore"
require 'logstash/util/manticore_ssl_config_helper'
require 'logstash/util/password'

module LogStash module Modules class KibanaClient
include LogStash::Util::Loggable
Expand Down
1 change: 1 addition & 0 deletions logstash-core/lib/logstash/util/substitution_variables.rb
Expand Up @@ -18,6 +18,7 @@
java_import "org.logstash.secret.store.SecretStoreExt"

require_relative 'lazy_singleton'
require_relative 'password'

module ::LogStash::Util::SubstitutionVariables

Expand Down
3 changes: 3 additions & 0 deletions qa/integration/fixtures/keystore_spec.yml
@@ -0,0 +1,3 @@
---
services:
- logstash
Binary file added qa/integration/fixtures/logstash.keystore
Binary file not shown.
67 changes: 67 additions & 0 deletions qa/integration/specs/cli/keystore_spec.rb
@@ -0,0 +1,67 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

require_relative "../../framework/fixture"
require_relative "../../framework/settings"
require_relative "../../services/logstash_service"
# require_relative "../../framework/helpers"
require "logstash/devutils/rspec/spec_helper"
require "stud/temporary"
require "fileutils"
require "open3"

describe "CLI > logstash-keystore" do

before(:all) do
@fixture = Fixture.new(__FILE__)
@logstash = @fixture.get_service("logstash")
end

context 'create' do

before do
FileUtils.rm_f File.join(@logstash.logstash_home, 'config', 'logstash.keystore')
end

it "works" do
keystore_list = @logstash.run_cmd(['bin/logstash-keystore', 'create'], true, 'LOGSTASH_KEYSTORE_PASS' => 'PaSSWD')
expect(keystore_list.stderr_and_stdout).to_not match(/ERROR/)
expect(keystore_list.stderr_and_stdout).to include('Created Logstash keystore')
end

end

context 'list' do

before do
keystore = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "fixtures", "logstash.keystore"))
FileUtils.cp keystore, File.join(@logstash.logstash_home, 'config')
end

after do
FileUtils.rm_f File.join(@logstash.logstash_home, 'config', 'logstash.keystore')
end

it "works" do
keystore_list = @logstash.run_cmd(['bin/logstash-keystore', 'list'], true, 'LOGSTASH_KEYSTORE_PASS' => 'PaSSWD')
expect(keystore_list.stderr_and_stdout).to_not match(/ERROR/)
expect(keystore_list.stderr_and_stdout).to include('foo') # contains foo: bar
end

end

end

0 comments on commit e8e393b

Please sign in to comment.