diff --git a/.fixtures.yml b/.fixtures.yml index 965e41d..4873cd3 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -2,4 +2,4 @@ fixtures: repositories: stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" - puppet_archive: "https://github.com/voxpupuli/puppet-archive.git" + archive: "https://github.com/voxpupuli/puppet-archive.git" diff --git a/spec/classes/ca_cert_spec.rb b/spec/classes/ca_cert_spec.rb index 73d667b..bb54d64 100644 --- a/spec/classes/ca_cert_spec.rb +++ b/spec/classes/ca_cert_spec.rb @@ -1,10 +1,11 @@ require 'spec_helper' -describe 'ca_cert', type: :class do - on_supported_os.each do |os, facts| - case facts[:os]['family'] +describe 'ca_cert' do + on_supported_os.each do |os, os_facts| + case os_facts[:os]['family'] when 'Debian' trusted_cert_dir = '/usr/local/share/ca-certificates' + update_cmd = 'update-ca-certificates' when 'RedHat' trusted_cert_dir = '/etc/pki/ca-trust/source/anchors' update_cmd = 'update-ca-trust extract' @@ -16,15 +17,12 @@ update_cmd = 'update-ca-certificates' end - cert_dir_group = 'root' if cert_dir_group.nil? - cert_dir_mode = '0755' if cert_dir_mode.nil? - update_cmd = 'update-ca-certificates' if update_cmd.nil? - package_name = 'ca-certificates' if package_name.nil? + package_name = 'ca-certificates' context "on #{os}" do - let(:facts) { facts } + let(:facts) { os_facts } - it { is_expected.to compile } + it { is_expected.to compile.with_all_deps } it do is_expected.to contain_file('trusted_certs').only_with( @@ -32,8 +30,8 @@ 'ensure' => 'directory', 'path' => trusted_cert_dir, 'owner' => 'root', - 'group' => cert_dir_group, - 'mode' => cert_dir_mode, + 'group' => 'root', + 'mode' => '0755', 'purge' => false, 'recurse' => false, 'notify' => 'Exec[ca_cert_update]', diff --git a/spec/defines/ca_spec.rb b/spec/defines/ca_spec.rb index ee5d8d3..974726c 100644 --- a/spec/defines/ca_spec.rb +++ b/spec/defines/ca_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'ca_cert::ca', type: :define do +describe 'ca_cert::ca' do let(:title) { 'Globalsign_Org_Intermediate' } let(:pre_condition) do 'class {"ca_cert": @@ -8,14 +8,14 @@ }' end - on_supported_os.sort.each do |os, facts| + on_supported_os.sort.each do |os, os_facts| # define os specific defaults - case facts[:os]['family'] + case os_facts[:os]['family'] when 'Debian' trusted_cert_dir = '/usr/local/share/ca-certificates' when 'RedHat' trusted_cert_dir = '/etc/pki/ca-trust/source/anchors' - distrusted_cert_dir = if facts[:os]['release']['major'] < '9' + distrusted_cert_dir = if os_facts[:os]['release']['major'] < '9' '/etc/pki/ca-trust/source/blacklist' else '/etc/pki/ca-trust/source/blocklist' @@ -26,15 +26,16 @@ when 'Suse' trusted_cert_dir = '/etc/pki/trust/anchors' distrusted_cert_dir = '/etc/pki/trust/blacklist' + else + distrusted_cert_dir = '' end - ca_file_extension = 'crt' if ca_file_extension.nil? - ca_file_group = 'root' if ca_file_group.nil? - ca_file_mode = '0644' if ca_file_mode.nil? - distrusted_cert_dir = '' if distrusted_cert_dir.nil? + ca_file_extension = 'crt' + ca_file_group = 'root' + ca_file_mode = '0644' describe "on #{os}" do - let(:facts) { facts } + let(:facts) { os_facts } context 'with default values for parameters' do it { is_expected.to compile.and_raise_error(%r{Either `source` or `content` is required}) } @@ -100,7 +101,7 @@ it { is_expected.not_to contain_archive("#{distrusted_cert_dir}/#{title}.#{ca_file_extension}") } - case facts[:os]['family'] + case os_facts[:os]['family'] when 'Debian' it { is_expected.to contain_exec("trust ca #{title}.#{ca_file_extension}") } it { is_expected.not_to contain_file("#{distrusted_cert_dir}/#{title}.#{ca_file_extension}") } @@ -121,7 +122,7 @@ context 'with ensure set to "distrusted" and no source or content' do let(:params) { { ensure: 'distrusted' } } - case facts[:os]['family'] + case os_facts[:os]['family'] when 'Debian' it { is_expected.to contain_exec("distrust ca #{title}.#{ca_file_extension}") } it { is_expected.not_to contain_archive("#{distrusted_cert_dir}/#{title}.#{ca_file_extension}") } @@ -134,7 +135,7 @@ context 'with ensure set to "distrusted" and valid source' do let(:params) { { ensure: 'distrusted', source: 'puppet:///testing.crt' } } - case facts[:os]['family'] + case os_facts[:os]['family'] when 'Debian' it { is_expected.to contain_exec("distrust ca #{title}.#{ca_file_extension}") } it { is_expected.not_to contain_archive("#{distrusted_cert_dir}/#{title}.#{ca_file_extension}") }