summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/ntp_spec.rb261
-rw-r--r--spec/fixtures/modules/my_ntp/templates/ntp.conf.erb4
-rw-r--r--spec/spec.opts6
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/spec_helper_system.rb26
-rw-r--r--spec/system/basic_spec.rb13
-rw-r--r--spec/system/class_spec.rb39
-rw-r--r--spec/system/ntp_config_spec.rb35
-rw-r--r--spec/system/ntp_install_spec.rb31
-rw-r--r--spec/system/ntp_service_spec.rb25
-rw-r--r--spec/system/preferred_servers_spec.rb20
-rw-r--r--spec/system/restrict_spec.rb20
-rw-r--r--spec/unit/puppet/provider/README.markdown4
-rw-r--r--spec/unit/puppet/type/README.markdown4
14 files changed, 0 insertions, 489 deletions
diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb
deleted file mode 100644
index 6c636f40..00000000
--- a/spec/classes/ntp_spec.rb
+++ /dev/null
@@ -1,261 +0,0 @@
-require 'spec_helper'
-
-describe 'ntp' do
-
- ['Debian', 'RedHat','SuSE', 'FreeBSD', 'Archlinux', 'Gentoo'].each do |system|
- if system == 'Gentoo'
- let(:facts) {{ :osfamily => 'Linux', :operatingsystem => system }}
- else
- let(:facts) {{ :osfamily => system }}
- end
-
- it { should include_class('ntp::install') }
- it { should include_class('ntp::config') }
- it { should include_class('ntp::service') }
-
- describe 'ntp::config on #{system}' do
- it { should contain_file('/etc/ntp.conf').with_owner('0') }
- it { should contain_file('/etc/ntp.conf').with_group('0') }
- it { should contain_file('/etc/ntp.conf').with_mode('0644') }
-
- describe 'allows template to be overridden' do
- let(:params) {{ :config_template => 'my_ntp/ntp.conf.erb' }}
- it { should contain_file('/etc/ntp.conf').with({
- 'content' => /server foobar/})
- }
- end
-
- describe "keys for osfamily #{system}" do
- context "when enabled" do
- 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(: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
-
- describe 'preferred servers' do
- context "when set" do
- let(:params) {{
- :servers => ['a', 'b', 'c', 'd'],
- :preferred_servers => ['a', 'b']
- }}
-
- it { should contain_file('/etc/ntp.conf').with({
- 'content' => /server a prefer\nserver b prefer\nserver c\nserver d/})
- }
- end
- context "when not set" do
- let(:params) {{
- :servers => ['a', 'b', 'c', 'd'],
- :preferred_servers => []
- }}
-
- it { should_not contain_file('/etc/ntp.conf').with({
- 'content' => /server a prefer/})
- }
- end
- end
-
- describe 'ntp::install on #{system}' do
- let(:params) {{ :package_ensure => 'present', :package_name => ['ntp'], }}
-
- it { should contain_package('ntp').with(
- :ensure => 'present',
- :name => 'ntp'
- )}
-
- describe 'should allow package ensure to be overridden' do
- let(:params) {{ :package_ensure => 'latest', :package_name => ['ntp'] }}
- it { should contain_package('ntp').with_ensure('latest') }
- end
-
- describe 'should allow the package name to be overridden' do
- let(:params) {{ :package_ensure => 'present', :package_name => ['hambaby'] }}
- it { should contain_package('ntp').with_name('hambaby') }
- end
- end
-
- describe 'ntp::service' do
- let(:params) {{
- :service_manage => true,
- :service_enable => true,
- :service_ensure => 'running',
- :service_name => 'ntp'
- }}
-
- describe 'with defaults' do
- it { should contain_service('ntp').with(
- :enable => true,
- :ensure => 'running',
- :name => 'ntp'
- )}
- end
-
- describe 'service_ensure' do
- describe 'when overridden' do
- let(:params) {{ :service_name => 'ntp', :service_ensure => 'stopped' }}
- it { should contain_service('ntp').with_ensure('stopped') }
- end
- end
-
- describe 'service_manage' do
- let(:params) {{
- :service_manage => false,
- :service_enable => true,
- :service_ensure => 'running',
- :service_name => 'ntpd',
- }}
-
- it 'when set to false' do
- should_not contain_service('ntp').with({
- 'enable' => true,
- 'ensure' => 'running',
- 'name' => 'ntpd'
- })
- end
- end
- end
- end
-
- context 'ntp::config' do
- describe "for operating system Gentoo" do
- let(:facts) {{ :operatingsystem => 'Gentoo',
- :osfamily => 'Linux' }}
-
- it 'uses the NTP pool servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.gentoo.pool.ntp.org/,
- })
- end
- end
- describe "on osfamily Debian" do
- let(:facts) {{ :osfamily => 'debian' }}
-
- it 'uses the debian ntp servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.debian.pool.ntp.org iburst/,
- })
- end
- end
-
- describe "on osfamily RedHat" do
- let(:facts) {{ :osfamily => 'RedHat' }}
-
- it 'uses the redhat ntp servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.centos.pool.ntp.org/,
- })
- end
- end
-
- describe "on osfamily SuSE" do
- let(:facts) {{ :osfamily => 'SuSE' }}
-
- it 'uses the opensuse ntp servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.opensuse.pool.ntp.org/,
- })
- end
- end
-
- describe "on osfamily FreeBSD" do
- let(:facts) {{ :osfamily => 'FreeBSD' }}
-
- it 'uses the freebsd ntp servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.freebsd.pool.ntp.org iburst maxpoll 9/,
- })
- end
- end
-
- describe "on osfamily ArchLinux" do
- let(:facts) {{ :osfamily => 'ArchLinux' }}
-
- it 'uses the NTP pool servers by default' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /server \d.pool.ntp.org/,
- })
- end
- end
-
- describe "for operating system family unsupported" do
- let(:facts) {{
- :osfamily => 'unsupported',
- }}
-
- it { expect{ subject }.to raise_error(
- /^The ntp module is not supported on an unsupported based system./
- )}
- end
- end
-
- describe 'for virtual machines' do
- let(:facts) {{ :osfamily => 'Archlinux',
- :is_virtual => 'true' }}
-
- it 'should not use local clock as a time source' do
- should_not contain_file('/etc/ntp.conf').with({
- 'content' => /server.*127.127.1.0.*fudge.*127.127.1.0 stratum 10/,
- })
- end
-
- it 'allows large clock skews' do
- should contain_file('/etc/ntp.conf').with({
- 'content' => /tinker panic 0/,
- })
- end
- end
-
- describe 'for physical machines' do
- let(:facts) {{ :osfamily => 'Archlinux',
- :is_virtual => 'false' }}
-
- it 'disallows large clock skews' do
- should_not contain_file('/etc/ntp.conf').with({
- 'content' => /tinker panic 0/,
- })
- end
- end
- end
-
-end
diff --git a/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb b/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb
deleted file mode 100644
index 40cf67c6..00000000
--- a/spec/fixtures/modules/my_ntp/templates/ntp.conf.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-#my uber ntp config
-#
-
-server foobar
diff --git a/spec/spec.opts b/spec/spec.opts
deleted file mode 100644
index 91cd6427..00000000
--- a/spec/spec.opts
+++ /dev/null
@@ -1,6 +0,0 @@
---format
-s
---colour
---loadby
-mtime
---backtrace
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
deleted file mode 100644
index 2c6f5664..00000000
--- a/spec/spec_helper.rb
+++ /dev/null
@@ -1 +0,0 @@
-require 'puppetlabs_spec_helper/module_spec_helper'
diff --git a/spec/spec_helper_system.rb b/spec/spec_helper_system.rb
deleted file mode 100644
index d5208463..00000000
--- a/spec/spec_helper_system.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'rspec-system/spec_helper'
-require 'rspec-system-puppet/helpers'
-require 'rspec-system-serverspec/helpers'
-include Serverspec::Helper::RSpecSystem
-include Serverspec::Helper::DetectOS
-include RSpecSystemPuppet::Helpers
-
-RSpec.configure do |c|
- # Project root
- proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
-
- # Enable colour
- c.tty = true
-
- c.include RSpecSystemPuppet::Helpers
-
- # This is where we 'setup' the nodes before running our tests
- c.before :suite do
- # Install puppet
- puppet_install
-
- # Install modules and dependencies
- puppet_module_install(:source => proj_root, :module_name => 'ntp')
- shell('puppet module install puppetlabs-stdlib')
- end
-end
diff --git a/spec/system/basic_spec.rb b/spec/system/basic_spec.rb
deleted file mode 100644
index 7b717a04..00000000
--- a/spec/system/basic_spec.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'spec_helper_system'
-
-# Here we put the more basic fundamental tests, ultra obvious stuff.
-describe "basic tests:" do
- context 'make sure we have copied the module across' do
- # No point diagnosing any more if the module wasn't copied properly
- context shell 'ls /etc/puppet/modules/ntp' do
- its(:stdout) { should =~ /Modulefile/ }
- its(:stderr) { should be_empty }
- its(:exit_code) { should be_zero }
- end
- end
-end
diff --git a/spec/system/class_spec.rb b/spec/system/class_spec.rb
deleted file mode 100644
index 49dfc641..00000000
--- a/spec/system/class_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-require 'spec_helper_system'
-
-describe "ntp class:" do
- context 'should run successfully' do
- pp = "class { 'ntp': }"
-
- context puppet_apply(pp) do
- its(:stderr) { should be_empty }
- its(:exit_code) { should_not == 1 }
- its(:refresh) { should be_nil }
- its(:stderr) { should be_empty }
- its(:exit_code) { should be_zero }
- end
- end
-
- context 'service_ensure => stopped:' do
- pp = "class { 'ntp': service_ensure => stopped }"
-
- context puppet_apply(pp) do
- its(:stderr) { should be_empty }
- its(:exit_code) { should_not == 1 }
- its(:refresh) { should be_nil }
- its(:stderr) { should be_empty }
- its(:exit_code) { should be_zero }
- end
- end
-
- context 'service_ensure => running:' do
- pp = "class { 'ntp': service_ensure => running }"
-
- context puppet_apply(pp) do |r|
- its(:stderr) { should be_empty }
- its(:exit_code) { should_not == 1 }
- its(:refresh) { should be_nil }
- its(:stderr) { should be_empty }
- its(:exit_code) { should be_zero }
- end
- end
-end
diff --git a/spec/system/ntp_config_spec.rb b/spec/system/ntp_config_spec.rb
deleted file mode 100644
index 194cdf10..00000000
--- a/spec/system/ntp_config_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper_system'
-
-describe 'ntp::config class' do
- let(:os) {
- node.facts['osfamily']
- }
-
- puppet_apply(%{
- class { 'ntp': }
- })
-
- case node.facts['osfamily']
- when 'FreeBSD'
- line = '0.freebsd.pool.ntp.org iburst maxpoll 9'
- when 'Debian'
- line = '0.debian.pool.ntp.org iburst'
- when 'RedHat'
- line = '0.centos.pool.ntp.org'
- when 'SuSE'
- line = '0.opensuse.pool.ntp.org'
- when 'Linux'
- case node.facts['operatingsystem']
- when 'ArchLinux'
- line = '0.pool.ntp.org'
- when 'Gentoo'
- line = '0.gentoo.pool.ntp.org'
- end
- end
-
- describe file('/etc/ntp.conf') do
- it { should be_file }
- it { should contain line }
- end
-
-end
diff --git a/spec/system/ntp_install_spec.rb b/spec/system/ntp_install_spec.rb
deleted file mode 100644
index 39759c5e..00000000
--- a/spec/system/ntp_install_spec.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require 'spec_helper_system'
-
-
-describe 'ntp::install class' do
- let(:os) {
- node.facts['osfamily']
- }
-
- case node.facts['osfamily']
- when 'FreeBSD'
- packagename = 'net/ntp'
- when 'Linux'
- case node.facts['operatingsystem']
- when 'ArchLinux'
- packagename = 'ntp'
- when 'Gentoo'
- packagename = 'net-misc/ntp'
- end
- else
- packagename = 'ntp'
- end
-
- puppet_apply(%{
- class { 'ntp': }
- })
-
- describe package(packagename) do
- it { should be_installed }
- end
-
-end
diff --git a/spec/system/ntp_service_spec.rb b/spec/system/ntp_service_spec.rb
deleted file mode 100644
index b97e2a4e..00000000
--- a/spec/system/ntp_service_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'spec_helper_system'
-
-
-describe 'ntp::service class' do
- let(:os) {
- node.facts['osfamily']
- }
-
- case node.facts['osfamily']
- when 'RedHat', 'FreeBSD', 'Linux'
- servicename = 'ntpd'
- else
- servicename = 'ntp'
- end
-
- puppet_apply(%{
- class { 'ntp': }
- })
-
- describe service(servicename) do
- it { should be_enabled }
- it { should be_running }
- end
-
-end
diff --git a/spec/system/preferred_servers_spec.rb b/spec/system/preferred_servers_spec.rb
deleted file mode 100644
index 686861bc..00000000
--- a/spec/system/preferred_servers_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'spec_helper_system'
-
-describe 'preferred servers' do
- it 'applies cleanly' do
- puppet_apply(%{
- class { '::ntp':
- servers => ['a', 'b', 'c', 'd'],
- preferred_servers => ['c', 'd'],
- }
- })
- end
-
- describe file('/etc/ntp.conf') do
- it { should be_file }
- it { should contain 'server a' }
- it { should contain 'server b' }
- it { should contain 'server c prefer' }
- it { should contain 'server d prefer' }
- end
-end
diff --git a/spec/system/restrict_spec.rb b/spec/system/restrict_spec.rb
deleted file mode 100644
index ae23bc01..00000000
--- a/spec/system/restrict_spec.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-require 'spec_helper_system'
-
-describe "ntp class with restrict:" do
- context 'should run successfully' do
- pp = "class { 'ntp': restrict => ['test restrict']}"
-
- context puppet_apply(pp) do
- its(:stderr) { should be_empty }
- its(:exit_code) { should_not == 1 }
- its(:refresh) { should be_nil }
- its(:stderr) { should be_empty }
- its(:exit_code) { should be_zero }
- end
- end
-
- describe file('/etc/ntp.conf') do
- it { should contain('test restrict') }
- end
-
-end
diff --git a/spec/unit/puppet/provider/README.markdown b/spec/unit/puppet/provider/README.markdown
deleted file mode 100644
index 70258502..00000000
--- a/spec/unit/puppet/provider/README.markdown
+++ /dev/null
@@ -1,4 +0,0 @@
-Provider Specs
-==============
-
-Define specs for your providers under this directory.
diff --git a/spec/unit/puppet/type/README.markdown b/spec/unit/puppet/type/README.markdown
deleted file mode 100644
index 1ee19ac8..00000000
--- a/spec/unit/puppet/type/README.markdown
+++ /dev/null
@@ -1,4 +0,0 @@
-Resource Type Specs
-===================
-
-Define specs for your resource types in this directory.