require 'helper' class SecureForwardInputTest < Test::Unit::TestCase CONFIG = %[ ] def create_driver(conf=CONFIG,tag='test') Fluent::Test::InputTestDriver.new(Fluent::SecureForwardInput).configure(conf) end def test_configure p1 = nil assert_nothing_raised { p1 = create_driver(< username tagomoris password foobar012 password yakiniku CONFIG assert_raise(Fluent::ConfigError){ create_driver(< username tagomoris password foobar012 username frsyuki CONFIG p2 = nil assert_nothing_raised { p2 = create_driver(< username tagomoris password foobar012 username frsyuki password yakiniku CONFIG assert_equal 2, p2.users.size assert_equal 'tagomoris', p2.users[0].username assert_equal 'foobar012', p2.users[0].password assert_raise(Fluent::ConfigError){ create_driver(< host 192.168.10.30 # network address (ex: 192.168.10.0/24) NOT Supported now host localhost network 192.168.1.1/32 network 192.168.16.0/24 CONFIG assert_raise(Fluent::ConfigError){ create_driver(< host 192.168.10.30 # network address (ex: 192.168.10.0/24) NOT Supported now network 192.168.16.0/24 CONFIG p3 = nil assert_nothing_raised { p3 = create_driver(< host 192.168.10.30 # network address (ex: 192.168.10.0/24) NOT Supported now host localhost # wildcard (ex: *.host.fqdn.local) NOT Supported now network 192.168.16.0/24 CONFIG assert (not p3.allow_anonymous_source) assert_equal 3, p3.clients.size assert_equal '192.168.16.0/24', p3.clients[2].network assert_equal 3, p3.nodes.size assert_equal IPAddr.new('192.168.10.30'), p3.nodes[0][:address] assert_equal IPAddr.new('192.168.16.0/24'), p3.nodes[2][:address] p4 = nil assert_nothing_raised { p4 = create_driver(< authentication yes # Deny clients without valid username/password username tagomoris password foobar012 username frsyuki password sukiyaki username repeatedly password sushi host 192.168.10.30 # allow all users to connect from 192.168.10.30 host 192.168.10.31 users tagomoris,frsyuki # deny repeatedly from 192.168.10.31 host 192.168.10.32 shared_key less_secret_string # limited shared_key for 192.168.10.32 users repeatedly # and repatedly only CONFIG assert_equal ['tagomoris','frsyuki'], p4.nodes[1][:users] end end