Suggest different variables to use if we want to tunnel both v4 and v6
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_domain_name_spec.rb
1 require 'spec_helper'
2
3 describe 'is_domain_name' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
6   it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7   it { is_expected.to run.with_params(1).and_return(false) }
8   it { is_expected.to run.with_params([]).and_return(false) }
9   it { is_expected.to run.with_params({}).and_return(false) }
10   it { is_expected.to run.with_params('').and_return(false) }
11   it { is_expected.to run.with_params('.').and_return(true) }
12   it { is_expected.to run.with_params('com').and_return(true) }
13   it { is_expected.to run.with_params('com.').and_return(true) }
14   it { is_expected.to run.with_params('x.com').and_return(true) }
15   it { is_expected.to run.with_params('x.com.').and_return(true) }
16   it { is_expected.to run.with_params('foo.example.com').and_return(true) }
17   it { is_expected.to run.with_params('foo.example.com.').and_return(true) }
18   it { is_expected.to run.with_params('2foo.example.com').and_return(true) }
19   it { is_expected.to run.with_params('2foo.example.com.').and_return(true) }
20   it { is_expected.to run.with_params('www.2foo.example.com').and_return(true) }
21   it { is_expected.to run.with_params('www.2foo.example.com.').and_return(true) }
22   describe 'inputs with spaces' do
23     it { is_expected.to run.with_params('invalid domain').and_return(false) }
24   end
25   describe 'inputs with hyphens' do
26     it { is_expected.to run.with_params('foo-bar.example.com').and_return(true) }
27     it { is_expected.to run.with_params('foo-bar.example.com.').and_return(true) }
28     it { is_expected.to run.with_params('www.foo-bar.example.com').and_return(true) }
29     it { is_expected.to run.with_params('www.foo-bar.example.com.').and_return(true) }
30     it { is_expected.to run.with_params('-foo.example.com').and_return(false) }
31     it { is_expected.to run.with_params('-foo.example.com.').and_return(false) }
32   end
33   # Values obtained from Facter values will be frozen strings
34   # in newer versions of Facter:
35   it { is_expected.to run.with_params('www.example.com'.freeze).and_return(true) }
36   describe 'top level domain must be alphabetic if there are multiple labels' do
37     it { is_expected.to run.with_params('2com').and_return(true) }
38     it { is_expected.to run.with_params('www.example.2com').and_return(false) }
39   end
40   describe 'IP addresses are not domain names' do
41     it { is_expected.to run.with_params('192.168.1.1').and_return(false) }
42   end
43 end