summaryrefslogtreecommitdiff
path: root/spec/acceptance
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
committervarac <varacanero@zeromail.org>2017-01-13 12:41:58 +0100
commit066c08f8362d53f0f30897cb8710d11260c726ea (patch)
treea6369eecd88bb731fe413d0bbc8af73d74d1f447 /spec/acceptance
parent71123634744b9fe2ec7d6a3e38e9789fd84801e3 (diff)
parentb65dd1f45d10e10e45455358aeabb29167990e2c (diff)
Merge remote-tracking branch 'origin/master' into leap_master
Diffstat (limited to 'spec/acceptance')
-rwxr-xr-xspec/acceptance/anchor_spec.rb26
-rwxr-xr-xspec/acceptance/ceiling_spec.rb39
-rwxr-xr-xspec/acceptance/clamp_spec.rb40
-rwxr-xr-xspec/acceptance/concat_spec.rb14
-rw-r--r--spec/acceptance/deprecation_spec.rb102
-rwxr-xr-xspec/acceptance/empty_spec.rb14
-rwxr-xr-xspec/acceptance/ensure_packages_spec.rb22
-rwxr-xr-xspec/acceptance/ensure_resource_spec.rb20
-rw-r--r--spec/acceptance/fqdn_rand_string_spec.rb66
-rwxr-xr-xspec/acceptance/fqdn_rotate_spec.rb79
-rw-r--r--spec/acceptance/is_a_spec.rb30
-rwxr-xr-xspec/acceptance/is_ipv4_address_spec.rb52
-rwxr-xr-xspec/acceptance/is_ipv6_address_spec.rb66
-rwxr-xr-xspec/acceptance/is_string_spec.rb11
-rw-r--r--spec/acceptance/loadjson_spec.rb52
-rw-r--r--spec/acceptance/loadyaml_spec.rb23
-rw-r--r--spec/acceptance/nodesets/centos-59-x64.yml10
-rw-r--r--spec/acceptance/nodesets/centos-6-vcloud.yml15
-rw-r--r--spec/acceptance/nodesets/centos-64-x64-pe.yml12
-rw-r--r--spec/acceptance/nodesets/centos-64-x64.yml10
-rw-r--r--spec/acceptance/nodesets/centos-65-x64.yml10
-rw-r--r--spec/acceptance/nodesets/centos-7-x64.yml10
-rw-r--r--spec/acceptance/nodesets/debian-8-x64.yml10
-rw-r--r--spec/acceptance/nodesets/default.yml12
-rw-r--r--spec/acceptance/nodesets/docker/centos-7.yml12
-rw-r--r--spec/acceptance/nodesets/docker/debian-8.yml11
-rw-r--r--spec/acceptance/nodesets/docker/ubuntu-14.04.yml12
-rw-r--r--spec/acceptance/nodesets/fedora-18-x64.yml10
-rw-r--r--spec/acceptance/nodesets/sles-11-x64.yml10
-rw-r--r--spec/acceptance/nodesets/ubuntu-server-10044-x64.yml10
-rw-r--r--spec/acceptance/nodesets/ubuntu-server-12042-x64.yml10
-rw-r--r--spec/acceptance/nodesets/ubuntu-server-1404-x64.yml11
-rw-r--r--spec/acceptance/nodesets/windows-2003-i386.yml26
-rw-r--r--spec/acceptance/nodesets/windows-2003-x86_64.yml26
-rw-r--r--spec/acceptance/nodesets/windows-2008-x86_64.yml26
-rw-r--r--spec/acceptance/nodesets/windows-2008r2-x86_64.yml26
-rw-r--r--spec/acceptance/nodesets/windows-2012-x86_64.yml26
-rw-r--r--spec/acceptance/nodesets/windows-2012r2-x86_64.yml26
-rwxr-xr-xspec/acceptance/parsejson_spec.rb23
-rwxr-xr-xspec/acceptance/parseyaml_spec.rb25
-rw-r--r--spec/acceptance/pw_hash_spec.rb34
-rwxr-xr-xspec/acceptance/try_get_value_spec.rb47
-rwxr-xr-xspec/acceptance/union_spec.rb5
-rwxr-xr-xspec/acceptance/validate_array_spec.rb16
-rwxr-xr-xspec/acceptance/validate_bool_spec.rb16
-rwxr-xr-xspec/acceptance/validate_hash_spec.rb16
-rwxr-xr-xspec/acceptance/validate_string_spec.rb7
47 files changed, 819 insertions, 357 deletions
diff --git a/spec/acceptance/anchor_spec.rb b/spec/acceptance/anchor_spec.rb
new file mode 100755
index 0000000..5bc2bbb
--- /dev/null
+++ b/spec/acceptance/anchor_spec.rb
@@ -0,0 +1,26 @@
+require 'spec_helper_acceptance'
+
+describe 'anchor type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'should effect proper chaining of resources' do
+ pp = <<-EOS
+ class anchored {
+ anchor { 'anchored::begin': }
+ ~> anchor { 'anchored::end': }
+ }
+
+ class anchorrefresh {
+ notify { 'first': }
+ ~> class { 'anchored': }
+ ~> anchor { 'final': }
+ }
+
+ include anchorrefresh
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Anchor\[final\]: Triggered 'refresh'/)
+ end
+ end
+ end
+end
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/clamp_spec.rb b/spec/acceptance/clamp_spec.rb
new file mode 100755
index 0000000..0189258
--- /dev/null
+++ b/spec/acceptance/clamp_spec.rb
@@ -0,0 +1,40 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'clamp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'clamps list of values' do
+ pp = <<-EOS
+ $x = 17
+ $y = 225
+ $z = 155
+ $o = clamp($x, $y, $z)
+ if $o == $z {
+ notify { 'output correct': }
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Notice: output correct/)
+ end
+ end
+ it 'clamps array of values' do
+ pp = <<-EOS
+ $a = [7, 19, 66]
+ $b = 19
+ $o = clamp($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 no arguments'
+ end
+end
diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb
index 06b649f..c472db6 100755
--- a/spec/acceptance/concat_spec.rb
+++ b/spec/acceptance/concat_spec.rb
@@ -36,5 +36,19 @@ describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
apply_manifest(pp, :catch_failures => true)
end
+ it 'should concat hash arguments' do
+ pp = <<-EOS
+ $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
+ validate_array($output)
+ if size($output) != 2 {
+ fail("${output} should have 2 elements.")
+ }
+ if $output[1] != {"c" => "d", "e" => "f"} {
+ fail("${output} does not have the expected hash for the second element.")
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
end
end
diff --git a/spec/acceptance/deprecation_spec.rb b/spec/acceptance/deprecation_spec.rb
new file mode 100644
index 0000000..7a0b34c
--- /dev/null
+++ b/spec/acceptance/deprecation_spec.rb
@@ -0,0 +1,102 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'deprecation function' do
+
+ if fact('operatingsystem') == 'windows'
+ test_file = 'C:/deprecation'
+ else
+ test_file = "/tmp/deprecation"
+ end
+
+ # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
+ add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
+ remove_file_manifest = "file { '#{test_file}': ensure => absent }"
+
+ before :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ context 'with --strict=error', if: get_puppet_version =~ /^4/ do
+ before :all do
+ @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it "should return an error" do
+ expect(@result.exit_code).to eq(1)
+ end
+
+ it "should show the error message" do
+ expect(@result.stderr).to match(/deprecation. key. message/)
+ end
+
+ describe file("#{test_file}") do
+ it { is_expected.not_to be_file }
+ end
+ end
+
+ context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
+ before :all do
+ @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it "should not return an error" do
+ expect(@result.exit_code).to eq(0)
+ end
+
+ it "should show the error message" do
+ expect(@result.stderr).to match(/Warning: message/)
+ end
+
+ describe file("#{test_file}") do
+ it { is_expected.to be_file }
+ end
+ end
+
+ context 'with --strict=off', if: get_puppet_version =~ /^4/ do
+ before :all do
+ @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it "should not return an error" do
+ expect(@result.exit_code).to eq(0)
+ end
+
+ it "should not show the error message" do
+ expect(@result.stderr).not_to match(/Warning: message/)
+ end
+
+ describe file("#{test_file}") do
+ it { is_expected.to be_file }
+ end
+ end
+
+ context 'puppet 3 test', if: get_puppet_version =~ /^3/ do
+ before :all do
+ @result = on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
+ end
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it "should return a deprecation error" do
+ expect(@result.stderr).to match(/Warning: message/)
+ end
+ it "should pass without error" do
+ expect(@result.exit_code).to eq(0)
+ end
+ end
+
+end
diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb
index 8b46aac..2d4df90 100755
--- a/spec/acceptance/empty_spec.rb
+++ b/spec/acceptance/empty_spec.rb
@@ -31,6 +31,20 @@ describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
expect(r.stdout).to match(/Notice: output correct/)
end
end
+ it 'handles numerical values' do
+ pp = <<-EOS
+ $a = 7
+ $b = false
+ $o = empty($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'
diff --git a/spec/acceptance/ensure_packages_spec.rb b/spec/acceptance/ensure_packages_spec.rb
deleted file mode 100755
index aedcfb5..0000000
--- a/spec/acceptance/ensure_packages_spec.rb
+++ /dev/null
@@ -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
diff --git a/spec/acceptance/ensure_resource_spec.rb b/spec/acceptance/ensure_resource_spec.rb
index 1cee53d..93f25dd 100755
--- a/spec/acceptance/ensure_resource_spec.rb
+++ b/spec/acceptance/ensure_resource_spec.rb
@@ -1,18 +1,26 @@
#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
-describe 'ensure_resource function', :unless => fact('osfamily') =~ /windows/i do
+describe 'ensure_resource function' do
describe 'success' do
- it 'ensure_resource a package' do
- apply_manifest('package { "rake": ensure => absent, provider => "gem", }')
+ it 'ensures a resource already declared' do
+ apply_manifest('')
pp = <<-EOS
- $a = "rake"
- ensure_resource('package', $a, {'provider' => 'gem'})
+ notify { "test": loglevel => 'err' }
+ ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+ EOS
+
+ apply_manifest(pp, :expect_changes => true)
+ end
+
+ it 'ensures a undeclared resource' do
+ apply_manifest('')
+ pp = <<-EOS
+ ensure_resource('notify', 'test', { 'loglevel' => 'err' })
EOS
apply_manifest(pp, :expect_changes => true)
end
- it 'ensures a resource already declared'
it 'takes defaults arguments'
end
describe 'failure' do
diff --git a/spec/acceptance/fqdn_rand_string_spec.rb b/spec/acceptance/fqdn_rand_string_spec.rb
new file mode 100644
index 0000000..065a517
--- /dev/null
+++ b/spec/acceptance/fqdn_rand_string_spec.rb
@@ -0,0 +1,66 @@
+#! /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
+ include_context "with faked facts"
+ context "when the FQDN is 'fakehost.localdomain'" do
+ before :each do
+ fake_fact("fqdn", "fakehost.localdomain")
+ end
+
+ it 'generates random alphanumeric strings' do
+ 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|9Acvnhkt4J)"/)
+ end
+ end
+ it 'generates random alphanumeric strings with custom charsets' do
+ pp = <<-eos
+ $l = 10
+ $c = '0123456789'
+ $o = fqdn_rand_string($l, $c)
+ 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 "(7203048515|2383756694)"/)
+ end
+ end
+ it 'generates random alphanumeric strings with custom seeds' do
+ 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|1jJtAMs94d)"/)
+ end
+ end
+ it 'generates random alphanumeric strings with custom charsets and seeds' do
+ pp = <<-eos
+ $l = 10
+ $c = '0123456789'
+ $s = 'seed'
+ $o = fqdn_rand_string($l, $c, $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 "(3104058232|7100592312)"/)
+ end
+ 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 753068b..404351f 100755
--- a/spec/acceptance/fqdn_rotate_spec.rb
+++ b/spec/acceptance/fqdn_rotate_spec.rb
@@ -3,45 +3,62 @@ require 'spec_helper_acceptance'
describe 'fqdn_rotate 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'
+ include_context "with faked facts"
+ context "when the FQDN is 'fakehost.localdomain'" do
+ before :each do
+ fake_fact("fqdn", "fakehost.localdomain")
+ end
+
+ it 'rotates arrays' do
+ pp = <<-EOS
+ $a = ['a','b','c','d']
+ $o = fqdn_rotate($a)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rotate is \["d", "a", "b", "c"\]/)
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}'")
+ it 'rotates arrays with custom seeds' do
+ pp = <<-EOS
+ $a = ['a','b','c','d']
+ $s = 'seed'
+ $o = fqdn_rotate($a, $s)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
+ end
end
- end
- it 'fqdn_rotates floats' do
- shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
- pp = <<-EOS
- $a = ['a','b','c','d']
- $o = fqdn_rotate($a)
- notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
- EOS
+ it 'rotates strings' do
+ pp = <<-EOS
+ $a = 'abcd'
+ $o = fqdn_rotate($a)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rotate is "dabc"/)
+ end
+ end
+ it 'rotates strings with custom seeds' do
+ pp = <<-EOS
+ $a = 'abcd'
+ $s = 'seed'
+ $o = fqdn_rotate($a, $s)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ EOS
- apply_manifest(pp, :catch_failures => true) do |r|
- expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/fqdn_rotate is "cdab"/)
+ end
end
end
end
describe 'failure' do
it 'handles improper argument counts'
- it 'handles non-numbers'
+ it 'handles invalid arguments'
end
end
diff --git a/spec/acceptance/is_a_spec.rb b/spec/acceptance/is_a_spec.rb
new file mode 100644
index 0000000..355fd83
--- /dev/null
+++ b/spec/acceptance/is_a_spec.rb
@@ -0,0 +1,30 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+if get_puppet_version =~ /^4/
+ describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ it 'should match a string' do
+ pp = <<-EOS
+ if 'hello world'.is_a(String) {
+ notify { 'output correct': }
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/Notice: output correct/)
+ end
+ end
+
+ it 'should not match a integer as string' do
+ pp = <<-EOS
+ if 5.is_a(String) {
+ notify { 'output wrong': }
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).not_to match(/Notice: output wrong/)
+ end
+ end
+ end
+end
diff --git a/spec/acceptance/is_ipv4_address_spec.rb b/spec/acceptance/is_ipv4_address_spec.rb
new file mode 100755
index 0000000..5dc6bf5
--- /dev/null
+++ b/spec/acceptance/is_ipv4_address_spec.rb
@@ -0,0 +1,52 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'is_ipv4_addresss' do
+ pp = <<-EOS
+ $a = '1.2.3.4'
+ $b = true
+ $o = is_ipv4_address($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 'is_ipv4_addresss strings' do
+ pp = <<-EOS
+ $a = "aoeu"
+ $b = false
+ $o = is_ipv4_address($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 'is_ipv4_addresss ipv4 out of range' do
+ pp = <<-EOS
+ $a = '1.2.3.400'
+ $b = false
+ $o = is_ipv4_address($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'
+ end
+end
diff --git a/spec/acceptance/is_ipv6_address_spec.rb b/spec/acceptance/is_ipv6_address_spec.rb
new file mode 100755
index 0000000..1e88be8
--- /dev/null
+++ b/spec/acceptance/is_ipv6_address_spec.rb
@@ -0,0 +1,66 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'is_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'is_ipv6_addresss' do
+ pp = <<-EOS
+ $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
+ $b = true
+ $o = is_ipv6_address($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 'is_ipv6_addresss ipv6 compressed' do
+ pp = <<-EOS
+ $a = "fe00::1"
+ $b = true
+ $o = is_ipv6_address($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 'is_ipv6_addresss strings' do
+ pp = <<-EOS
+ $a = "aoeu"
+ $b = false
+ $o = is_ipv6_address($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 'is_ipv6_addresss ip out of range' do
+ pp = <<-EOS
+ $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg'
+ $b = false
+ $o = is_ipv6_address($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'
+ end
+end
diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb
index 94d8e96..f526888 100755
--- a/spec/acceptance/is_string_spec.rb
+++ b/spec/acceptance/is_string_spec.rb
@@ -95,6 +95,17 @@ describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
expect(r.stdout).to match(/Notice: output correct/)
end
end
+ it 'is_strings undef' do
+ pp = <<-EOS
+ $a = undef
+ $o = is_string($a)
+ notice(inline_template('is_string is <%= @o.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/is_string is true/)
+ end
+ end
end
describe 'failure' do
it 'handles improper argument counts'
diff --git a/spec/acceptance/loadjson_spec.rb b/spec/acceptance/loadjson_spec.rb
new file mode 100644
index 0000000..2992c37
--- /dev/null
+++ b/spec/acceptance/loadjson_spec.rb
@@ -0,0 +1,52 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+tmpdir = default.tmpdir('stdlib')
+
+describe 'loadjson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'loadjsons array of values' do
+ shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/testjson.json")
+ pp = <<-EOS
+ $o = loadjson('#{tmpdir}/testjson.json')
+ notice(inline_template('loadjson[aaa] is <%= @o["aaa"].inspect %>'))
+ notice(inline_template('loadjson[bbb] is <%= @o["bbb"].inspect %>'))
+ notice(inline_template('loadjson[ccc] is <%= @o["ccc"].inspect %>'))
+ notice(inline_template('loadjson[ddd] is <%= @o["ddd"].inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/loadjson\[aaa\] is 1/)
+ expect(r.stdout).to match(/loadjson\[bbb\] is 2/)
+ expect(r.stdout).to match(/loadjson\[ccc\] is 3/)
+ expect(r.stdout).to match(/loadjson\[ddd\] is 4/)
+ end
+ end
+
+ it 'returns the default value if there is no file to load' do
+ pp = <<-EOS
+ $o = loadjson('#{tmpdir}/no-file.json', {'default' => 'value'})
+ notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/loadjson\[default\] is "value"/)
+ end
+ end
+
+ it 'returns the default value if the file was parsed with an error' do
+ shell("echo '!' > #{tmpdir}/testjson.json")
+ pp = <<-EOS
+ $o = loadjson('#{tmpdir}/testjson.json', {'default' => 'value'})
+ notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/loadjson\[default\] is "value"/)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ end
+end
diff --git a/spec/acceptance/loadyaml_spec.rb b/spec/acceptance/loadyaml_spec.rb
index 1e910a9..ba3f0b7 100644
--- a/spec/acceptance/loadyaml_spec.rb
+++ b/spec/acceptance/loadyaml_spec.rb
@@ -26,6 +26,29 @@ describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('op
expect(r.stdout).to match(/loadyaml\[ddd\] is 4/)
end
end
+
+ it 'returns the default value if there is no file to load' do
+ pp = <<-EOS
+ $o = loadyaml('#{tmpdir}/no-file.yaml', {'default' => 'value'})
+ notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/loadyaml\[default\] is "value"/)
+ end
+ end
+
+ it 'returns the default value if the file was parsed with an error' do
+ shell("echo '!' > #{tmpdir}/testyaml.yaml")
+ pp = <<-EOS
+ $o = loadyaml('#{tmpdir}/testyaml.yaml', {'default' => 'value'})
+ notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/loadyaml\[default\] is "value"/)
+ end
+ end
end
describe 'failure' do
it 'fails with no arguments'
diff --git a/spec/acceptance/nodesets/centos-59-x64.yml b/spec/acceptance/nodesets/centos-59-x64.yml
deleted file mode 100644
index 2ad90b8..0000000
--- a/spec/acceptance/nodesets/centos-59-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- centos-59-x64:
- roles:
- - master
- platform: el-5-x86_64
- box : centos-59-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-59-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: git
diff --git a/spec/acceptance/nodesets/centos-6-vcloud.yml b/spec/acceptance/nodesets/centos-6-vcloud.yml
deleted file mode 100644
index ca9c1d3..0000000
--- a/spec/acceptance/nodesets/centos-6-vcloud.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-HOSTS:
- 'centos-6-vcloud':
- roles:
- - master
- platform: el-6-x86_64
- hypervisor: vcloud
- template: centos-6-x86_64
-CONFIG:
- type: foss
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
diff --git a/spec/acceptance/nodesets/centos-64-x64-pe.yml b/spec/acceptance/nodesets/centos-64-x64-pe.yml
deleted file mode 100644
index 7d9242f..0000000
--- a/spec/acceptance/nodesets/centos-64-x64-pe.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-HOSTS:
- centos-64-x64:
- roles:
- - master
- - database
- - dashboard
- platform: el-6-x86_64
- box : centos-64-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: pe
diff --git a/spec/acceptance/nodesets/centos-64-x64.yml b/spec/acceptance/nodesets/centos-64-x64.yml
deleted file mode 100644
index 05540ed..0000000
--- a/spec/acceptance/nodesets/centos-64-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- centos-64-x64:
- roles:
- - master
- platform: el-6-x86_64
- box : centos-64-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/centos-65-x64.yml b/spec/acceptance/nodesets/centos-65-x64.yml
deleted file mode 100644
index 4e2cb80..0000000
--- a/spec/acceptance/nodesets/centos-65-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- centos-65-x64:
- roles:
- - master
- platform: el-6-x86_64
- box : centos-65-x64-vbox436-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml
new file mode 100644
index 0000000..5eebdef
--- /dev/null
+++ b/spec/acceptance/nodesets/centos-7-x64.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ centos-7-x64:
+ roles:
+ - agent
+ - default
+ platform: el-7-x86_64
+ hypervisor: vagrant
+ box: puppetlabs/centos-7.2-64-nocm
+CONFIG:
+ type: foss
diff --git a/spec/acceptance/nodesets/debian-8-x64.yml b/spec/acceptance/nodesets/debian-8-x64.yml
new file mode 100644
index 0000000..fef6e63
--- /dev/null
+++ b/spec/acceptance/nodesets/debian-8-x64.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ debian-8-x64:
+ roles:
+ - agent
+ - default
+ platform: debian-8-amd64
+ hypervisor: vagrant
+ box: puppetlabs/debian-8.2-64-nocm
+CONFIG:
+ type: foss
diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml
index 4e2cb80..dba339c 100644
--- a/spec/acceptance/nodesets/default.yml
+++ b/spec/acceptance/nodesets/default.yml
@@ -1,10 +1,10 @@
HOSTS:
- centos-65-x64:
+ ubuntu-1404-x64:
roles:
- - master
- platform: el-6-x86_64
- box : centos-65-x64-vbox436-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
- hypervisor : vagrant
+ - agent
+ - default
+ platform: ubuntu-14.04-amd64
+ hypervisor: vagrant
+ box: puppetlabs/ubuntu-14.04-64-nocm
CONFIG:
type: foss
diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml
new file mode 100644
index 0000000..a3333aa
--- /dev/null
+++ b/spec/acceptance/nodesets/docker/centos-7.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-7-x64:
+ platform: el-7-x86_64
+ hypervisor: docker
+ image: centos:7
+ docker_preserve_image: true
+ docker_cmd: '["/usr/sbin/init"]'
+ # install various tools required to get the image up to usable levels
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts'
+CONFIG:
+ trace_limit: 200
diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml
new file mode 100644
index 0000000..df5c319
--- /dev/null
+++ b/spec/acceptance/nodesets/docker/debian-8.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ hypervisor: docker
+ image: debian:8
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen'
+CONFIG:
+ trace_limit: 200
diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
new file mode 100644
index 0000000..b1efa58
--- /dev/null
+++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1404-x64:
+ platform: ubuntu-14.04-amd64
+ hypervisor: docker
+ image: ubuntu:14.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ # ensure that upstart is booting correctly in the container
+ - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8'
+CONFIG:
+ trace_limit: 200
diff --git a/spec/acceptance/nodesets/fedora-18-x64.yml b/spec/acceptance/nodesets/fedora-18-x64.yml
deleted file mode 100644
index 1361649..0000000
--- a/spec/acceptance/nodesets/fedora-18-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- fedora-18-x64:
- roles:
- - master
- platform: fedora-18-x86_64
- box : fedora-18-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/sles-11-x64.yml b/spec/acceptance/nodesets/sles-11-x64.yml
deleted file mode 100644
index 41abe21..0000000
--- a/spec/acceptance/nodesets/sles-11-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- sles-11-x64.local:
- roles:
- - master
- platform: sles-11-x64
- box : sles-11sp1-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml b/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml
deleted file mode 100644
index 5ca1514..0000000
--- a/spec/acceptance/nodesets/ubuntu-server-10044-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- ubuntu-server-10044-x64:
- roles:
- - master
- platform: ubuntu-10.04-amd64
- box : ubuntu-server-10044-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml b/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
deleted file mode 100644
index d065b30..0000000
--- a/spec/acceptance/nodesets/ubuntu-server-12042-x64.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-HOSTS:
- ubuntu-server-12042-x64:
- roles:
- - master
- platform: ubuntu-12.04-amd64
- box : ubuntu-server-12042-x64-vbox4210-nocm
- box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
- hypervisor : vagrant
-CONFIG:
- type: foss
diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
deleted file mode 100644
index cba1cd0..0000000
--- a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-HOSTS:
- ubuntu-server-1404-x64:
- roles:
- - master
- platform: ubuntu-14.04-amd64
- box : puppetlabs/ubuntu-14.04-64-nocm
- box_url : https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm
- hypervisor : vagrant
-CONFIG:
- log_level : debug
- type: git
diff --git a/spec/acceptance/nodesets/windows-2003-i386.yml b/spec/acceptance/nodesets/windows-2003-i386.yml
deleted file mode 100644
index 47dadbd..0000000
--- a/spec/acceptance/nodesets/windows-2003-i386.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2003_i386:
- roles:
- - agent
- - default
- platform: windows-2003-i386
- template: win-2003-i386
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/nodesets/windows-2003-x86_64.yml b/spec/acceptance/nodesets/windows-2003-x86_64.yml
deleted file mode 100644
index 6a884bc..0000000
--- a/spec/acceptance/nodesets/windows-2003-x86_64.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2003_x86_64:
- roles:
- - agent
- - default
- platform: windows-2003-x86_64
- template: win-2003-x86_64
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/nodesets/windows-2008-x86_64.yml b/spec/acceptance/nodesets/windows-2008-x86_64.yml
deleted file mode 100644
index ae3c11d..0000000
--- a/spec/acceptance/nodesets/windows-2008-x86_64.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2008_x86_64:
- roles:
- - agent
- - default
- platform: windows-2008-x86_64
- template: win-2008-x86_64
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/nodesets/windows-2008r2-x86_64.yml b/spec/acceptance/nodesets/windows-2008r2-x86_64.yml
deleted file mode 100644
index 63923ac..0000000
--- a/spec/acceptance/nodesets/windows-2008r2-x86_64.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2008r2:
- roles:
- - agent
- - default
- platform: windows-2008r2-x86_64
- template: win-2008r2-x86_64
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/nodesets/windows-2012-x86_64.yml b/spec/acceptance/nodesets/windows-2012-x86_64.yml
deleted file mode 100644
index eaa4eca..0000000
--- a/spec/acceptance/nodesets/windows-2012-x86_64.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2012:
- roles:
- - agent
- - default
- platform: windows-2012-x86_64
- template: win-2012-x86_64
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/nodesets/windows-2012r2-x86_64.yml b/spec/acceptance/nodesets/windows-2012r2-x86_64.yml
deleted file mode 100644
index 1f0ea97..0000000
--- a/spec/acceptance/nodesets/windows-2012r2-x86_64.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-HOSTS:
- ubuntu1204:
- roles:
- - master
- - database
- - dashboard
- platform: ubuntu-12.04-amd64
- template: ubuntu-1204-x86_64
- hypervisor: vcloud
- win2012r2:
- roles:
- - agent
- - default
- platform: windows-2012r2-x86_64
- template: win-2012r2-x86_64
- hypervisor: vcloud
-CONFIG:
- nfs_server: none
- ssh:
- keys: "~/.ssh/id_rsa-acceptance"
- consoleport: 443
- datastore: instance0
- folder: Delivery/Quality Assurance/Enterprise/Dynamic
- resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
- pooling_api: http://vcloud.delivery.puppetlabs.net/
- pe_dir: http://neptune.puppetlabs.lan/3.2/ci-ready/
diff --git a/spec/acceptance/parsejson_spec.rb b/spec/acceptance/parsejson_spec.rb
index 5097810..d0e3de8 100755
--- a/spec/acceptance/parsejson_spec.rb
+++ b/spec/acceptance/parsejson_spec.rb
@@ -16,10 +16,23 @@ describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
end
end
end
+
describe 'failure' do
it 'raises error on incorrect json' do
pp = <<-EOS
$a = '{"hunter": "washere", "tests": "passing",}'
+ $ao = parsejson($a, 'tests are using the default value')
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/tests are using the default value/)
+ end
+ end
+
+ it 'raises error on incorrect json' do
+ pp = <<-EOS
+ $a = '{"hunter": "washere", "tests": "passing",}'
$ao = parsejson($a)
notice(inline_template('a is <%= @ao.inspect %>'))
EOS
@@ -29,6 +42,14 @@ describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
end
end
- it 'raises error on incorrect number of arguments'
+ it 'raises error on incorrect number of arguments' do
+ pp = <<-EOS
+ $o = parsejson()
+ EOS
+
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(/wrong number of arguments/i)
+ end
+ end
end
end
diff --git a/spec/acceptance/parseyaml_spec.rb b/spec/acceptance/parseyaml_spec.rb
index 5819837..64511f1 100755
--- a/spec/acceptance/parseyaml_spec.rb
+++ b/spec/acceptance/parseyaml_spec.rb
@@ -16,7 +16,21 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
end
end
end
+
describe 'failure' do
+ it 'returns the default value on incorrect yaml' do
+ pp = <<-EOS
+ $a = "---\nhunter: washere\ntests: passing\n:"
+ $o = parseyaml($a, {'tests' => 'using the default value'})
+ $tests = $o['tests']
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/tests are "using the default value"/)
+ end
+ end
+
it 'raises error on incorrect yaml' do
pp = <<-EOS
$a = "---\nhunter: washere\ntests: passing\n:"
@@ -30,6 +44,15 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
end
end
- it 'raises error on incorrect number of arguments'
+
+ it 'raises error on incorrect number of arguments' do
+ pp = <<-EOS
+ $o = parseyaml()
+ EOS
+
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(/wrong number of arguments/i)
+ end
+ 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..cd4cb87
--- /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', 'SLES']).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/try_get_value_spec.rb b/spec/acceptance/try_get_value_spec.rb
new file mode 100755
index 0000000..c0bf38a
--- /dev/null
+++ b/spec/acceptance/try_get_value_spec.rb
@@ -0,0 +1,47 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+ describe 'success' do
+ it 'gets a value' do
+ pp = <<-EOS
+ $data = {
+ 'a' => { 'b' => 'passing'}
+ }
+
+ $tests = try_get_value($data, 'a/b')
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/tests are "passing"/)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'uses a default value' do
+ pp = <<-EOS
+ $data = {
+ 'a' => { 'b' => 'passing'}
+ }
+
+ $tests = try_get_value($data, 'c/d', 'using the default value')
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ EOS
+
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(/using the default value/)
+ end
+ end
+
+ it 'raises error on incorrect number of arguments' do
+ pp = <<-EOS
+ $o = try_get_value()
+ EOS
+
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(/wrong number of arguments/i)
+ end
+ end
+ end
+end
diff --git a/spec/acceptance/union_spec.rb b/spec/acceptance/union_spec.rb
index 6db8d0c..160fd7b 100755
--- a/spec/acceptance/union_spec.rb
+++ b/spec/acceptance/union_spec.rb
@@ -6,9 +6,10 @@ describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('opera
it 'unions arrays' do
pp = <<-EOS
$a = ["the","public"]
- $b = ["art","galleries"]
+ $b = ["art"]
+ $c = ["galleries"]
# Anagram: Large picture halls, I bet
- $o = union($a,$b)
+ $o = union($a,$b,$c)
notice(inline_template('union is <%= @o.inspect %>'))
EOS
diff --git a/spec/acceptance/validate_array_spec.rb b/spec/acceptance/validate_array_spec.rb
index b53e98c..2f549d5 100755
--- a/spec/acceptance/validate_array_spec.rb
+++ b/spec/acceptance/validate_array_spec.rb
@@ -20,14 +20,14 @@ describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fa
apply_manifest(pp, :catch_failures => true)
end
- it 'validates a non-array' do
- {
- %{validate_array({'a' => 'hash' })} => "Hash",
- %{validate_array('string')} => "String",
- %{validate_array(false)} => "FalseClass",
- %{validate_array(undef)} => "String"
- }.each do |pp,type|
- expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+ [
+ %{validate_array({'a' => 'hash' })},
+ %{validate_array('string')},
+ %{validate_array(false)},
+ %{validate_array(undef)}
+ ].each do |pp|
+ it "rejects #{pp.inspect}" do
+ expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not an Array\. It looks to be a/)
end
end
end
diff --git a/spec/acceptance/validate_bool_spec.rb b/spec/acceptance/validate_bool_spec.rb
index c837f08..5c52d0f 100755
--- a/spec/acceptance/validate_bool_spec.rb
+++ b/spec/acceptance/validate_bool_spec.rb
@@ -20,14 +20,14 @@ describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fac
apply_manifest(pp, :catch_failures => true)
end
- it 'validates a non-bool' do
- {
- %{validate_bool('true')} => "String",
- %{validate_bool('false')} => "String",
- %{validate_bool([true])} => "Array",
- %{validate_bool(undef)} => "String",
- }.each do |pp,type|
- expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+ [
+ %{validate_bool('true')},
+ %{validate_bool('false')},
+ %{validate_bool([true])},
+ %{validate_bool(undef)}
+ ].each do |pp|
+ it "rejects #{pp.inspect}" do
+ expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/is not a boolean\. It looks to be a/)
end
end
end
diff --git a/spec/acceptance/validate_hash_spec.rb b/spec/acceptance/validate_hash_spec.rb
index 52fb615..637df0a 100755
--- a/spec/acceptance/validate_hash_spec.rb
+++ b/spec/acceptance/validate_hash_spec.rb
@@ -20,14 +20,14 @@ describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fac
apply_manifest(pp, :catch_failures => true)
end
- it 'validates a non-hash' do
- {
- %{validate_hash('{ "not" => "hash" }')} => "String",
- %{validate_hash('string')} => "String",
- %{validate_hash(["array"])} => "Array",
- %{validate_hash(undef)} => "String",
- }.each do |pp,type|
- expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
+ [
+ %{validate_hash('{ "not" => "hash" }')},
+ %{validate_hash('string')},
+ %{validate_hash(["array"])},
+ %{validate_hash(undef)}
+ ].each do |pp|
+ it "rejects #{pp.inspect}" do
+ expect(apply_manifest(pp, :expect_failures => true).stderr).to match(//)
end
end
end
diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb
index 8956f48..ae3468f 100755
--- a/spec/acceptance/validate_string_spec.rb
+++ b/spec/acceptance/validate_string_spec.rb
@@ -20,6 +20,13 @@ describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(f
apply_manifest(pp, :catch_failures => true)
end
+ it 'validates undef' do
+ pp = <<-EOS
+ validate_string(undef)
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
it 'validates a non-string' do
{
%{validate_string({ 'a' => 'hash' })} => "Hash",