mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-13 09:47:07 +02:00
73 lines
1.5 KiB
Ruby
73 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Fluentd::Setting::InForward do
|
|
let(:klass) { described_class }
|
|
let(:instance) { klass.new(valid_attributes) }
|
|
let(:valid_attributes) {
|
|
{}
|
|
}
|
|
|
|
describe "#valid?" do
|
|
it "should be valid" do
|
|
params = valid_attributes.dup
|
|
klass.new(params).should be_valid
|
|
end
|
|
end
|
|
|
|
describe "#plugin_name" do
|
|
subject { instance.plugin_name }
|
|
it { should == "forward" }
|
|
end
|
|
|
|
describe "#plugin_type" do
|
|
subject { instance.plugin_type }
|
|
it { should == "input" }
|
|
end
|
|
|
|
describe "#to_config" do
|
|
subject { instance.to_config.to_s }
|
|
it { should include("@type forward") }
|
|
end
|
|
|
|
describe "with security section" do
|
|
let(:valid_attributes) {
|
|
{
|
|
security: {
|
|
"0" => {
|
|
self_hostname: "test.fluentd",
|
|
shared_key: "secretsharedkey",
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let(:expected) {
|
|
<<-CONFIG
|
|
<source>
|
|
@type forward
|
|
<security>
|
|
self_hostname test.fluentd
|
|
shared_key secretsharedkey
|
|
</security>
|
|
</source>
|
|
CONFIG
|
|
}
|
|
subject { instance.to_config.to_s }
|
|
it { should == expected }
|
|
end
|
|
|
|
describe "with invalid security section" do
|
|
it do
|
|
params = {
|
|
security: {
|
|
"0" => {
|
|
self_hostname: "test.fluentd",
|
|
}
|
|
}
|
|
}
|
|
object = klass.new(params)
|
|
object.validate
|
|
object.errors.full_messages.should == ["'shared_key' parameter is required, in section security"]
|
|
end
|
|
end
|
|
end
|