summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshley Penney <ashley.penney@puppetlabs.com>2013-07-29 17:08:44 -0400
committerAshley Penney <ashley.penney@puppetlabs.com>2013-07-29 17:10:58 -0400
commit56df86a9a2838ef11bd07928709b04667f9b305f (patch)
treeb9a4a3d0f2cc90ecbeb60c37d363951559ff0242
parente896ad92293b596876dbd829ffd0f98e0bd441ad (diff)
Add tests for the new keys options.
-rw-r--r--spec/classes/ntp_config_spec.rb63
1 files changed, 56 insertions, 7 deletions
diff --git a/spec/classes/ntp_config_spec.rb b/spec/classes/ntp_config_spec.rb
index 940eee0..53836a0 100644
--- a/spec/classes/ntp_config_spec.rb
+++ b/spec/classes/ntp_config_spec.rb
@@ -23,13 +23,6 @@ describe 'ntp::config' do
'server 3.debian.pool.ntp.org iburst']
(content.split("\n") & expected_lines).should == expected_lines
end
-
- it 'should use different restrict settings if set' do
- params[:restrict] == '127.0.0.1'
- content = param_value(subject, 'file', '/etc/ntp.conf', 'content')
- expected_lines = ['restrict 127.0.0.1']
- (content.split("\n") & expected_lines).should == expected_lines
- end
end
describe "for operating system family RedHat" do
@@ -175,5 +168,61 @@ describe 'ntp::config' do
end
end
end
+
+ ['Debian', 'RedHat','SuSE', 'FreeBSD', 'Archlinux'].each do |osfamily|
+ describe "keys for osfamily #{osfamily}" do
+
+ context "when enabled" do
+ let(:facts) {{ :osfamily => osfamily }}
+ let(:params) {{
+ :keys_enable => true,
+ :keys_file => '/etc/ntp/ntp.keys',
+ :keys_trusted => ['1', '2', '3'],
+ :keys_controlkey => '2',
+ :keys_requestkey => '3',
+ }}
+
+ it { should contain_file('/etc/ntp').with({
+ 'ensure' => 'directory'})
+ }
+ it { should contain_file('/etc/ntp.conf').with({
+ 'content' => /trustedkey 1 2 3/})
+ }
+ it { should contain_file('/etc/ntp.conf').with({
+ 'content' => /controlkey 2/})
+ }
+ it { should contain_file('/etc/ntp.conf').with({
+ 'content' => /requestkey 3/})
+ }
+ end
+ end
+
+ context "when disabled" do
+ let(:facts) {{ :osfamily => osfamily }}
+ let(:params) {{
+ :keys_enable => false,
+ :keys_file => '/etc/ntp/ntp.keys',
+ :keys_trusted => ['1', '2', '3'],
+ :keys_controlkey => '2',
+ :keys_requestkey => '3',
+ }}
+
+ it { should_not contain_file('/etc/ntp').with({
+ 'ensure' => 'directory'})
+ }
+ it { should_not contain_file('/etc/ntp.conf').with({
+ 'content' => /trustedkey 1 2 3/})
+ }
+ it { should_not contain_file('/etc/ntp.conf').with({
+ 'content' => /controlkey 2/})
+ }
+ it { should_not contain_file('/etc/ntp.conf').with({
+ 'content' => /requestkey 3/})
+ }
+ end
+ end
+
+
+
end
end