-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathserver_module_spec.rb
More file actions
109 lines (97 loc) · 4.83 KB
/
server_module_spec.rb
File metadata and controls
109 lines (97 loc) · 4.83 KB
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
104
105
106
107
108
109
require 'spec_helper'
describe 'rsync::server::module', :type => :define do
on_supported_os.each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
let :title do
'foobar'
end
let :pre_condition do
'class { "rsync::server": }'
end
let :fragment_name do
"frag-foobar"
end
let :mandatory_params do
{ :path => '/some/path' }
end
let :params do
mandatory_params
end
describe "when using default class paramaters" do
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^\[ foobar \]$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^path\s*=\s*\/some\/path$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^read only\s*=\s*yes$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^write only\s*=\s*no$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^list\s*=\s*yes$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^uid\s*=\s*0$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^gid\s*=\s*0$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^incoming chmod.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^outgoing chmod.*$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*0$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^secrets file\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts allow\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^hosts deny\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^transfer logging\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^log format\s*=.*$/) }
it { is_expected.not_to contain_concat__fragment(fragment_name).with_content(/^refuse options\s*=.*$/) }
end
describe "when overriding max connections" do
let :params do
mandatory_params.merge({ :max_connections => 1 })
end
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^max connections\s*=\s*1$/) }
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^lock file\s*=\s*\/var\/run\/rsyncd\.lock$/) }
end
describe "when setting incoming chmod to false" do
let :params do
mandatory_params.merge({:incoming_chmod => false,
:outgoing_chmod => false,
})
end
it { is_expected.not_to contain_file(fragment_name).with_content(/^incoming chmod.*$/) }
it { is_expected.not_to contain_file(fragment_name).with_content(/^outgoing chmod.*$/) }
end
{
:comment => 'super module !',
:read_only => 'no',
:write_only => 'yes',
:list => 'no',
:uid => '4682',
:gid => '4682',
:incoming_chmod => '0777',
:outgoing_chmod => '0777',
:secrets_file => '/path/to/secrets',
:hosts_allow => ['localhost', '169.254.42.51'],
:hosts_deny => ['some-host.example.com', '10.0.0.128'],
:transfer_logging => 'true',
:log_format => '%t %a %m %f %b',
:refuse_options => ['c', 'delete'],
:ignore_nonreadable => 'yes'
}.each do |k,v|
describe "when overriding #{k}" do
let :params do
mandatory_params.merge({ k => v })
end
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{Array(v).join(' ')}$/)}
end
end
describe "when overriding auth_users" do
let :params do
mandatory_params.merge({ :auth_users => ['me', 'you', 'them'] })
end
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^auth users\s*=\s*me, you, them$/)}
end
describe "when overriding log_file" do
let :params do
mandatory_params.merge({ :log_file => '/var/log/rsync.log' })
end
it { is_expected.to contain_concat__fragment(fragment_name).with_content(/^log file\s*=\s*\/var\/log\/rsync.log$/)}
end
end
end
end