|
| 1 | +require 'spec_helper_acceptance' |
| 2 | + |
| 3 | +describe "ntp class:" do |
| 4 | + it 'applies successfully' do |
| 5 | + pp = "class { 'ntp': }" |
| 6 | + |
| 7 | + apply_manifest(pp, :catch_failures => true) do |r| |
| 8 | + expect(r.stderr).to eq("") |
| 9 | + end |
| 10 | + end |
| 11 | + |
| 12 | + describe 'autoconfig' do |
| 13 | + it 'raises a deprecation warning' do |
| 14 | + pp = "class { 'ntp': autoupdate => true }" |
| 15 | + |
| 16 | + apply_manifest(pp, :catch_failures => true) do |r| |
| 17 | + expect(r.stdout).to match(/autoupdate parameter has been deprecated and replaced with package_ensure/) |
| 18 | + end |
| 19 | + end |
| 20 | + end |
| 21 | + |
| 22 | + describe 'config' do |
| 23 | + it 'sets the ntp.conf location' do |
| 24 | + pp = "class { 'ntp': config => '/etc/antp.conf' }" |
| 25 | + apply_manifest(pp, :catch_failures => true) |
| 26 | + end |
| 27 | + |
| 28 | + describe file('/etc/antp.conf') do |
| 29 | + it { should be_file } |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + describe 'config_template' do |
| 34 | + it 'sets up template' do |
| 35 | + shell('mkdir -p /etc/puppet/modules/test/templates') |
| 36 | + shell('echo "testcontent" >> /etc/puppet/modules/test/templates/ntp.conf') |
| 37 | + end |
| 38 | + |
| 39 | + it 'sets the ntp.conf location' do |
| 40 | + pp = "class { 'ntp': config_template => 'test/ntp.conf' }" |
| 41 | + apply_manifest(pp, :catch_failures => true) |
| 42 | + end |
| 43 | + |
| 44 | + describe file('/etc/ntp.conf') do |
| 45 | + it { should be_file } |
| 46 | + it { should contain 'testcontent' } |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + describe 'driftfile' do |
| 51 | + it 'sets the driftfile location' do |
| 52 | + pp = "class { 'ntp': driftfile => '/tmp/driftfile' }" |
| 53 | + apply_manifest(pp, :catch_failures => true) |
| 54 | + end |
| 55 | + |
| 56 | + describe file('/etc/ntp.conf') do |
| 57 | + it { should be_file } |
| 58 | + it { should contain 'driftfile /tmp/driftfile' } |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + describe 'keys' do |
| 63 | + it 'enables the key parameters' do |
| 64 | + pp = <<-EOS |
| 65 | + class { 'ntp': |
| 66 | + keys_enable => true, |
| 67 | + keys_file => '/etc/ntp/keys', |
| 68 | + keys_controlkey => '/etc/ntp/controlkey', |
| 69 | + keys_requestkey => '/etc/ntp/requestkey', |
| 70 | + keys_trusted => [ '/etc/ntp/key1', '/etc/ntp/key2' ], |
| 71 | + } |
| 72 | + EOS |
| 73 | + apply_manifest(pp, :catch_failures => true) |
| 74 | + end |
| 75 | + |
| 76 | + describe file('/etc/ntp.conf') do |
| 77 | + it { should be_file } |
| 78 | + it { should contain 'keys /etc/ntp/keys' } |
| 79 | + it { should contain 'controlkey /etc/ntp/controlkey' } |
| 80 | + it { should contain 'requestkey /etc/ntp/requestkey' } |
| 81 | + it { should contain 'trustedkey /etc/ntp/key1 /etc/ntp/key2' } |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + describe 'package' do |
| 86 | + it 'installs the right package' do |
| 87 | + pp = <<-EOS |
| 88 | + class { 'ntp': |
| 89 | + package_ensure => present, |
| 90 | + package_name => ['ntp'], |
| 91 | + } |
| 92 | + EOS |
| 93 | + apply_manifest(pp, :catch_failures => true) |
| 94 | + end |
| 95 | + |
| 96 | + describe package('ntp') do |
| 97 | + it { should be_installed } |
| 98 | + end |
| 99 | + end |
| 100 | + |
| 101 | + describe 'panic => false' do |
| 102 | + it 'enables the tinker panic setting' do |
| 103 | + pp = <<-EOS |
| 104 | + class { 'ntp': |
| 105 | + panic => false, |
| 106 | + } |
| 107 | + EOS |
| 108 | + apply_manifest(pp, :catch_failures => true) |
| 109 | + end |
| 110 | + |
| 111 | + describe file('/etc/ntp.conf') do |
| 112 | + it { should contain 'tinker panic' } |
| 113 | + end |
| 114 | + end |
| 115 | + |
| 116 | + describe 'panic => true' do |
| 117 | + it 'disables the tinker panic setting' do |
| 118 | + pp = <<-EOS |
| 119 | + class { 'ntp': |
| 120 | + panic => true, |
| 121 | + } |
| 122 | + EOS |
| 123 | + apply_manifest(pp, :catch_failures => true) |
| 124 | + end |
| 125 | + |
| 126 | + describe file('/etc/ntp.conf') do |
| 127 | + it { should_not contain 'tinker panic 0' } |
| 128 | + end |
| 129 | + end |
| 130 | + |
| 131 | + describe 'udlc' do |
| 132 | + it 'adds a udlc' do |
| 133 | + pp = "class { 'ntp': udlc => true }" |
| 134 | + apply_manifest(pp, :catch_failures => true) |
| 135 | + end |
| 136 | + |
| 137 | + describe file('/etc/ntp.conf') do |
| 138 | + it { should be_file } |
| 139 | + it { should contain '127.127.1.0' } |
| 140 | + end |
| 141 | + end |
| 142 | + |
| 143 | +end |
0 commit comments