Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the tests #67

Merged
merged 1 commit into from
Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 5 additions & 28 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,20 @@
$package_name = 'squid3'
$service_name = 'squid3'
$config = '/etc/squid3/squid.conf'
$config_user = 'root'
$config_group = 'root'
$access_log = 'daemon:/var/log/squid3/access.log squid'
$daemon_user = 'proxy'
$daemon_group = 'proxy'
}
/^(9.*)$/: {
$package_name = 'squid3'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://packages.debian.org/stretch/squid3 this is a transitional package that depends on squid. That makes it exactly the same as Ubuntu 16.04.

$service_name = 'squid'
$config = '/etc/squid/squid.conf'
$config_user = 'root'
$config_group = 'root'
$access_log = 'daemon:/var/log/squid/access.log squid'
$daemon_user = 'proxy'
$daemon_group = 'proxy'
}
/^16\.04$/: {
$package_name = 'squid'
$service_name = 'squid'
$config = '/etc/squid/squid.conf'
$config_user = 'root'
$config_group = 'root'
$access_log = 'daemon:/var/log/squid/access.log squid'
$daemon_user = 'proxy'
$daemon_group = 'proxy'
}
default: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to metadata.json we only supported explicitly written out versions. I've taken the most modern versions (Stretch and Xenial) and made them the default).

$package_name = 'squid'
$service_name = 'squid'
$config = '/etc/squid/squid.conf'
$config_user = 'root'
$config_group = 'squid'
$access_log = 'daemon:/var/log/squid/access.log squid'
$daemon_user = 'squid'
$daemon_group = 'squid'
}
}

$config_user = 'root'
$config_group = 'root'
$daemon_user = 'proxy'
$daemon_group = 'proxy'
}
'FreeBSD': {
$package_name = 'squid'
Expand Down
69 changes: 19 additions & 50 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,30 @@
facts
end

let(:squid_name) do
%w[jessie trusty].include?(facts[:lsbdistcodename]) ? 'squid3' : 'squid'
end

let(:etc_dir) do
facts[:operatingsystem] == 'FreeBSD' ? '/usr/local/etc' : '/etc'
end

let(:config_group) do
facts[:osfamily] == 'Debian' ? 'root' : 'squid'
end

context 'with defaults for all parameters' do
it { is_expected.to contain_class('squid') }
it { is_expected.to contain_class('squid::install') }
it { is_expected.to contain_class('squid::config') }
it { is_expected.to contain_class('squid::service') }
case facts[:operatingsystem]
when 'Debian'
context 'when on Debian' do
it { is_expected.to contain_package('squid3').with_ensure('present') }
it { is_expected.to contain_service('squid3').with_ensure('running') }
it { is_expected.to contain_concat('/etc/squid3/squid.conf').with_group('root') }
it { is_expected.to contain_concat('/etc/squid3/squid.conf').with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target('/etc/squid3/squid.conf') }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/squid3/access.log\s+squid$}) }
end
when 'Ubuntu'
case facts[:operatingsystemrelease]
when '14.04'
context 'when on Ubuntu 14.04' do
it { is_expected.to contain_package('squid3').with_ensure('present') }
it { is_expected.to contain_service('squid3').with_ensure('running') }
it { is_expected.to contain_concat('/etc/squid3/squid.conf').with_group('root') }
it { is_expected.to contain_concat('/etc/squid3/squid.conf').with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target('/etc/squid3/squid.conf') }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/squid3/access.log\s+squid$}) }
end
when '16.04'
context 'when on Ubuntu 16.04' do
it { is_expected.to contain_package('squid').with_ensure('present') }
it { is_expected.to contain_service('squid').with_ensure('running') }
it { is_expected.to contain_concat('/etc/squid/squid.conf').with_group('root') }
it { is_expected.to contain_concat('/etc/squid/squid.conf').with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target('/etc/squid/squid.conf') }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/squid/access.log\s+squid$}) }
end
end
when 'FreeBSD'
context 'when on FreeBSD' do
it { is_expected.to contain_package('squid').with_ensure('present') }
it { is_expected.to contain_service('squid').with_ensure('running') }
it { is_expected.to contain_concat('/usr/local/etc/squid/squid.conf').with_group('squid') }
it { is_expected.to contain_concat('/usr/local/etc/squid/squid.conf').with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target('/usr/local/etc/squid/squid.conf') }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/squid/access.log\s+squid$}) }
end
else
context 'when on any other supported OS' do
it { is_expected.to contain_package('squid').with_ensure('present') }
it { is_expected.to contain_service('squid').with_ensure('running') }
it { is_expected.to contain_concat('/etc/squid/squid.conf').with_group('squid') }
it { is_expected.to contain_concat('/etc/squid/squid.conf').with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target('/etc/squid/squid.conf') }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/squid/access.log\s+squid$}) }
end
end

it { is_expected.to contain_package(squid_name).with_ensure('present') }
it { is_expected.to contain_service(squid_name).with_ensure('running') }
it { is_expected.to contain_concat("#{etc_dir}/#{squid_name}/squid.conf").with_group(config_group) }
it { is_expected.to contain_concat("#{etc_dir}/#{squid_name}/squid.conf").with_owner('root') }
it { is_expected.to contain_concat_fragment('squid_header').with_target("#{etc_dir}/#{squid_name}/squid.conf") }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^access_log\s+daemon:/var/log/#{squid_name}/access.log\s+squid$}) }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^cache_mem\s+256 MB$}) }
it { is_expected.to contain_concat_fragment('squid_header').with_content(%r{^maximum_object_size_in_memory\s+512 KB$}) }
it { is_expected.to contain_concat_fragment('squid_header').without_content(%r{^memory_cache_shared}) }
Expand Down