Commit 3591a106 authored by Jerry Nicholls's avatar Jerry Nicholls
Browse files

Applied the suggestions on the PR to the official repo.

parent 1c8be614
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ define freeradius::attr (
  Freeradius::Ensure $ensure             = present,
  Optional[String] $key                  = 'User-Name',
  Optional[String] $prefix               = 'filter',
  Optional[Enum['yes', 'no']] $relaxed = undef,
  Optional[Freeradius::Boolean] $relaxed = undef,
) {
  $fr_package          = $::freeradius::params::fr_package
  $fr_service          = $::freeradius::params::fr_service
+28 −63
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ describe 'freeradius::attr' do

  let(:title) { 'test' }

  context 'No specific relaxed value' do
  let(:params) do
    {
      source: 'puppet:///modules/test/path/to/file',
@@ -27,64 +26,30 @@ describe 'freeradius::attr' do
  it do
    is_expected.to contain_concat__fragment('attr-test')
      .with_content(%r{^attr_filter filter.test {\n\s+key = "\%{User-Name}"\n\s+filename = \${modconfdir}/\${\.:name}/test\n}})
      .without_content(%r{^\s+relaxed\s+.*$})
      .with_order('20')
      .with_target('/etc/raddb/mods-available/attr_filter')
  end
  end

  context 'relaxed = no' do
  context 'with relaxed = no' do
    let(:params) do
      {
        source: 'puppet:///modules/test/path/to/file',
        relaxed: 'no',
      }
    end

    it do
      is_expected.to contain_file('/etc/raddb/mods-config/attr_filter/test')
        .that_notifies('Service[radiusd]')
        .that_requires('Group[radiusd]')
        .that_requires('Package[freeradius]')
        .with_ensure('present')
        .with_group('radiusd')
        .with_mode('0640')
        .with_owner('root')
        .with_source('puppet:///modules/test/path/to/file')
      super().merge(relaxed: 'no')
    end

    it do
      is_expected.to contain_concat__fragment('attr-test')
        .with_content(%r{^attr_filter filter.test {\n\s+key = "\%{User-Name}"\n\s+filename = \${modconfdir}/\${\.:name}/test\n\s+relaxed = no\n}})
        .with_order('20')
        .with_target('/etc/raddb/mods-available/attr_filter')
        .with_content(%r{^\s+relaxed\s+=\s+no$})
    end
  end

  context 'relaxed = yes' do
  context 'with relaxed = yes' do
    let(:params) do
      {
        source: 'puppet:///modules/test/path/to/file',
        relaxed: 'yes',
      }
    end

    it do
      is_expected.to contain_file('/etc/raddb/mods-config/attr_filter/test')
        .that_notifies('Service[radiusd]')
        .that_requires('Group[radiusd]')
        .that_requires('Package[freeradius]')
        .with_ensure('present')
        .with_group('radiusd')
        .with_mode('0640')
        .with_owner('root')
        .with_source('puppet:///modules/test/path/to/file')
      super().merge(relaxed: 'yes')
    end

    it do
      is_expected.to contain_concat__fragment('attr-test')
        .with_content(%r{^attr_filter filter.test {\n\s+key = "\%{User-Name}"\n\s+filename = \${modconfdir}/\${\.:name}/test\n\s+relaxed = yes\n}})
        .with_order('20')
        .with_target('/etc/raddb/mods-available/attr_filter')
        .with_content(%r{^\s+relaxed\s+=\s+yes$})
    end
  end
end