summaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
Diffstat (limited to 'spec/acceptance')
-rwxr-xr-xspec/acceptance/abs_spec.rb4
-rwxr-xr-xspec/acceptance/any2array_spec.rb4
-rwxr-xr-xspec/acceptance/bool2num_spec.rb12
-rwxr-xr-xspec/acceptance/ceiling_spec.rb39
-rwxr-xr-xspec/acceptance/concat_spec.rb22
-rwxr-xr-xspec/acceptance/count_spec.rb4
-rwxr-xr-xspec/acceptance/ensure_packages_spec.rb2
-rwxr-xr-xspec/acceptance/ensure_resource_spec.rb2
-rw-r--r--spec/acceptance/fqdn_rand_string_spec.rb60
-rwxr-xr-xspec/acceptance/fqdn_rotate_spec.rb2
-rwxr-xr-xspec/acceptance/member_spec.rb28
-rwxr-xr-xspec/acceptance/merge_spec.rb4
-rw-r--r--spec/acceptance/pw_hash_spec.rb34
-rwxr-xr-xspec/acceptance/type_spec.rb2
-rwxr-xr-xspec/acceptance/validate_cmd_spec.rb6
-rwxr-xr-xspec/acceptance/values_spec.rb6
-rwxr-xr-xspec/acceptance/zip_spec.rb28
17 files changed, 230 insertions, 29 deletions
diff --git a/spec/acceptance/abs_spec.rb b/spec/acceptance/abs_spec.rb
index 8e05642..6e41e2f 100755
--- a/spec/acceptance/abs_spec.rb
+++ b/spec/acceptance/abs_spec.rb
@@ -7,7 +7,7 @@ describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
pp = <<-EOS
$input = '-34.56'
$output = abs($input)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
@@ -19,7 +19,7 @@ describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
pp = <<-EOS
$input = -34.56
$output = abs($input)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb
index 467d6af..18ea4cd 100755
--- a/spec/acceptance/any2array_spec.rb
+++ b/spec/acceptance/any2array_spec.rb
@@ -25,7 +25,7 @@ describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
EOS
apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/Notice: Output: testarray/)
+ expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
end
end
@@ -42,7 +42,7 @@ describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
EOS
apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/Notice: Output: testarray/)
+ expect(r.stdout).to match(/Notice: Output: (\[|)test(,\s|)array(\]|)/)
end
end
end
diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb
index 7a70311..52ff75b 100755
--- a/spec/acceptance/bool2num_spec.rb
+++ b/spec/acceptance/bool2num_spec.rb
@@ -4,11 +4,11 @@ require 'spec_helper_acceptance'
describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
describe 'success' do
['false', 'f', '0', 'n', 'no'].each do |bool|
- it 'should convert a given boolean, #{bool}, to 0' do
+ it "should convert a given boolean, #{bool}, to 0" do
pp = <<-EOS
- $input = #{bool}
+ $input = "#{bool}"
$output = bool2num($input)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
@@ -18,11 +18,11 @@ describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('op
end
['true', 't', '1', 'y', 'yes'].each do |bool|
- it 'should convert a given boolean, #{bool}, to 1' do
+ it "should convert a given boolean, #{bool}, to 1" do
pp = <<-EOS
- $input = #{bool}
+ $input = "#{bool}"
$output = bool2num($input)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
diff --git a/spec/acceptance/ceiling_spec.rb b/spec/acceptance/ceiling_spec.rb
new file mode 100755
index 0000000..557986e
--- /dev/null
+++ b/spec/acceptance/ceiling_spec.rb
@@ -0,0 +1,39 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'ceilings floats' do
+ pp = <<-EOS
+ $a = 12.8
+ $b = 13
+ $o = ceiling($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Notice: output correct/)
+ end
+ end
+ it 'ceilings integers' do
+ pp = <<-EOS
+ $a = 7
+ $b = 7
+ $o = ceiling($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Notice: output correct/)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers'
+ end
+end
diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb
index 7bda365..06b649f 100755
--- a/spec/acceptance/concat_spec.rb
+++ b/spec/acceptance/concat_spec.rb
@@ -14,5 +14,27 @@ describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
apply_manifest(pp, :catch_failures => true)
end
+ it 'should concat arrays and primitives to array' do
+ pp = <<-EOS
+ $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
+ validate_array($output)
+ if size($output) != 9 {
+ fail("${output} should have 9 elements.")
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
+ it 'should concat multiple arrays to one' do
+ pp = <<-EOS
+ $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
+ validate_array($output)
+ if size($output) != 9 {
+ fail("${output} should have 9 elements.")
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
end
end
diff --git a/spec/acceptance/count_spec.rb b/spec/acceptance/count_spec.rb
index 51a40ba..fe7ca9d 100755
--- a/spec/acceptance/count_spec.rb
+++ b/spec/acceptance/count_spec.rb
@@ -7,7 +7,7 @@ describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
pp = <<-EOS
$input = [1,2,3,4]
$output = count($input)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
@@ -19,7 +19,7 @@ describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
pp = <<-EOS
$input = [1,1,1,2]
$output = count($input, 1)
- notify { $output: }
+ notify { "$output": }
EOS
apply_manifest(pp, :catch_failures => true) do |r|
diff --git a/spec/acceptance/ensure_packages_spec.rb b/spec/acceptance/ensure_packages_spec.rb
index 12da0cd..aedcfb5 100755
--- a/spec/acceptance/ensure_packages_spec.rb
+++ b/spec/acceptance/ensure_packages_spec.rb
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+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", }')
diff --git a/spec/acceptance/ensure_resource_spec.rb b/spec/acceptance/ensure_resource_spec.rb
index 2aad243..1cee53d 100755
--- a/spec/acceptance/ensure_resource_spec.rb
+++ b/spec/acceptance/ensure_resource_spec.rb
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-describe 'ensure_resource function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'ensure_resource function', :unless => fact('osfamily') =~ /windows/i do
describe 'success' do
it 'ensure_resource a package' do
apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
diff --git a/spec/acceptance/fqdn_rand_string_spec.rb b/spec/acceptance/fqdn_rand_string_spec.rb
new file mode 100644
index 0000000..8fe1a69
--- /dev/null
+++ b/spec/acceptance/fqdn_rand_string_spec.rb
@@ -0,0 +1,60 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ let(:facts_d) do
+ if 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
+ #no need to create on windows, pe creates by default
+ if fact('osfamily') !~ /windows/i
+ shell("mkdir -p '#{facts_d}'")
+ end
+ end
+ it 'generates random alphanumeric strings' do
+ shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
+ pp = <<-eos
+ $l = 10
+ $o = fqdn_rand_string($l)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ eos
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rand_string is "7oDp0KOr1b"/)
+ end
+ end
+ it 'generates random alphanumeric strings with custom seeds' do
+ shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
+ pp = <<-eos
+ $l = 10
+ $s = 'seed'
+ $o = fqdn_rand_string($l, undef, $s)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ eos
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rand_string is "3HS4mbuI3E"/)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers for length argument'
+ end
+end
diff --git a/spec/acceptance/fqdn_rotate_spec.rb b/spec/acceptance/fqdn_rotate_spec.rb
index c37b35a..753068b 100755
--- a/spec/acceptance/fqdn_rotate_spec.rb
+++ b/spec/acceptance/fqdn_rotate_spec.rb
@@ -21,7 +21,7 @@ describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact(
after :each do
shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
end
- before :all do
+ before :each do
#No need to create on windows, PE creates by default
if fact('osfamily') !~ /windows/i
shell("mkdir -p '#{facts_d}'")
diff --git a/spec/acceptance/member_spec.rb b/spec/acceptance/member_spec.rb
index b467dbb..fe75a07 100755
--- a/spec/acceptance/member_spec.rb
+++ b/spec/acceptance/member_spec.rb
@@ -2,6 +2,13 @@
require 'spec_helper_acceptance'
describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ shared_examples 'item found' do
+ it 'should output correctly' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Notice: output correct/)
+ end
+ end
+ end
describe 'success' do
it 'members arrays' do
pp = <<-EOS
@@ -18,8 +25,29 @@ describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
expect(r.stdout).to match(/Notice: output correct/)
end
end
+ describe 'members array of integers' do
+ it_should_behave_like 'item found' do
+ let(:pp) { <<-EOS
+ if member( [1,2,3,4], 4 ){
+ notify { 'output correct': }
+ }
+ EOS
+ }
+ end
+ end
+ describe 'members of mixed array' do
+ it_should_behave_like 'item found' do
+ let(:pp) { <<-EOS
+ if member( ['a','4',3], 'a' ){
+ notify { 'output correct': }
+}
+ EOS
+ }
+ end
+ end
it 'members arrays without members'
end
+
describe 'failure' do
it 'handles improper argument counts'
end
diff --git a/spec/acceptance/merge_spec.rb b/spec/acceptance/merge_spec.rb
index a60e784..227b994 100755
--- a/spec/acceptance/merge_spec.rb
+++ b/spec/acceptance/merge_spec.rb
@@ -14,9 +14,9 @@ describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
EOS
apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/merge\[one\] is "1"/)
+ expect(r.stdout).to match(/merge\[one\] is ("1"|1)/)
expect(r.stdout).to match(/merge\[two\] is "dos"/)
- expect(r.stdout).to match(/merge\[three\] is {"five"=>"5"}/)
+ expect(r.stdout).to match(/merge\[three\] is {"five"=>("5"|5)}/)
end
end
end
diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb
new file mode 100644
index 0000000..eddb782
--- /dev/null
+++ b/spec/acceptance/pw_hash_spec.rb
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+# 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 'success' do
+ it 'hashes passwords' do
+ pp = <<-EOS
+ $o = pw_hash('password', 'sha-512', 'salt')
+ notice(inline_template('pw_hash is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."/)
+ end
+ end
+
+ it 'returns nil if no password is provided' do
+ pp = <<-EOS
+ $o = pw_hash('', 'sha-512', 'salt')
+ notice(inline_template('pw_hash is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/pw_hash is nil/)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles less than three arguments'
+ it 'handles more than three arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb
index 0043aad..67e3248 100755
--- a/spec/acceptance/type_spec.rb
+++ b/spec/acceptance/type_spec.rb
@@ -1,7 +1,7 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-describe 'type function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do
describe 'success' do
it 'types arrays' do
pp = <<-EOS
diff --git a/spec/acceptance/validate_cmd_spec.rb b/spec/acceptance/validate_cmd_spec.rb
index 385676d..5ac66fd 100755
--- a/spec/acceptance/validate_cmd_spec.rb
+++ b/spec/acceptance/validate_cmd_spec.rb
@@ -37,10 +37,12 @@ describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact
} else {
$two = '/bin/aoeu'
}
- validate_cmd($one,$two,"aoeu is dvorak)
+ validate_cmd($one,$two,"aoeu is dvorak")
EOS
- expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/aoeu is dvorak/)
+ apply_manifest(pp, :expect_failures => true) do |output|
+ expect(output.stderr).to match(/aoeu is dvorak/)
+ end
end
end
describe 'failure' do
diff --git a/spec/acceptance/values_spec.rb b/spec/acceptance/values_spec.rb
index 7ef956e..a2eff32 100755
--- a/spec/acceptance/values_spec.rb
+++ b/spec/acceptance/values_spec.rb
@@ -13,8 +13,12 @@ describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
$output = values($arg)
notice(inline_template('<%= @output.sort.inspect %>'))
EOS
+ if is_future_parser_enabled?
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/)
+ else
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
+ end
- expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/)
end
end
describe 'failure' do
diff --git a/spec/acceptance/zip_spec.rb b/spec/acceptance/zip_spec.rb
index 0e924e8..139079e 100755
--- a/spec/acceptance/zip_spec.rb
+++ b/spec/acceptance/zip_spec.rb
@@ -11,8 +11,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
$output = zip($one,$two)
notice(inline_template('<%= @output.inspect %>'))
EOS
-
- expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/)
+ if is_future_parser_enabled?
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/)
+ else
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/)
+ end
end
it 'zips two arrays of numbers & bools together' do
pp = <<-EOS
@@ -21,8 +24,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
$output = zip($one,$two)
notice(inline_template('<%= @output.inspect %>'))
EOS
-
- expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/)
+ if is_future_parser_enabled?
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/)
+ else
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/)
+ end
end
it 'zips two arrays of numbers together and flattens them' do
# XXX This only tests the argument `true`, even though the following are valid:
@@ -35,8 +41,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
$output = zip($one,$two,true)
notice(inline_template('<%= @output.inspect %>'))
EOS
-
- expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/)
+ if is_future_parser_enabled?
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/)
+ else
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/)
+ end
end
it 'handles unmatched length' do
# XXX Is this expected behavior?
@@ -46,8 +55,11 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati
$output = zip($one,$two)
notice(inline_template('<%= @output.inspect %>'))
EOS
-
- expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/)
+ if is_future_parser_enabled?
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/)
+ else
+ expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/)
+ end
end
end
describe 'failure' do