diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-03-24 14:18:03 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-03-24 14:18:03 -0300 |
commit | 309d5859d9c801218075789fe068869ab49065f5 (patch) | |
tree | dc31d7e0e39b48f75475f374d5301bba10c7c64a /spec | |
parent | 846ed365f19187b50f9aff0c7911b533880398a7 (diff) | |
parent | eb97a2b642499fde7afdb64dfd3e2b7e8c14eacc (diff) | |
download | puppet-samba-309d5859d9c801218075789fe068869ab49065f5.tar.gz puppet-samba-309d5859d9c801218075789fe068869ab49065f5.tar.bz2 |
Merge branch 'master' of https://github.com/ajjahn/puppet-samba
Conflicts:
manifests/server/service.pp
Diffstat (limited to 'spec')
-rw-r--r-- | spec/acceptance/basic_samba_spec.rb | 36 | ||||
-rw-r--r-- | spec/acceptance/nodesets/centos-66-x64.yml | 12 | ||||
-rw-r--r-- | spec/acceptance/nodesets/centos-70-x64.yml | 12 | ||||
-rw-r--r-- | spec/acceptance/nodesets/debian-78-x64.yml | 12 | ||||
-rw-r--r-- | spec/acceptance/nodesets/debian-81-x64.yml | 12 | ||||
-rw-r--r-- | spec/acceptance/nodesets/ubuntu-server-1204-x86.yml | 13 | ||||
-rw-r--r-- | spec/acceptance/nodesets/ubuntu-server-1404-x64.yml | 12 | ||||
-rw-r--r-- | spec/classes/samba__server__config_spec.rb | 10 | ||||
-rw-r--r-- | spec/classes/samba__server__install_spec.rb | 9 | ||||
-rw-r--r-- | spec/classes/samba__server__service_spec.rb | 54 | ||||
-rw-r--r-- | spec/classes/samba__server_spec.rb | 66 | ||||
-rw-r--r-- | spec/defines/samba__server__user_spec.rb | 14 | ||||
-rw-r--r-- | spec/spec_helper.rb | 8 | ||||
-rw-r--r-- | spec/spec_helper_acceptance.rb | 29 |
14 files changed, 299 insertions, 0 deletions
diff --git a/spec/acceptance/basic_samba_spec.rb b/spec/acceptance/basic_samba_spec.rb new file mode 100644 index 0000000..8a9e363 --- /dev/null +++ b/spec/acceptance/basic_samba_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper_acceptance' + +describe 'basic samba' do + context 'default parameters' do + let(:pp) {" + class { 'samba::server': + workgroup => 'example', + server_string => 'Example Samba Server' + } + + samba::server::share {'example-share': + comment => 'Example Share', + path => '/path/to/share', + guest_only => true, + guest_ok => true, + guest_account => 'guest', + browsable => false, + create_mask => 0777, + force_create_mask => 0777, + directory_mask => 0777, + force_directory_mode => 0777, + force_group => 'group', + force_user => 'user', + hide_dot_files => false, + } + "} + + it 'should apply with no errors' do + apply_manifest(pp, :catch_failures=>true) + end + + it 'should be idempotent' do + apply_manifest(pp, :catch_changes=>true) + end + end +end diff --git a/spec/acceptance/nodesets/centos-66-x64.yml b/spec/acceptance/nodesets/centos-66-x64.yml new file mode 100644 index 0000000..1fffff6 --- /dev/null +++ b/spec/acceptance/nodesets/centos-66-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-66-x64: + roles: + - master + platform: el-6-x86_64 + box: puppetlabs/centos-6.6-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-6.6-64-nocm + hypervisor: vagrant +CONFIG: + log_level: verbose + type: foss + color: false diff --git a/spec/acceptance/nodesets/centos-70-x64.yml b/spec/acceptance/nodesets/centos-70-x64.yml new file mode 100644 index 0000000..845e47e --- /dev/null +++ b/spec/acceptance/nodesets/centos-70-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-70-x64: + roles: + - master + platform: el-7-x86_64 + box: puppetlabs/centos-7.0-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/centos-7.0-64-nocm + hypervisor : vagrant +CONFIG: + log_level: verbose + type: foss + color: false diff --git a/spec/acceptance/nodesets/debian-78-x64.yml b/spec/acceptance/nodesets/debian-78-x64.yml new file mode 100644 index 0000000..c4062fd --- /dev/null +++ b/spec/acceptance/nodesets/debian-78-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + debian-78-x64: + roles: + - master + platform: debian-7-amd64 + box: puppetlabs/debian-7.8-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/debian-7.8-64-nocm + hypervisor: vagrant + +CONFIG: + log_level: verbose + type: foss diff --git a/spec/acceptance/nodesets/debian-81-x64.yml b/spec/acceptance/nodesets/debian-81-x64.yml new file mode 100644 index 0000000..3b1d8aa --- /dev/null +++ b/spec/acceptance/nodesets/debian-81-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + debian-81-x64: + roles: + - master + platform: debian-8-amd64 + box: lazyfrosch/debian-8-jessie-amd64-puppet + box_url: https://vagrantcloud.com/lazyfrosch/boxes/debian-8-jessie-amd64-puppet + hypervisor: vagrant + +CONFIG: + log_level: verbose + type: foss diff --git a/spec/acceptance/nodesets/ubuntu-server-1204-x86.yml b/spec/acceptance/nodesets/ubuntu-server-1204-x86.yml new file mode 100644 index 0000000..c2e8657 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1204-x86.yml @@ -0,0 +1,13 @@ +HOSTS: + ubuntu-server-1204-x64: + roles: + - master + platform: ubuntu-1204-amd64 + box: puppetlabs/ubuntu-12.04-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/boxes/ubuntu-12.04-64-nocm + hypervisor: vagrant + +CONFIG: + log_level: verbose + type: foss + color: false diff --git a/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml new file mode 100644 index 0000000..62e2ea9 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-server-1404-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + ubuntu-server-1404-x64: + roles: + - master + platform: ubuntu-1404-amd64 + box: puppetlabs/ubuntu-14.04-64-nocm + box_url: https://vagrantcloud.com/puppetlabs/ubuntu-14.04-64-nocm + hypervisor: vagrant +CONFIG: + log_level: verbose + type: foss + color: false diff --git a/spec/classes/samba__server__config_spec.rb b/spec/classes/samba__server__config_spec.rb new file mode 100644 index 0000000..5f13aa4 --- /dev/null +++ b/spec/classes/samba__server__config_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +describe 'samba::server::config', :type => :class do + context "on a Debian OS" do + let( :facts ) { { :osfamily => 'Debian' } } + + it { should contain_file('/etc/samba/smb.conf').with_owner('root') } + end +end + diff --git a/spec/classes/samba__server__install_spec.rb b/spec/classes/samba__server__install_spec.rb new file mode 100644 index 0000000..9764687 --- /dev/null +++ b/spec/classes/samba__server__install_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe 'samba::server::install', :type => :class do + context "on a Debian OS" do + let(:facts) {{ :osfamily => 'Debian' }} + it { should contain_package('samba') } + end +end + diff --git a/spec/classes/samba__server__service_spec.rb b/spec/classes/samba__server__service_spec.rb new file mode 100644 index 0000000..4352ec2 --- /dev/null +++ b/spec/classes/samba__server__service_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +describe 'samba::server::service' do + context 'on a Debian os family' do + let(:facts) {{ :osfamily => 'Debian' }} + + it { should contain_service('samba').with_require('Class[Samba::Server::Config]') } + + context 'Debian' do + context 'wheezy' do + let(:facts) {{ :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemmajrelease => '7' }} + it { should contain_service('samba') } + end + context 'jessie' do + let(:facts) {{ :osfamily => 'Debian', + :operatingsystem => 'Debian', + :operatingsystemmajrelease => '8' }} + it { should contain_service('smbd') } + end + end + + context 'Ubuntu' do + let(:facts) {{ :osfamily => 'Debian', :operatingsystem => 'Ubuntu' }} + it { should contain_service('smbd') } + end + end + + context 'on a Redhat os family' do + let(:facts) {{ :osfamily => 'Redhat' }} + it { should contain_service('smb') } + end + + context 'on a Archlinux os family' do + let(:facts) {{ :osfamily => 'Archlinux' }} + it { should contain_service('smbd') } + end + + context 'on Linux os family' do + let(:facts) {{ :osfamily => 'Linux' }} + it { should raise_error(/is not supported by this module./) } + + context 'Gentoo' do + let(:facts) {{ :osfamily => 'Linux', :operatingsystem => 'Gentoo' }} + it { should contain_service('samba') } + end + end + + context 'on an unsupported OS' do + let(:facts) {{ :osfamily => 'Solaris' }} + it { should raise_error(/Solaris is not supported by this module./) } + end +end diff --git a/spec/classes/samba__server_spec.rb b/spec/classes/samba__server_spec.rb new file mode 100644 index 0000000..46c5b15 --- /dev/null +++ b/spec/classes/samba__server_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe 'samba::server' do + let(:facts) {{ :osfamily => 'Debian' }} + + it { should contain_class('samba::server::install') } + it { should contain_class('samba::server::config') } + it { should contain_class('samba::server::service') } + + it { should contain_samba__server__option('interfaces') } + it { should contain_samba__server__option('bind interfaces only') } + it { should contain_samba__server__option('security') } + it { should contain_samba__server__option('server string') } + it { should contain_samba__server__option('unix password sync') } + it { should contain_samba__server__option('workgroup') } + it { should contain_samba__server__option('socket options') } + it { should contain_samba__server__option('deadtime') } + it { should contain_samba__server__option('keepalive') } + it { should contain_samba__server__option('load printers') } + it { should contain_samba__server__option('printing') } + it { should contain_samba__server__option('printcap name') } + it { should contain_samba__server__option('disable spoolss') } + + context 'with hiera shares hash' do + let(:params) {{ + 'shares' => { + 'testShare' => { + 'path' => '/path/to/some/share', + 'browsable' => true, + 'writable' => true, + 'guest_ok' => true, + 'guest_only' => true, + }, + 'testShare2' => { + 'path' => '/some/other/path' + } + } + }} + it { + should contain_samba__server__share( 'testShare' ).with({ + 'path' => '/path/to/some/share', + 'browsable' => true, + 'writable' => true, + 'guest_ok' => true, + 'guest_only' => true, + }) + } + it { should contain_samba__server__share( 'testShare2' ).with_path('/some/other/path') } + end + + context 'with hiera users hash' do + let(:params) {{ + 'users' => { + 'testUser' => { + 'password' => 'testpass01' + }, + 'testUser2' => { + 'password' => 'testpass02' + } + } + }} + it { should contain_samba__server__user( 'testUser' ).with_password('testpass01') } + it { should contain_samba__server__user( 'testUser2' ).with_password('testpass02') } + end + +end diff --git a/spec/defines/samba__server__user_spec.rb b/spec/defines/samba__server__user_spec.rb new file mode 100644 index 0000000..c7ae00c --- /dev/null +++ b/spec/defines/samba__server__user_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe 'samba::server::user', :type => :define do + let(:title) { 'test_user' } + let(:params) {{ :password => 'secret' }} + + it { is_expected.to contain_samba__server__user('test_user') } + it { is_expected.to contain_exec('add smb account for test_user').with( + :command => '/bin/echo -e \'secret\nsecret\n\' | /usr/bin/pdbedit --password-from-stdin -a \'test_user\'', + :unless => '/usr/bin/pdbedit \'test_user\'', + :require => 'User[test_user]', + :notify => 'Class[Samba::Server::Service]' + ) } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..81f98ac --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,8 @@ +require 'puppetlabs_spec_helper/module_spec_helper' + +RSpec.configure do |c| + c.before do + # avoid "Only root can execute commands as other users" + Puppet.features.stubs(:root? => true) + end +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..74187d8 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,29 @@ +require 'beaker-rspec/spec_helper' +require 'beaker-rspec/helpers/serverspec' +require 'pry' + +unless ENV['BEAKER_provision'] == 'no' + hosts.each do |host| + # Install Puppet + if host.is_pe? + install_pe + else + install_puppet + end + end +end + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'samba') + end +end + |