#6696 validate evaluation result

Fixes #7411
This commit is contained in:
Armin 2017-06-10 19:18:24 +02:00 committed by Armin Braun
parent 32709ae72e
commit 26a8163f19
2 changed files with 17 additions and 0 deletions

View file

@ -143,6 +143,9 @@ module LogStash::Config::Mixin
end # def config_init
module DSL
include LogStash::Util::EnvironmentVariables
attr_accessor :flags
# If name is given, set the name and return it.
@ -388,6 +391,8 @@ module LogStash::Config::Mixin
# (see LogStash::Inputs::File for example)
result = nil
value = deep_replace(value)
if validator.nil?
return true, value
elsif validator.is_a?(Array)

View file

@ -369,11 +369,13 @@ describe LogStash::Config::Mixin do
before do
ENV["FunString"] = "fancy"
ENV["FunBool"] = "true"
ENV["SERVER_LS_TEST_ADDRESS"] = "some.host.address.tld"
end
after do
ENV.delete("FunString")
ENV.delete("FunBool")
ENV.delete("SERVER_LS_TEST_ADDRESS")
end
subject do
@ -397,6 +399,16 @@ describe LogStash::Config::Mixin do
expect(subject.nestedArray).to(be == { "level1" => [{ "key1" => "http://fancy:8080/blah.txt" }, { "key2" => "http://fancy:8080/foo.txt" }] })
expect(subject.deepHash).to(be == { "level1" => { "level2" => { "level3" => { "key1" => "http://fancy:8080/blah.txt" } } } })
end
it "should validate settings after interpolating ENV variables" do
expect {
Class.new(LogStash::Filters::Base) do
include LogStash::Config::Mixin
config_name "test"
config :server_address, :validate => :uri
end.new({"server_address" => "${SERVER_LS_TEST_ADDRESS}"})
}.not_to raise_error
end
end
context "should support $ in values" do