1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper_acceptance'
4 describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
7 if fact('is_pe', '--puppet') == "true"
8 if fact('osfamily') =~ /windows/i
9 if fact('kernelmajversion').to_f < 6.0
10 'c:/documents and settings/all users/application data/puppetlabs/facter/facts.d'
12 'c:/programdata/puppetlabs/facter/facts.d'
15 '/etc/puppetlabs/facter/facts.d'
22 shell("if [ -f '#{facts_d}/fqdn.txt' ] ; then rm '#{facts_d}/fqdn.txt' ; fi")
25 #no need to create on windows, pe creates by default
26 if fact('osfamily') !~ /windows/i
27 shell("mkdir -p '#{facts_d}'")
30 it 'generates random alphanumeric strings' do
31 shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
34 $o = fqdn_rand_string($l)
35 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
38 apply_manifest(pp, :catch_failures => true) do |r|
39 expect(r.stdout).to match(/fqdn_rand_string is "7oDp0KOr1b"/)
42 it 'generates random alphanumeric strings with custom seeds' do
43 shell("echo fqdn=fakehost.localdomain > '#{facts_d}/fqdn.txt'")
47 $o = fqdn_rand_string($l, undef, $s)
48 notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
51 apply_manifest(pp, :catch_failures => true) do |r|
52 expect(r.stdout).to match(/fqdn_rand_string is "3HS4mbuI3E"/)
57 it 'handles improper argument counts'
58 it 'handles non-numbers for length argument'