aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-11 14:31:39 +0200
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-11 14:31:39 +0200
commitd7efc5772d475e3ad374e6000f2e706be42c85da (patch)
treeb944fe7666c249fbdce1b94b073b3df3b1455a14 /spec
parent65bea20e0d8e61de7519bb1ab0677597500aaac7 (diff)
downloadpuppet-dhcp-d7efc5772d475e3ad374e6000f2e706be42c85da.tar.gz
puppet-dhcp-d7efc5772d475e3ad374e6000f2e706be42c85da.tar.bz2
Check param validation in dhcp::server::config
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/dhcp_spec.rb141
1 files changed, 99 insertions, 42 deletions
diff --git a/spec/classes/dhcp_spec.rb b/spec/classes/dhcp_spec.rb
index ce9228e..5eb7172 100644
--- a/spec/classes/dhcp_spec.rb
+++ b/spec/classes/dhcp_spec.rb
@@ -86,56 +86,113 @@ describe 'dhcp' do
end
context 'When passing ddns_update' do
- let (:facts) { {
- :operatingsystem => 'Debian',
- :osfamily => 'Debian',
- :lsbdistcodename => 'squeeze'
- } }
- let (:params) { {
- :server_ddns_update => 'foo'
- } }
+ context 'When passing wrong type' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_ddns_update => true
+ } }
+
+ it 'should fail' do
+ expect {
+ should contain_concat__fragment('00.dhcp.server.base')
+ }.to raise_error(Puppet::Error, /true is not a string./)
+ end
+ end
- it { should contain_concat__fragment('00.dhcp.server.base').with(
- :ensure => 'present',
- :target => '/etc/dhcp/dhcpd.conf',
- :content => /log-facility/
- ).with_content(/ddns-update-style foo;/).with_content(/#authoritative/)
- }
+ context 'When passing valid value' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_ddns_update => 'foo'
+ } }
+
+ it { should contain_concat__fragment('00.dhcp.server.base').with(
+ :ensure => 'present',
+ :target => '/etc/dhcp/dhcpd.conf',
+ :content => /log-facility/
+ ).with_content(/ddns-update-style foo;/).with_content(/#authoritative/)
+ }
+ end
end
context 'When passing authoritative' do
- let (:facts) { {
- :operatingsystem => 'Debian',
- :osfamily => 'Debian',
- :lsbdistcodename => 'squeeze'
- } }
- let (:params) { {
- :server_authoritative => true
- } }
+ context 'When passing wrong type' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_authoritative => 'foo'
+ } }
+
+ it 'should fail' do
+ expect {
+ should contain_concat__fragment('00.dhcp.server.base')
+ }.to raise_error(Puppet::Error, /"foo" is not a boolean./)
+ end
+ end
- it { should contain_concat__fragment('00.dhcp.server.base').with(
- :ensure => 'present',
- :target => '/etc/dhcp/dhcpd.conf',
- :content => /log-facility/
- ).with_content(/ddns-update-style none;/).with_content(/[^#]authoritative/)
- }
+ context 'When passing valid value' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_authoritative => true
+ } }
+
+ it { should contain_concat__fragment('00.dhcp.server.base').with(
+ :ensure => 'present',
+ :target => '/etc/dhcp/dhcpd.conf',
+ :content => /log-facility/
+ ).with_content(/ddns-update-style none;/).with_content(/[^#]authoritative/)
+ }
+ end
end
context 'When passing opts' do
- let (:facts) { {
- :operatingsystem => 'Debian',
- :osfamily => 'Debian',
- :lsbdistcodename => 'squeeze'
- } }
- let (:params) { {
- :server_opts => ['foo', 'bar', 'baz']
- } }
+ context 'When passing wrong type' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_opts => 'foo'
+ } }
+
+ it 'should fail' do
+ expect {
+ should contain_concat__fragment('00.dhcp.server.base')
+ }.to raise_error(Puppet::Error, /"foo" is not an Array./)
+ end
+ end
- it { should contain_concat__fragment('00.dhcp.server.base').with(
- :ensure => 'present',
- :target => '/etc/dhcp/dhcpd.conf',
- :content => /log-facility/
- ).with_content(/ddns-update-style none;/).with_content(/#authoritative/).with_content(/foo;\nbar;\nbaz;\n/)
- }
+ context 'When passing valid value' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+ let (:params) { {
+ :server_opts => ['foo', 'bar', 'baz']
+ } }
+
+ it { should contain_concat__fragment('00.dhcp.server.base').with(
+ :ensure => 'present',
+ :target => '/etc/dhcp/dhcpd.conf',
+ :content => /log-facility/
+ ).with_content(/ddns-update-style none;/).with_content(/#authoritative/).with_content(/foo;\nbar;\nbaz;\n/)
+ }
+ end
end
end