1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
require 'spec_helper'
require 'puppet/settings'
describe "Defaults" do
describe ".default_diffargs" do
describe "on AIX" do
before(:each) do
allow(Facter).to receive(:value).with(:kernel).and_return("AIX")
end
describe "on 5.3" do
before(:each) do
allow(Facter).to receive(:value).with(:kernelmajversion).and_return("5300")
end
it "should be empty" do
expect(Puppet.default_diffargs).to eq("")
end
end
[ "",
nil,
"6300",
"7300",
].each do |kernel_version|
describe "on kernel version #{kernel_version.inspect}" do
before(:each) do
allow(Facter).to receive(:value).with(:kernelmajversion).and_return(kernel_version)
end
it "should be '-u'" do
expect(Puppet.default_diffargs).to eq("-u")
end
end
end
end
describe "on everything else" do
before(:each) do
allow(Facter).to receive(:value).with(:kernel).and_return("NOT_AIX")
end
it "should be '-u'" do
expect(Puppet.default_diffargs).to eq("-u")
end
end
end
describe 'strict' do
it 'should accept the valid value :off' do
expect {Puppet.settings[:strict] = 'off'}.to_not raise_exception
end
it 'should accept the valid value :warning' do
expect {Puppet.settings[:strict] = 'warning'}.to_not raise_exception
end
it 'should accept the valid value :error' do
expect {Puppet.settings[:strict] = 'error'}.to_not raise_exception
end
it 'should fail if given an invalid value' do
expect {Puppet.settings[:strict] = 'ignore'}.to raise_exception(/Invalid value 'ignore' for parameter strict\./)
end
end
describe '.default_digest_algorithm' do
it 'defaults to md5 when FIPS is not enabled' do
allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(false)
expect(Puppet.default_digest_algorithm).to eq('md5')
end
it 'defaults to sha256 when FIPS is enabled' do
allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(true)
expect(Puppet.default_digest_algorithm).to eq('sha256')
end
end
describe '.supported_checksum_types' do
it 'defaults to md5, sha256, sha384, sha512, sha224 when FIPS is not enabled' do
allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(false)
expect(Puppet.default_file_checksum_types).to eq(%w[md5 sha256 sha384 sha512 sha224])
end
it 'defaults to sha256, sha384, sha512, sha224 when FIPS is enabled' do
allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(true)
expect(Puppet.default_file_checksum_types).to eq(%w[sha256 sha384 sha512 sha224])
end
end
describe 'Puppet[:supported_checksum_types]' do
it 'defaults to md5, sha256, sha512, sha384, sha224' do
expect(Puppet.settings[:supported_checksum_types]).to eq(%w[md5 sha256 sha384 sha512 sha224])
end
it 'should raise an error on an unsupported checksum type' do
expect {
Puppet.settings[:supported_checksum_types] = %w[md5 foo]
}.to raise_exception ArgumentError,
/Invalid value 'foo' for parameter supported_checksum_types. Allowed values are/
end
it 'should not raise an error on setting a valid list of checksum types' do
Puppet.settings[:supported_checksum_types] = %w[sha256 md5lite mtime]
expect(Puppet.settings[:supported_checksum_types]).to eq(%w[sha256 md5lite mtime])
end
it 'raises when setting md5 in FIPS mode' do
allow(Puppet::Util::Platform).to receive(:fips_enabled?).and_return(true)
expect {
Puppet.settings[:supported_checksum_types] = %w[md5]
}.to raise_error(ArgumentError,
/Invalid value 'md5' for parameter supported_checksum_types. Allowed values are 'sha256'/)
end
end
describe 'manage_internal_file_permissions' do
describe 'on windows', :if => Puppet::Util::Platform.windows? do
it 'should default to false' do
expect(Puppet.settings[:manage_internal_file_permissions]).to be false
end
end
describe 'on non-windows', :if => ! Puppet::Util::Platform.windows? do
it 'should default to true' do
expect(Puppet.settings[:manage_internal_file_permissions]).to be true
end
end
end
describe 'basemodulepath' do
it 'includes the global and system modules on non-windows', :unless => Puppet::Util::Platform.windows? do
expect(
Puppet[:basemodulepath]
).to match(%r{.*/code/modules:/opt/puppetlabs/puppet/modules})
end
it 'includes global modules on windows', :if => Puppet::Util::Platform.windows? do
expect(
Puppet[:basemodulepath]
).to match(%r{.*/code/modules})
end
end
describe 'ordering' do
it 'issues a deprecation warning when set to title-hash' do
expect(Puppet).to receive(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering')
Puppet.settings[:ordering] = 'title-hash'
end
it 'issues a deprecation warning when set to random' do
expect(Puppet).to receive(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering')
Puppet.settings[:ordering] = 'random'
end
it 'does not issue a deprecation warning when set to manifest' do
expect(Puppet).not_to receive(:deprecation_warning).with('Setting ordering is deprecated.', 'setting-ordering')
Puppet.settings[:ordering] = 'manifest'
end
end
end
|