|
155 | 155 | }
|
156 | 156 | end
|
157 | 157 |
|
158 |
| - describe 'with parameters' do |
| 158 | + describe 'with custom rules' do |
159 | 159 | let :params do
|
160 | 160 | {
|
161 | 161 | custom_rules: true,
|
|
173 | 173 | it { is_expected.to contain_file('/etc/httpd/modsecurity.d/custom_rules/custom_01_rules.conf').with_content %r{^\s*.*"id:199999,phase:1,nolog,allow,ctl:ruleEngine=off"$} }
|
174 | 174 | end
|
175 | 175 |
|
| 176 | + describe 'with custom actions' do |
| 177 | + let :params do |
| 178 | + { |
| 179 | + custom_rules: true, |
| 180 | + custom_actions_set: ['id:199999,phase:1,pass,nolog,t:none,initcol:global=global'] |
| 181 | + } |
| 182 | + end |
| 183 | + |
| 184 | + it { |
| 185 | + expect(subject).to contain_file('/etc/httpd/modsecurity.d/custom_rules').with( |
| 186 | + ensure: 'directory', path: '/etc/httpd/modsecurity.d/custom_rules', |
| 187 | + owner: 'apache', group: 'apache' |
| 188 | + ) |
| 189 | + } |
| 190 | + |
| 191 | + it { is_expected.to contain_file('/etc/httpd/modsecurity.d/custom_rules/custom_01_rules.conf').with_content %r{^\s*.*id:199999,phase:1,pass,nolog,t:none,initcol:global=global$} } |
| 192 | + end |
| 193 | + |
176 | 194 | describe 'with CRS parameters' do
|
177 | 195 | let :params do
|
178 | 196 | {
|
|
284 | 302 | )
|
285 | 303 | }
|
286 | 304 |
|
| 305 | + it { is_expected.to contain_apache__security__rule_link('rules/crawlers-user-agents.data') } |
| 306 | + |
| 307 | + it { |
| 308 | + expect(subject).to contain_file('crawlers-user-agents.data').with( |
| 309 | + path: '/etc/modsecurity/activated_rules/crawlers-user-agents.data', |
| 310 | + target: '/usr/share/modsecurity-crs/rules/crawlers-user-agents.data', |
| 311 | + ) |
| 312 | + } |
| 313 | + |
287 | 314 | it {
|
288 | 315 | expect(subject).to contain_file('/etc/modsecurity/security_crs.conf').with(
|
289 | 316 | path: '/etc/modsecurity/security_crs.conf',
|
|
302 | 329 | }
|
303 | 330 | end
|
304 | 331 |
|
305 |
| - describe 'with parameters' do |
| 332 | + describe 'with custom rules' do |
306 | 333 | let :params do
|
307 | 334 | {
|
308 | 335 | custom_rules: true,
|
|
320 | 347 | it { is_expected.to contain_file('/etc/modsecurity/custom_rules/custom_01_rules.conf').with_content %r{\s*.*"id:199999,phase:1,nolog,allow,ctl:ruleEngine=off"$} }
|
321 | 348 | end
|
322 | 349 |
|
| 350 | + describe 'with custom actions' do |
| 351 | + let :params do |
| 352 | + { |
| 353 | + custom_rules: true, |
| 354 | + custom_actions_set: ['id:199999,phase:1,pass,nolog,t:none,initcol:global=global'] |
| 355 | + } |
| 356 | + end |
| 357 | + |
| 358 | + it { |
| 359 | + expect(subject).to contain_file('/etc/modsecurity/custom_rules').with( |
| 360 | + ensure: 'directory', path: '/etc/modsecurity/custom_rules', |
| 361 | + owner: 'www-data', group: 'www-data' |
| 362 | + ) |
| 363 | + } |
| 364 | + |
| 365 | + it { is_expected.to contain_file('/etc/modsecurity/custom_rules/custom_01_rules.conf').with_content %r{\s*.*id:199999,phase:1,pass,nolog,t:none,initcol:global=global$} } |
| 366 | + end |
| 367 | + |
| 368 | + describe 'with absolute path to activated rule' do |
| 369 | + let :params do |
| 370 | + { |
| 371 | + activated_rules: ['/tmp/foo/bar.conf'] |
| 372 | + } |
| 373 | + end |
| 374 | + |
| 375 | + it { is_expected.to contain_apache__security__rule_link('/tmp/foo/bar.conf') } |
| 376 | + |
| 377 | + it { |
| 378 | + expect(subject).to contain_file('bar.conf').with( |
| 379 | + path: '/etc/modsecurity/activated_rules/bar.conf', |
| 380 | + target: '/tmp/foo/bar.conf', |
| 381 | + ) |
| 382 | + } |
| 383 | + end |
| 384 | + describe 'with relative path to activated rule' do |
| 385 | + let :params do |
| 386 | + { |
| 387 | + activated_rules: ['rules/bar.conf'] |
| 388 | + } |
| 389 | + end |
| 390 | + |
| 391 | + it { is_expected.to contain_apache__security__rule_link('rules/bar.conf') } |
| 392 | + it { |
| 393 | + expect(subject).to contain_file('bar.conf').with( |
| 394 | + path: '/etc/modsecurity/activated_rules/bar.conf', |
| 395 | + target: '/usr/share/modsecurity-crs/rules/bar.conf', |
| 396 | + ) |
| 397 | + } |
| 398 | + end |
| 399 | + |
323 | 400 | describe 'with mod security version' do
|
324 | 401 | let :params do
|
325 | 402 | {
|
|
0 commit comments