forked from theforeman/puppet-dhcp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_spec.rb
112 lines (104 loc) · 4.01 KB
/
init_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
require 'spec_helper'
describe 'dhcp' do
context 'supported operating systems' do
['Debian', 'RedHat', 'FreeBSD'].each do |osfamily|
conf_path = (osfamily == 'FreeBSD') ? '/usr/local/etc' : '/etc/dhcp'
describe "dhcp class without any parameters on #{osfamily}" do
let(:params) do {
:interfaces => ['eth0'],
} end
let(:facts) do {
:concat_basedir => '/doesnotexist',
:domain => 'example.org',
:osfamily => osfamily,
} end
it { should compile.with_all_deps }
it {
verify_concat_fragment_exact_contents(catalogue, 'dhcp.conf+01_main.dhcp', [
'omapi-port 7911;',
'default-lease-time 43200;',
'max-lease-time 86400;',
'ddns-update-style none;',
'option domain-name "example.org";',
'option domain-name-servers 8.8.8.8, 8.8.4.4;',
"option ntp-servers none;",
'allow booting;',
'allow bootp;',
'option fqdn.no-client-update on; # set the "O" and "S" flag bits',
'option fqdn.rcode2 255;',
'option pxegrub code 150 = text ;',
'log-facility local7;',
"include \"#{conf_path}/dhcpd.hosts\";",
])
}
end
describe "dhcp class parameters on #{osfamily}" do
let(:params) do {
:interfaces => ['eth0'],
:dnsupdatekey => 'mydnsupdatekey',
:ntpservers => ['1.1.1.1', '1.1.1.2'],
:omapi_name => 'mykeyname',
:omapi_key => 'myomapikey',
:pxeserver => '10.0.0.5',
:mtu => 9000,
:pxefilename => 'mypxefilename',
:option_static_route => true,
:options => ['provision-url code 224 = text', 'provision-type code 225 = text'],
:authoritative => true,
:ddns_domainname => 'example.org',
:ddns_rev_domainname => 'in-addr.arpa',
:includes => ['myinclude1', 'myinclude2'],
} end
let(:facts) do {
:concat_basedir => '/doesnotexist',
:domain => 'example.org',
:osfamily => osfamily,
} end
it { should compile.with_all_deps }
it {
verify_concat_fragment_exact_contents(catalogue, 'dhcp.conf+01_main.dhcp', [
'omapi-port 7911;',
'key mykeyname {',
' algorithm HMAC-MD5;',
' secret "myomapikey";',
'}',
'omapi-key mykeyname;',
'default-lease-time 43200;',
'max-lease-time 86400;',
'authoritative;',
'ddns-updates on;',
'ddns-update-style interim;',
'update-static-leases on;',
'use-host-decl-names on;',
'ddns-domainname "example.org";',
'ddns-rev-domainname "in-addr.arpa";',
'include "mydnsupdatekey";',
'zone example.org. {',
' primary 8.8.8.8;',
' key rndc-key;',
'}',
'option domain-name "example.org";',
'option domain-name-servers 8.8.8.8, 8.8.4.4;',
'option ntp-servers 1.1.1.1, 1.1.1.2;',
'allow booting;',
'allow bootp;',
'option fqdn.no-client-update on; # set the "O" and "S" flag bits',
'option fqdn.rcode2 255;',
'option pxegrub code 150 = text ;',
'option rfc3442-classless-static-routes code 121 = array of integer 8;',
'option ms-classless-static-routes code 249 = array of integer 8;',
'option interface-mtu 9000;',
'option provision-url code 224 = text;',
'option provision-type code 225 = text;',
'next-server 10.0.0.5;',
'filename "mypxefilename";',
'log-facility local7;',
"include \"#{conf_path}/dhcpd.hosts\";",
'include "myinclude1";',
'include "myinclude2";',
])
}
end
end
end
end