Merge pull request #495 from puppetlabs/4.7.x

4.7.x
This commit is contained in:
Bryan Jen 2015-07-30 13:33:44 -07:00
commit 41a7297cb7
5 changed files with 125 additions and 157 deletions

View file

@ -1,22 +0,0 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
describe 'ensure_packages function', :unless => fact('osfamily') =~ /windows/i do
describe 'success' do
it 'ensure_packages a package' do
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
pp = <<-EOS
$a = "rake"
ensure_packages($a,{'provider' => 'gem'})
EOS
apply_manifest(pp, :expect_changes => true)
end
it 'ensures a package already declared'
it 'takes defaults arguments'
end
describe 'failure' do
it 'handles no arguments'
it 'handles non strings'
end
end

View file

@ -3,33 +3,13 @@ require 'spec_helper_acceptance'
describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do describe 'success' do
let(:facts_d) do include_context "with faked facts"
puppet_version = (on default, puppet('--version')).output.chomp context "when the FQDN is 'fakehost.localdomain'" do
if puppet_version < '4.0.0' && fact('is_pe', '--puppet') == "true"
if fact('osfamily') =~ /windows/i
if fact('kernelmajversion').to_f < 6.0
'c:/documents and settings/all users/application data/puppetlabs/facter/facts.d'
else
'c:/programdata/puppetlabs/facter/facts.d'
end
else
'/etc/puppetlabs/facter/facts.d'
end
else
'/etc/facter/facts.d'
end
end
after :each do
shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
end
before :each do before :each do
#no need to create on windows, pe creates by default fake_fact("fqdn", "fakehost.localdomain")
if fact('osfamily') !~ /windows/i
shell("mkdir -p '#{facts_d}'")
end
end end
it 'generates random alphanumeric strings' do it 'generates random alphanumeric strings' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-eos pp = <<-eos
$l = 10 $l = 10
$o = fqdn_rand_string($l) $o = fqdn_rand_string($l)
@ -41,7 +21,6 @@ describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(
end end
end end
it 'generates random alphanumeric strings with custom charsets' do it 'generates random alphanumeric strings with custom charsets' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-eos pp = <<-eos
$l = 10 $l = 10
$c = '0123456789' $c = '0123456789'
@ -54,7 +33,6 @@ describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(
end end
end end
it 'generates random alphanumeric strings with custom seeds' do it 'generates random alphanumeric strings with custom seeds' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-eos pp = <<-eos
$l = 10 $l = 10
$s = 'seed' $s = 'seed'
@ -67,7 +45,6 @@ describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(
end end
end end
it 'generates random alphanumeric strings with custom charsets and seeds' do it 'generates random alphanumeric strings with custom charsets and seeds' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-eos pp = <<-eos
$l = 10 $l = 10
$c = '0123456789' $c = '0123456789'
@ -81,6 +58,7 @@ describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(
end end
end end
end end
end
describe 'failure' do describe 'failure' do
it 'handles improper argument counts' it 'handles improper argument counts'
it 'handles non-numbers for length argument' it 'handles non-numbers for length argument'

View file

@ -3,33 +3,13 @@ require 'spec_helper_acceptance'
describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do describe 'success' do
let(:facts_d) do include_context "with faked facts"
puppet_version = (on default, puppet('--version')).output.chomp context "when the FQDN is 'fakehost.localdomain'" do
if puppet_version < '4.0.0' && fact('is_pe', '--puppet') == "true"
if fact('osfamily') =~ /windows/i
if fact('kernelmajversion').to_f < 6.0
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
else
'C:/ProgramData/PuppetLabs/facter/facts.d'
end
else
'/etc/puppetlabs/facter/facts.d'
end
else
'/etc/facter/facts.d'
end
end
after :each do
shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
end
before :each do before :each do
#No need to create on windows, PE creates by default fake_fact("fqdn", "fakehost.localdomain")
if fact('osfamily') !~ /windows/i
shell("mkdir -p '#{facts_d}'")
end
end end
it 'rotates arrays' do it 'rotates arrays' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-EOS pp = <<-EOS
$a = ['a','b','c','d'] $a = ['a','b','c','d']
$o = fqdn_rotate($a) $o = fqdn_rotate($a)
@ -41,7 +21,6 @@ describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact(
end end
end end
it 'rotates arrays with custom seeds' do it 'rotates arrays with custom seeds' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-EOS pp = <<-EOS
$a = ['a','b','c','d'] $a = ['a','b','c','d']
$s = 'seed' $s = 'seed'
@ -54,7 +33,6 @@ describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact(
end end
end end
it 'rotates strings' do it 'rotates strings' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-EOS pp = <<-EOS
$a = 'abcd' $a = 'abcd'
$o = fqdn_rotate($a) $o = fqdn_rotate($a)
@ -66,7 +44,6 @@ describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact(
end end
end end
it 'rotates strings with custom seeds' do it 'rotates strings with custom seeds' do
shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
pp = <<-EOS pp = <<-EOS
$a = 'abcd' $a = 'abcd'
$s = 'seed' $s = 'seed'
@ -79,6 +56,7 @@ describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact(
end end
end end
end end
end
describe 'failure' do describe 'failure' do
it 'handles improper argument counts' it 'handles improper argument counts'
it 'handles invalid arguments' it 'handles invalid arguments'

View file

@ -2,7 +2,7 @@
require 'spec_helper_acceptance' require 'spec_helper_acceptance'
# Windows and OS X do not have useful implementations of crypt(3) # Windows and OS X do not have useful implementations of crypt(3)
describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin']).include?(fact('operatingsystem')) do describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do
describe 'success' do describe 'success' do
it 'hashes passwords' do it 'hashes passwords' do
pp = <<-EOS pp = <<-EOS

View file

@ -32,3 +32,37 @@ def is_future_parser_enabled?
end end
return false return false
end end
RSpec.shared_context "with faked facts" do
let(:facts_d) do
puppet_version = (on default, puppet('--version')).output.chomp
if Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 && fact('is_pe', '--puppet') == "true"
if fact('osfamily') =~ /windows/i
if fact('kernelmajversion').to_f < 6.0
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
else
'C:/ProgramData/PuppetLabs/facter/facts.d'
end
else
'/etc/puppetlabs/facter/facts.d'
end
else
'/etc/facter/facts.d'
end
end
before :each do
#No need to create on windows, PE creates by default
if fact('osfamily') !~ /windows/i
shell("mkdir -p '#{facts_d}'")
end
end
after :each do
shell("rm -f '#{facts_d}/fqdn.txt'")
end
def fake_fact(name, value)
shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
end
end