-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport PR #12749 to 6.8: internal-monitoring: use configured ssl ve…
…rification mode (#12752) * internal-monitoring: use configured ssl verification mode (#12749) Upstream `ElasticsearchOptions#es_options_from_settings` already uses the setting `elasticsearch.ssl.verification_mode` to produce an appropriate boolean-valued `ssl_certificate_verification` in our `es_settings` hash, so we can rely on it instead of re-checking equality with a string. (cherry picked from commit d5becc0) # Conflicts: # x-pack/spec/monitoring/pipeline_register_hook_spec.rb * monitoring: backport auto-detection of ssl from host
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License; | ||
# you may not use this file except in compliance with the Elastic License. | ||
|
||
require 'monitoring/monitoring' | ||
|
||
describe LogStash::MonitoringExtension::PipelineRegisterHook do | ||
|
||
subject { described_class.new } | ||
|
||
before(:all) { | ||
@extension = LogStash::MonitoringExtension.new | ||
# used to register monitoring xpack's settings | ||
@sys_settings = LogStash::Runner::SYSTEM_SETTINGS.clone | ||
@extension.additionals_settings(@sys_settings) | ||
} | ||
|
||
context 'validate monitoring settings' do | ||
it "work with xpack-namespaced settings" do | ||
settings = @sys_settings.clone | ||
settings.set_value("xpack.monitoring.enabled", true) | ||
settings.set_value("xpack.monitoring.elasticsearch.hosts", "http://localhost:9200") | ||
settings.set_value("xpack.monitoring.elasticsearch.username", "elastic") | ||
settings.set_value("xpack.monitoring.elasticsearch.password", "changeme") | ||
expect(subject.generate_pipeline_config(settings)).to be_truthy | ||
end | ||
|
||
context 'ssl certificate verification setting' do | ||
{ | ||
'certificate' => 'true', | ||
'none' => 'false', | ||
nil => 'true', # unset, uses default | ||
}.each do |setting_value, expected_result| | ||
context "with `xpack.monitoring.elasticsearch.ssl.verification_mode` #{setting_value ? "set to `#{setting_value}`" : 'unset'}" do | ||
it "the generated pipeline includes `ssl_certificate_verification => #{expected_result}`" do | ||
settings = @sys_settings.clone.tap(&:reset) | ||
settings.set_value("xpack.monitoring.enabled", true) | ||
settings.set_value("xpack.monitoring.elasticsearch.hosts", "https://localhost:9200") | ||
settings.set_value("xpack.monitoring.elasticsearch.username", "elastic") | ||
settings.set_value("xpack.monitoring.elasticsearch.password", "changeme") | ||
|
||
settings.set_value("xpack.monitoring.elasticsearch.ssl.verification_mode", setting_value) unless setting_value.nil? | ||
|
||
generated_pipeline_config = subject.generate_pipeline_config(settings) | ||
|
||
expect(generated_pipeline_config).to include("ssl_certificate_verification => #{expected_result}") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |