From e9cd4bcf63c32a348334e0eb09b6db5ea37f73ab Mon Sep 17 00:00:00 2001 From: Tomas Barton Date: Wed, 22 Jan 2025 09:14:09 +0100 Subject: [PATCH] Include audit_enable tests (#190, #199) Allow passing Integer to `audit_maxbackupindex` --- manifests/init.pp | 2 +- spec/classes/init_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 2c24b7a..5af4006 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -264,7 +264,7 @@ Hash[String,Hash[String,String]] $extra_appenders = $zookeeper::params::extra_appenders, String $audit_threshold = $zookeeper::params::audit_threshold, String $audit_maxfilesize = $zookeeper::params::audit_maxfilesize, - String $audit_maxbackupindex = $zookeeper::params::audit_maxbackupindex, + Variant[Integer,String] $audit_maxbackupindex = $zookeeper::params::audit_maxbackupindex, Boolean $logrotate_timebased = $zookeeper::params::logrotate_timebased, Integer $logrotate_days = $zookeeper::params::logrotate_days, diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index a70f2d3..9f91506 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -274,4 +274,22 @@ it { is_expected.not_to contain_file('/etc/zookeeper/conf/zoo.cfg').with_content(%r{^clientPort=2181}) } it { is_expected.to contain_file('/etc/zookeeper/conf/zoo.cfg').with_content(%r{^secureClientPort=2182}) } end + + context 'with audit_enable' do + let(:params) do + { + audit_enable: true, + audit_maxfilesize: '5M', + audit_maxbackupindex: 5, + audit_threshold: 'ERROR', + } + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('/etc/zookeeper/conf/zoo.cfg').with_content(%r{^audit.enable=true}) } + it { is_expected.to contain_file('/etc/zookeeper/conf/log4j.properties').with_content(%r{^zookeeper.auditlog.file=zookeeper_audit.log}) } + it { is_expected.to contain_file('/etc/zookeeper/conf/log4j.properties').with_content(%r{^log4j.appender.RFAAUDIT.MaxFileSize=5M}) } + it { is_expected.to contain_file('/etc/zookeeper/conf/log4j.properties').with_content(%r{^log4j.appender.RFAAUDIT.MaxBackupIndex=5}) } + it { is_expected.to contain_file('/etc/zookeeper/conf/log4j.properties').with_content(%r{^zookeeper.auditlog.threshold=ERROR}) } + end end