Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / fqdn_rand_string_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'fqdn_rand_string function' do
4   describe 'success' do
5     include_context 'with faked facts'
6     context "when the FQDN is 'fakehost.localdomain'" do
7       before :each do
8         fake_fact('fqdn', 'fakehost.localdomain')
9       end
10
11       pp1 = <<-PUPPETCODE
12         $l = 10
13         $o = fqdn_rand_string($l)
14         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
15       PUPPETCODE
16       it 'generates random alphanumeric strings' do
17         apply_manifest(pp1, :catch_failures => true) do |r|
18           expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"})
19         end
20       end
21
22       pp2 = <<-PUPPETCODE
23         $l = 10
24         $c = '0123456789'
25         $o = fqdn_rand_string($l, $c)
26         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
27       PUPPETCODE
28       it 'generates random alphanumeric strings with custom charsets' do
29         apply_manifest(pp2, :catch_failures => true) do |r|
30           expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"})
31         end
32       end
33
34       pp3 = <<-PUPPETCODE
35         $l = 10
36         $s = 'seed'
37         $o = fqdn_rand_string($l, undef, $s)
38         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
39       PUPPETCODE
40       it 'generates random alphanumeric strings with custom seeds' do
41         apply_manifest(pp3, :catch_failures => true) do |r|
42           expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"})
43         end
44       end
45
46       pp4 = <<-PUPPETCODE
47         $l = 10
48         $c = '0123456789'
49         $s = 'seed'
50         $o = fqdn_rand_string($l, $c, $s)
51         notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
52       PUPPETCODE
53       it 'generates random alphanumeric strings with custom charsets and seeds' do
54         apply_manifest(pp4, :catch_failures => true) do |r|
55           expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"})
56         end
57       end
58     end
59   end
60   describe 'failure' do
61     it 'handles improper argument counts'
62     it 'handles non-numbers for length argument'
63   end
64 end