spec tests for bind::key

This commit is contained in:
Cédric Defortis
2017-05-02 11:41:59 +02:00
parent 3dd198e706
commit 8308595a57
5 changed files with 126 additions and 23 deletions
+38 -9
View File
@@ -1,6 +1,5 @@
# ex: syntax=ruby ts=2 sw=2 si et
require 'spec_helper'
require 'pp'
describe 'bind' do
on_supported_os.each do |os, facts|
@@ -8,30 +7,60 @@ describe 'bind' do
let (:facts) {facts}
case facts[:os]['family']
when 'Debian'
expected_bind_tools_pkg = 'dnsutils'
expected_bind_pkg = 'bind9'
expected_bind_service = 'bind9'
expected_named_conf = '/etc/bind/named.conf'
expected_confdir = '/etc/bind'
when 'RedHat'
expected_bind_tools_pkg = 'bind-utils'
expected_bind_pkg = 'bind'
expected_bind_service = 'named'
expected_named_conf = '/etc/named.conf'
expected_confdir = '/etc/named'
end
context 'with defaults for all parameters' do
it { is_expected.to contain_class('bind::defaults') }
it { is_expected.to contain_class('bind::keydir') }
it { is_expected.to contain_class('bind::updater') }
it { is_expected.to contain_class('bind') }
it { is_expected.to compile.with_all_deps }
it do
is_expected.to contain_package('bind-tools').with({
ensure: 'present',
name: expected_bind_tools_pkg
})
end
it do
is_expected.to contain_package('bind').with({
ensure: 'latest',
name: expected_bind_pkg
})
end
it { is_expected.to contain_file('/usr/local/bin/dnssec-init') }
it do
is_expected.to contain_bind__key('rndc-key').with(
algorithm: 'hmac-md5',
secret_bits: '512',
keydir: expected_confdir,
keyfile: 'rndc.key',
)
end
it { is_expected.to contain_file('/usr/local/bin/rndc-helper') }
it { is_expected.to contain_concat("#{expected_confdir}/acls.conf") }
it { is_expected.to contain_concat("#{expected_confdir}/keys.conf") }
it { is_expected.to contain_concat("#{expected_confdir}/views.conf") }
it { is_expected.to contain_concat("#{expected_confdir}/servers.conf") }
it { is_expected.to contain_concat("#{expected_confdir}/logging.conf") }
it { is_expected.to contain_concat("#{expected_confdir}/view-mappings.txt") }
it { is_expected.to contain_concat("#{expected_confdir}/domain-mappings.txt") }
it do
is_expected.to contain_concat__fragment('bind-logging-header').with(
order: '00-header',
target: "#{expected_confdir}/logging.conf",
content: "logging {\n"
)
end
it do
is_expected.to contain_concat__fragment('bind-logging-footer').with(
order: '99-footer',
target: "#{expected_confdir}/logging.conf",
content: "};\n"
)
end
it { is_expected.to contain_file(expected_named_conf).that_requires('Package[bind]') }
it { is_expected.to contain_file(expected_named_conf).that_notifies('Service[bind]') }
it do
+20 -11
View File
@@ -1,16 +1,25 @@
require 'spec_helper'
describe 'bind::updater' do
let :facts do
{
:concat_basedir => '/wtf',
:osfamily => 'Debian',
:os => {
:family => 'Debian',
},
:operatingsystem => 'Debian'
}
on_supported_os.each do |os, facts|
context "on #{os}" do
let (:facts) {facts}
case facts[:os]['family']
when 'Debian'
expected_bind_tools_pkg = 'dnsutils'
when 'RedHat'
expected_bind_tools_pkg = 'bind-utils'
end
context 'with defaults for all parameters' do
it { is_expected.to compile }
it { is_expected.to compile.with_all_deps }
end
it do
is_expected.to contain_package('bind-tools').with({
ensure: 'present',
name: expected_bind_tools_pkg
})
end
end
end
it { should compile }
it { should compile.with_all_deps }
end