aboutsummaryrefslogtreecommitdiff
path: root/spec/classes
diff options
context:
space:
mode:
Diffstat (limited to 'spec/classes')
-rw-r--r--spec/classes/samba__server__config_spec.rb10
-rw-r--r--spec/classes/samba__server__install_spec.rb9
-rw-r--r--spec/classes/samba__server__service_spec.rb54
-rw-r--r--spec/classes/samba__server_spec.rb66
4 files changed, 139 insertions, 0 deletions
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