Skip to content

Commit

Permalink
Add more tests for invalid <label> directive
Browse files Browse the repository at this point in the history
Signed-off-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
ashie committed Jul 30, 2021
1 parent 3bf4045 commit 62809ca
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/root_agent.rb
Expand Up @@ -131,7 +131,7 @@ def configure(conf)
end
name = e.arg
raise ConfigError, "Missing symbol argument on <label> directive" if name.empty?
raise ConfigError, "@ROOT for <label> is invalid, reserved for getting root router" if name == '@ROOT'
raise ConfigError, "@ROOT for <label> is not permitted, reserved for getting root router" if name == '@ROOT'

if name == ERROR_LABEL
error_label_config = e
Expand Down
28 changes: 28 additions & 0 deletions test/test_root_agent.rb
Expand Up @@ -109,6 +109,34 @@ def configure_ra(conf_str)
end
end

test 'raises configuration error for label without name' do
conf = <<-EOC
<label>
@type test_out
</label>
EOC
errmsg = "Missing symbol argument on <label> directive"
assert_raise Fluent::ConfigError.new(errmsg) do
configure_ra(conf)
end
end

test 'raises configuration error for <label @ROOT>' do
conf = <<-EOC
<source>
@type test_in
@label @ROOT
</source>
<label @ROOT>
@type test_out
</label>
EOC
errmsg = "@ROOT for <label> is not permitted, reserved for getting root router"
assert_raise Fluent::ConfigError.new(errmsg) do
configure_ra(conf)
end
end

test 'raises configuration error if there are not match sections in label section' do
conf = <<-EOC
<source>
Expand Down

0 comments on commit 62809ca

Please sign in to comment.