-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathclamav_spec.rb
117 lines (99 loc) · 4.03 KB
/
clamav_spec.rb
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
110
111
112
113
114
115
116
117
require 'spec_helper'
describe 'clamav', type: :class do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(environment: 'test')
end
context 'with defaults' do
it { is_expected.to compile.with_all_deps }
if facts[:osfamily] == 'RedHat'
it { is_expected.to contain_class('epel') }
elsif facts[:osfamily] == 'Debian'
it { is_expected.not_to contain_class('epel') }
end
it { is_expected.not_to contain_class('clamav::user') }
it { is_expected.to contain_class('clamav::install') }
it { is_expected.not_to contain_class('clamav::clamd') }
it { is_expected.not_to contain_class('clamav::freshclam') }
end
context 'manage user' do
let(:params) { { manage_user: true } }
it { is_expected.to contain_class('clamav::user') }
end
context 'disable epel on RedHat' do
let(:params) { { manage_repo: false } }
it { is_expected.not_to contain_class('epel') }
end
context 'manage clamd and freshclam' do
let(:params) { { manage_clamd: true, manage_freshclam: true } }
it { is_expected.to contain_class('clamav::clamd') }
it { is_expected.to contain_class('clamav::freshclam') }
end
context 'manage manage_clamav_milter' do
if facts[:osfamily] == 'RedHat' && facts[:operatingsystemrelease] >= '7.0'
let(:params) { { manage_clamav_milter: true } }
it { is_expected.to contain_class('clamav::clamav_milter') }
end
end
context 'clamav::user' do
let(:params) { { manage_user: true } }
context 'with defaults' do
it { is_expected.to contain_group('clamav') }
it { is_expected.to contain_user('clamav') }
end
context 'disable group and user' do
let(:params) { { manage_user: true, group: false, user: false } }
it { is_expected.not_to contain_group('clamav') }
it { is_expected.not_to contain_user('clamav') }
end
end
context 'clamav::install' do
context 'with defaults' do
it { is_expected.to contain_package('clamav') }
end
end
context 'clamav::clamd' do
let(:params) { { manage_clamd: true } }
context 'with defaults' do
it { is_expected.to contain_package('clamd') }
it { is_expected.to contain_file('clamd.conf') }
it { is_expected.to contain_service('clamd') }
end
end
context 'clamav::freshclam' do
let(:params) { { manage_freshclam: true } }
context 'with defaults' do
if facts[:osfamily] == 'RedHat'
if facts[:operatingsystemmajrelease].to_i == 6
it 'is valid when there is no freshclam package' do
is_expected.not_to contain_package('freshclam')
end
it 'is valid when there no file freshclam_sysconfig' do
is_expected.not_to contain_file('freshclam_sysconfig')
end
elsif facts[:operatingsystemmajrelease].to_i == 7
it 'is valid when there is freshclam package' do
is_expected.to contain_package('freshclam')
end
it 'is valid when there is freshclam_sysconfig file' do
is_expected.to contain_file('freshclam_sysconfig')
end
end
it 'is valid when there is freshclam.conf file' do
is_expected.to contain_file('freshclam.conf')
end
it 'is valid when there is no freshclam service' do
is_expected.not_to contain_service('freshclam')
end
elsif facts[:osfamily] == 'Debian'
it { is_expected.to contain_package('freshclam') }
it { is_expected.to contain_file('freshclam.conf') }
it { is_expected.to contain_service('freshclam') }
it { is_expected.not_to contain_file('freshclam_sysconfig') }
end
end
end
end
end
end