aboutsummaryrefslogtreecommitdiff
path: root/spec/defines/samba__server__share_spec.rb
blob: e6b24b854908d20e7219c3e876cb19b70053ee44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
require 'spec_helper'

describe 'samba::server::share', :type => :define do
  let(:pre_condition){ 'class{"samba::server":}'}
  on_supported_os.each do |os, facts|
    context "When on an #{os} system" do
      let(:facts) do
        facts.merge({
          :concat_basedir => '/tmp',
          :domain => 'domain.com'
        })
      end

      context 'when called with base options' do
        let(:title) { 'test_share' }
        let(:params) {{
          :ensure => 'present'
        }}

        it { is_expected.to contain_samba__server__share('test_share') }
        it { is_expected.to contain_augeas('test_share-section').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          :changes => ["set target[. = 'test_share'] 'test_share'"]
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
        it { is_expected.to contain_augeas('test_share-changes').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
      end#no params

      context 'when called with ensure set to absent' do
        let(:title) { 'test_share' }
        let(:params) {{
          :ensure => 'absent'
        }}

        it 'should not contain the share'  do
          skip 'this is not working'
          should_not contain_samba__server__share('test_share')
        end
      end#no params

      context 'when called with available set to true' do
        let(:title) { 'test_share' }
        let(:params) {{
          :ensure    => 'present',
          :available => true,
        }}
        it { is_expected.to contain_samba__server__share('test_share') }
        it { is_expected.to contain_augeas('test_share-section').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          :changes => ["set target[. = 'test_share'] 'test_share'"]
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
        it { is_expected.to contain_augeas('test_share-changes').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          :changes => ["set \"target[. = 'test_share']/available\" yes"]
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
      end#no params

      context 'when called with root_preexec set to something' do
        let(:title) { 'test_share' }
        let(:params) {{
          :ensure    => 'present',
          :root_preexec => '/bin/true',
        }}
        it { is_expected.to contain_samba__server__share('test_share') }
        it { is_expected.to contain_augeas('test_share-section').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          :changes => ["set target[. = 'test_share'] 'test_share'"]
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
        it { is_expected.to contain_augeas('test_share-changes').with(
          :incl    => '/etc/samba/smb.conf',
          :lens    => 'Samba.lns',
          :context => '/files/etc/samba/smb.conf',
          :changes => ["set \"target[. = 'test_share']/root_preexec\" /bin/true"]
          ).that_requires('Class[Samba::Server::Config]'
          ).that_notifies('Class[Samba::Server::Service]')
        }
      end#no params

    end
  end
end