diff --git a/.fixtures.yml b/.fixtures.yml index 4a0c7be..6985c26 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,6 @@ fixtures: repositories: - stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" - remote_file: "git://github.com/lwf/puppet-remote_file.git" + stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git" + remote_file: "https://github.com/lwf/puppet-remote_file.git" symlinks: ca_cert: "#{source_dir}" diff --git a/manifests/update.pp b/manifests/update.pp index c8827bf..1566020 100644 --- a/manifests/update.pp +++ b/manifests/update.pp @@ -2,7 +2,7 @@ class ca_cert::update { include ::ca_cert::params - if $::osfamily == 'RedHat' { + if ($::osfamily == 'RedHat' and versioncmp($::operatingsystemrelease, '7') < 0) { exec { 'enable_ca_trust': command => 'update-ca-trust enable', logoutput => 'on_failure', diff --git a/metadata.json b/metadata.json index e892321..bd43ce6 100644 --- a/metadata.json +++ b/metadata.json @@ -12,24 +12,24 @@ { "operatingsystem": "RedHat", "operatingsystemrelease": [ - "5.0", - "6.0", - "7.0" + "5", + "6", + "7" ] }, { - "operatingsystem": "Suse", + "operatingsystem": "SLES", "operatingsystemrelease": [ - "10.0", - "11.0", - "12.0" + "10", + "11", + "12" ] }, { "operatingsystem": "OpenSuSE", "operatingsystemrelease": [ - "13.2", - "42.1" + "13", + "42" ] }, { @@ -41,10 +41,7 @@ ] }, { - "operatingsystem": "Archlinux", - "operatingsystemrelease": [ - "4.x" - ] + "operatingsystem": "Archlinux" } ], "requirements": [ diff --git a/spec/classes/ca_cert_spec.rb b/spec/classes/ca_cert_spec.rb index eff7d21..7628f2e 100644 --- a/spec/classes/ca_cert_spec.rb +++ b/spec/classes/ca_cert_spec.rb @@ -46,6 +46,7 @@ let :facts do { :osfamily => 'RedHat', + :operatingsystemrelease => '7.0' } end diff --git a/spec/classes/update_spec.rb b/spec/classes/update_spec.rb index 26dc47f..06e681f 100644 --- a/spec/classes/update_spec.rb +++ b/spec/classes/update_spec.rb @@ -1,81 +1,47 @@ require 'spec_helper' describe 'ca_cert::update', :type => :class do - - shared_examples 'compiles and includes params class' do - it { should compile } - it { should contain_class('ca_cert::params') } - end - - context "on a Debian based OS" do - let :facts do - { - :osfamily => 'Debian', - :operatingsystem => 'Ubuntu' - } - end - - it_behaves_like 'compiles and includes params class' do - end - it { is_expected.not_to contain_exec('enable_ca_trust') } - it { is_expected.to contain_exec('ca_cert_update').with( - :command => 'update-ca-certificates', - :refreshonly => true, - )} - - end - context "on a RedHat based OS" do - let :facts do - { - :osfamily => 'RedHat', - } - end - - it_behaves_like 'compiles and includes params class' do - end - it { is_expected.to contain_exec('enable_ca_trust').with( - :command => 'update-ca-trust enable', - ) } - it { is_expected.to contain_exec('ca_cert_update').with( - :command => 'update-ca-trust extract', - :refreshonly => true, - )} - - end - ['10','11'].each do |osmajrel| - context "on a Suse #{osmajrel} based OS" do - let :facts do - { - :osfamily => 'Suse', - :operatingsystemmajrelease => "#{osmajrel}", - } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts end - it_behaves_like 'compiles and includes params class' do + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('ca_cert::params') } + + case facts[:osfamily] + when 'Debian' + it { is_expected.not_to contain_exec('enable_ca_trust') } + it { is_expected.to contain_exec('ca_cert_update').with( + :command => 'update-ca-certificates', + :refreshonly => true, + )} + when 'RedHat' + if facts[:operatingsystemrelease] == '7.0' + it { is_expected.not_to contain_exec('enable_ca_trust') } + else + it { is_expected.to contain_exec('enable_ca_trust').with_command('update-ca-trust enable') } + end + it { is_expected.to contain_exec('ca_cert_update').with( + :command => 'update-ca-trust extract', + :refreshonly => true, + )} + when 'Suse' + it { is_expected.not_to contain_exec('enable_ca_trust') } + case facts[:operatingsystemmajrelease] + when '10','11' + it { is_expected.to contain_exec('ca_cert_update').with( + :command => 'c_rehash', + :refreshonly => true, + )} + when '12','13','42' + it { is_expected.to contain_exec('ca_cert_update').with( + :command => 'update-ca-certificates', + :refreshonly => true, + )} + end end - it { is_expected.not_to contain_exec('enable_ca_trust') } - it { is_expected.to contain_exec('ca_cert_update').with( - :command => 'c_rehash', - :refreshonly => true, - )} - end end - context "on a Suse 12 based OS" do - let :facts do - { - :osfamily => 'Suse', - :operatingsystemmajrelease => '12', - } - end - - it_behaves_like 'compiles and includes params class' do - end - it { is_expected.not_to contain_exec('enable_ca_trust') } - it { is_expected.to contain_exec('ca_cert_update').with( - :command => 'update-ca-certificates', - :refreshonly => true, - )} - - end end diff --git a/spec/defines/ca_spec.rb b/spec/defines/ca_spec.rb index 7ec051a..a6e488e 100644 --- a/spec/defines/ca_spec.rb +++ b/spec/defines/ca_spec.rb @@ -55,6 +55,7 @@ { :osfamily => 'RedHat', :operatingsystem => 'RedHat', + :operatingsystemrelease => '7.0' } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 44a5538..501ecc0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,6 @@ require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' +include RspecPuppetFacts RSpec.configure do |c| c.before :each do