Skip to content
Snippets Groups Projects
Select Git revision
  • 12dab8c2012c5896f8f22f51250bb05f440434b2
  • master default protected
  • main
  • update_github_actions
  • 144_rocky8_support
  • 195-update-pdk-to-300
  • 144-rocky8
  • add_test_github_test_workflow
  • pdk_2.4.0
  • fix_unclosed_let_block_in_defines_client_spec
  • validation_fixes
  • freeradius_3_0_21_config_updates
  • data_types
  • PrepareBuster
  • travis
  • 4.0.1
  • 4.0.0
  • 3.9.2
  • 3.9.1
  • 3.9.0
  • 3.8.2
  • 3.8.1
  • 3.8.0
  • 3.7.0
  • 3.6.0
  • 3.5.0
  • 3.4.3
  • 3.4.2
  • 3.4.1
  • 3.4.0
  • 3.3.0
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.3.1
35 results

radsniff.rb

  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    radsniff.rb 3.29 KiB
    require 'spec_helper'
    
    describe 'freeradius::radsniff' do
      on_supported_os.each do |os, os_facts|
        context "on #{os}" do
          include_context 'freeradius_with_utils'
    
          let(:facts) { os_facts }
    
          let(:params) do
            {
              options: 'radsniff cmd "line" options',
            }
          end
    
          if os_facts[:osfamily] =~ %r{^RedHat|Debian$}
            it do
              is_expected.to contain_service('radsniff')
                .with_ensure('running')
                .with_enable(true)
            end
          end
    
          case os_facts[:osfamily]
          when 'RedHat'
            it do
              is_expected.to contain_file('/etc/sysconfig/radsniff')
                .with_content(%r{RADSNIFF_OPTIONS="radsniff cmd \\"line\\" options"})
                .that_notifies('Service[radsniff]')
                .that_requires('Package[freeradius-utils]')
            end
    
            it do
              is_expected.to contain_systemd__unit_file('radsniff.service')
                .with_content(%r{^Pidfile=/var/run/radiusd/radsniff.pid$})
                .with_content(%r{^EnvironmentFile=/etc/sysconfig/radsniff$})
                .with_content(%r{^ExecStart=/usr/bin/radsniff -P /var/run/radiusd/radsniff.pid -d /etc/raddb $RADSNIFF_OPTIONS$})
                .that_notifies('Service[radsniff]')
            end
          when 'Debian'
            it do
              is_expected.to contain_file('/etc/defaults/radsniff')
                .with_content(%r{RADSNIFF_OPTIONS="radsniff cmd \\"line\\" options"})
                .that_notifies('Service[radsniff]')
                .that_requires('Package[freeradius-utils]')
            end
    
            it do
              is_expected.to contain_systemd__unit_file('radsniff.service')
                .with_content(%r{^Pidfile=/var/run/freeradius/radsniff.pid$})
                .with_content(%r{^EnvironmentFile=/etc/defaults/radsniff$})
                .with_content(%r{^ExecStart=/usr/bin/radsniff -P /var/run/freeradius/radsniff.pid -d /etc/freeradius $RADSNIFF_OPTIONS$})
                .that_notifies('Service[radsniff]')
            end
          else
            it do
              is_expected.to compile.and_raise_error(%r{freeradius::radsniff requires envfile to be explicitly set on this OS})
              is_expected.to compile.and_raise_error(%r{freeradius::radsniff requires pidfile to be explicitly set on this OS})
            end
          end
    
          context 'with envfile and pidfile set' do
            let(:params) do
              super().merge(
                envfile: '/test/env/file',
                pidfile: '/a/pid/file',
              )
            end
    
            if os_facts[:osfamily] !~ %r{^RedHat|Debian$}
              it do
                is_expected.to contain_service('radsniff')
                  .with_ensure('running')
                  .with_enable(true)
              end
            end
    
            it do
              is_expected.to contain_file('/test/env/file')
                .with_content(%r{RADSNIFF_OPTIONS="radsniff cmd \\"line\\" options"})
                .that_notifies('Service[radsniff]')
                .that_requires('Package[freeradius-utils]')
            end
    
            it do
              is_expected.to contain_systemd__unit_file('radsniff.service')
                .with_content(%r{^Pidfile=/a/pid/file$})
                .with_content(%r{^EnvironmentFile=/test/env/file$})
                .with_content(%r{^ExecStart=/usr/bin/radsniff -P /a/pid/file -d /etc/freeradius $RADSNIFF_OPTIONS$})
                .that_notifies('Service[radsniff]')
            end
          end
        end
      end
    end