<commit_before>require 'spec_helper'

describe 'rsync::server::module', :type => :define do
  let :facts do
    {
      :concat_basedir => '/dne'
    }
  end

  let :title do
    'foobar'
  end

  let :pre_condition do
    'class { "rsync::server": }'
  end

  let :fragment_name do
    "frag-foobar"
  end

  let :mandatory_params do
    { :path => '/some/path' }
  end

  let :params do
    mandatory_params
  end

  describe "when using default class paramaters" do
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^\[ foobar \]$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^path\s*=\s*\/some\/path$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^read only\s*=\s*yes$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^write only\s*=\s*no$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^list\s*=\s*yes$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^uid\s*=\s*0$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^gid\s*=\s*0$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^incoming chmod\s*=\s*0644$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^outgoing chmod\s*=\s*0644$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*0$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^secrets file\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts allow\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts deny\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^transfer logging\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^log format\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^refuse options\s*=.*$/) }
  end

  describe "when overriding max connections" do
    let :params do
      mandatory_params.merge({ :max_connections => 1 })
    end
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*1$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=\s*\/var\/run\/rsyncd\.lock$/) }
  end

  describe "when setting incoming chmod to false" do
    let :params do
      mandatory_params.merge({:incoming_chmod => false,
                              :outgoing_chmod => false,
      })
    end
    it { is_expected.not_to contain_file(fragment_name).with_content(/^incoming chmod.*$/) }
    it { is_expected.not_to contain_file(fragment_name).with_content(/^outgoing chmod.*$/) }
  end

  {
    :comment          => 'super module !',
    :read_only        => 'no',
    :write_only       => 'yes',
    :list             => 'no',
    :uid              => '4682',
    :gid              => '4682',
    :incoming_chmod   => '0777',
    :outgoing_chmod   => '0777',
    :secrets_file     => '/path/to/secrets',
    :hosts_allow      => ['localhost', '169.254.42.51'],
    :hosts_deny       => ['some-host.example.com', '10.0.0.128'],
    :transfer_logging => 'true',
    :log_format       => '%t %a %m %f %b',
    :refuse_options   => ['c', 'delete']
  }.each do |k,v|
    describe "when overriding #{k}" do
      let :params do
        mandatory_params.merge({ k => v })
      end
      it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{Array(v).join(' ')}$/)}
    end
  end

  describe "when overriding auth_users" do
    let :params do
      mandatory_params.merge({ :auth_users     => ['me', 'you', 'them'] })
    end
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=\s*me, you, them$/)}
  end

end
<commit_msg>Add test for log_file parameter<commit_after>require 'spec_helper'

describe 'rsync::server::module', :type => :define do
  let :facts do
    {
      :concat_basedir => '/dne'
    }
  end

  let :title do
    'foobar'
  end

  let :pre_condition do
    'class { "rsync::server": }'
  end

  let :fragment_name do
    "frag-foobar"
  end

  let :mandatory_params do
    { :path => '/some/path' }
  end

  let :params do
    mandatory_params
  end

  describe "when using default class paramaters" do
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^\[ foobar \]$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^path\s*=\s*\/some\/path$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^read only\s*=\s*yes$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^write only\s*=\s*no$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^list\s*=\s*yes$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^uid\s*=\s*0$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^gid\s*=\s*0$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^incoming chmod\s*=\s*0644$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^outgoing chmod\s*=\s*0644$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*0$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^secrets file\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts allow\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts deny\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^transfer logging\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^log format\s*=.*$/) }
    it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^refuse options\s*=.*$/) }
  end

  describe "when overriding max connections" do
    let :params do
      mandatory_params.merge({ :max_connections => 1 })
    end
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*1$/) }
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=\s*\/var\/run\/rsyncd\.lock$/) }
  end

  describe "when setting incoming chmod to false" do
    let :params do
      mandatory_params.merge({:incoming_chmod => false,
                              :outgoing_chmod => false,
      })
    end
    it { is_expected.not_to contain_file(fragment_name).with_content(/^incoming chmod.*$/) }
    it { is_expected.not_to contain_file(fragment_name).with_content(/^outgoing chmod.*$/) }
  end

  {
    :comment          => 'super module !',
    :read_only        => 'no',
    :write_only       => 'yes',
    :list             => 'no',
    :uid              => '4682',
    :gid              => '4682',
    :incoming_chmod   => '0777',
    :outgoing_chmod   => '0777',
    :secrets_file     => '/path/to/secrets',
    :hosts_allow      => ['localhost', '169.254.42.51'],
    :hosts_deny       => ['some-host.example.com', '10.0.0.128'],
    :transfer_logging => 'true',
    :log_format       => '%t %a %m %f %b',
    :refuse_options   => ['c', 'delete']
  }.each do |k,v|
    describe "when overriding #{k}" do
      let :params do
        mandatory_params.merge({ k => v })
      end
      it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{Array(v).join(' ')}$/)}
    end
  end

  describe "when overriding auth_users" do
    let :params do
      mandatory_params.merge({ :auth_users     => ['me', 'you', 'them'] })
    end
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=\s*me, you, them$/)}
  end

  describe "when overriding log_file" do
    let :params do
      mandatory_params.merge({ :log_file => '/var/log/rsync.log' })
    end
    it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^log file\s*=\s*\/var\/log\/rsync.log$/)}
  end
end

{'fraction_non_alphanumeric': 0.158464342674869, 'fraction_numerical': 0.010480747322852585, 'mean_word_length': 3.485947879407256, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3379201', 'n_tokens_mistral': 3116, 'n_tokens_neox': 2996, 'n_words': 505}