mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
parent
62c42be8e2
commit
dbb034ec45
2 changed files with 38 additions and 0 deletions
|
@ -110,6 +110,16 @@ module LogStash::Config::Mixin
|
|||
I18n.t("logstash.agent.configuration.invalid_plugin_settings")
|
||||
end
|
||||
|
||||
# We remove any config options marked as obsolete,
|
||||
# no code should be associated to them and their values should not bleed
|
||||
# to the plugin context.
|
||||
#
|
||||
# This need to be done after fetching the options from the parents classed
|
||||
params.reject! do |name, value|
|
||||
opts = self.class.get_config[name]
|
||||
opts.include?(:obsolete)
|
||||
end
|
||||
|
||||
# set instance variables like '@foo' for each config value given.
|
||||
params.each do |key, value|
|
||||
next if key[0, 1] == "@"
|
||||
|
|
|
@ -115,6 +115,14 @@ describe LogStash::Config::Mixin do
|
|||
end
|
||||
end
|
||||
|
||||
context "when using an obsolete settings from the parent class" do
|
||||
it "should cause a configuration error" do
|
||||
expect {
|
||||
plugin_class.new("debug" => true)
|
||||
}.to raise_error(LogStash::ConfigurationError)
|
||||
end
|
||||
end
|
||||
|
||||
context "when not using an obsolete setting" do
|
||||
it "should not cause a configuration error" do
|
||||
expect {
|
||||
|
@ -123,4 +131,24 @@ describe LogStash::Config::Mixin do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "#params" do
|
||||
let(:plugin_class) do
|
||||
Class.new(LogStash::Filters::Base) do
|
||||
config_name "fake"
|
||||
config :password, :validate => :password
|
||||
config :bad, :validate => :string, :default => "my default", :obsolete => "not here"
|
||||
end
|
||||
end
|
||||
|
||||
subject { plugin_class.new({ "password" => "secret" }) }
|
||||
|
||||
it "should not return the obsolete options" do
|
||||
expect(subject.params).not_to include("bad")
|
||||
end
|
||||
|
||||
it "should include any other params" do
|
||||
expect(subject.params).to include("password")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue