|
387 | 387 | context 'with deprecated parameters' do |
388 | 388 | context 'disable audit_cfg_sudoers using deprecated audit_sudoers' do |
389 | 389 | let(:hieradata) { 'simp_audit_profile/disable__audit_sudoers' } |
| 390 | + |
390 | 391 | [ |
391 | 392 | %r{^-w /etc/sudoers -p wa -k CFG_sys$}, |
392 | 393 | %r{^-w /etc/sudoers.d/ -p wa -k CFG_sys$}, |
393 | 394 | ].each do |command_regex| |
394 | | - it { |
395 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
396 | | - with_content(command_regex) |
397 | | - } |
| 395 | + it do |
| 396 | + if Puppet[:strict] == :error |
| 397 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_sudoers' is deprecated\.}) |
| 398 | + else |
| 399 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
| 400 | + with_content(command_regex) |
| 401 | + end |
| 402 | + end |
398 | 403 | end |
399 | 404 | end |
400 | 405 |
|
401 | 406 | context 'set audit_cfg_sudoers rule key using deprecated audit_sudoers_tag' do |
402 | 407 | let(:hieradata) { 'simp_audit_profile/set__audit_sudoers_tag' } |
| 408 | + |
403 | 409 | [ |
404 | 410 | %r{^-w /etc/sudoers -p wa -k old_sudoers_tag$}, |
405 | 411 | %r{^-w /etc/sudoers.d/ -p wa -k old_sudoers_tag$}, |
406 | 412 | ].each do |command_regex| |
407 | | - it { |
408 | | - is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
409 | | - with_content(command_regex) |
410 | | - } |
| 413 | + it do |
| 414 | + if Puppet[:strict] == :error |
| 415 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_sudoers_tag' is deprecated\.}) |
| 416 | + else |
| 417 | + is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
| 418 | + with_content(command_regex) |
| 419 | + end |
| 420 | + end |
411 | 421 | end |
412 | 422 |
|
413 | 423 | [ |
414 | 424 | %r{^-w /etc/sudoers -p wa -k CFG_sys$}, |
415 | 425 | %r{^-w /etc/sudoers.d/ -p wa -k CFG_sys$}, |
416 | 426 | ].each do |command_regex| |
417 | | - it { |
418 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
419 | | - with_content(command_regex) |
420 | | - } |
| 427 | + it do |
| 428 | + if Puppet[:strict] == :error |
| 429 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_sudoers_tag' is deprecated\.}) |
| 430 | + else |
| 431 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules'). |
| 432 | + with_content(command_regex) |
| 433 | + end |
| 434 | + end |
421 | 435 | end |
422 | 436 | end |
423 | 437 |
|
424 | 438 | context 'disable audit_cfg_grub using deprecated audit_grub' do |
425 | 439 | let(:hieradata) { 'simp_audit_profile/disable__audit_grub' } |
426 | | - it { |
427 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
428 | | - %r{^.* -k CFG_grub$} |
429 | | - ) |
430 | | - } |
| 440 | + |
| 441 | + it do |
| 442 | + if Puppet[:strict] == :error |
| 443 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_grub' is deprecated\.}) |
| 444 | + else |
| 445 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 446 | + %r{^.* -k CFG_grub$} |
| 447 | + ) |
| 448 | + end |
| 449 | + end |
431 | 450 | end |
432 | 451 |
|
433 | 452 | context 'set audit_cfg_grub rule key using deprecated audit_grub_tag' do |
434 | 453 | let(:hieradata) { 'simp_audit_profile/set__audit_grub_tag' } |
435 | 454 |
|
436 | | - it { |
437 | | - is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
438 | | - %r{^.*grub.(d|conf).* -k old_grub_tag$} |
439 | | - ) |
440 | | - } |
| 455 | + it do |
| 456 | + if Puppet[:strict] == :error |
| 457 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_grub_tag' is deprecated\.}) |
| 458 | + else |
| 459 | + is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 460 | + %r{^.*grub.(d|conf).* -k old_grub_tag$} |
| 461 | + ) |
| 462 | + end |
| 463 | + end |
441 | 464 |
|
442 | | - it { |
443 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
444 | | - %r{^.* -k CFG_grub$} |
445 | | - ) |
446 | | - } |
| 465 | + it do |
| 466 | + if Puppet[:strict] == :error |
| 467 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_grub_tag' is deprecated\.}) |
| 468 | + else |
| 469 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 470 | + %r{^.* -k CFG_grub$} |
| 471 | + ) |
| 472 | + end |
| 473 | + end |
447 | 474 | end |
448 | 475 |
|
449 | 476 | context 'disable audit_cfg_yum using deprecated audit_yum' do |
450 | 477 | let(:hieradata) { 'simp_audit_profile/disable__audit_yum' } |
451 | | - it { |
452 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
453 | | - %r{^.* -k yum_config$} |
454 | | - ) |
455 | | - } |
| 478 | + |
| 479 | + it do |
| 480 | + if Puppet[:strict] == :error |
| 481 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_yum' is deprecated\.}) |
| 482 | + else |
| 483 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 484 | + %r{^.* -k yum_config$} |
| 485 | + ) |
| 486 | + end |
| 487 | + end |
456 | 488 | end |
457 | 489 |
|
458 | 490 | context 'set audit_cfg_yum rule key using deprecated audit_yum_tag' do |
459 | 491 | let(:hieradata) { 'simp_audit_profile/set__audit_yum_tag' } |
460 | 492 |
|
461 | | - it { |
462 | | - is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
463 | | - %r{^.*/etc/yum.* -k old_yum_tag$} |
464 | | - ) |
465 | | - } |
| 493 | + it do |
| 494 | + if Puppet[:strict] == :error |
| 495 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_yum_tag' is deprecated\.}) |
| 496 | + else |
| 497 | + is_expected.to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 498 | + %r{^.*/etc/yum.* -k old_yum_tag$} |
| 499 | + ) |
| 500 | + end |
| 501 | + end |
466 | 502 |
|
467 | | - it { |
468 | | - is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
469 | | - %r{^.* -k yum_config$} |
470 | | - ) |
471 | | - } |
| 503 | + it do |
| 504 | + if Puppet[:strict] == :error |
| 505 | + is_expected.to compile.and_raise_error(%r{'auditd::config::audit_profiles::simp::audit_yum_tag' is deprecated\.}) |
| 506 | + else |
| 507 | + is_expected.not_to contain_file('/etc/audit/rules.d/50_00_simp_base.rules').with_content( |
| 508 | + %r{^.* -k yum_config$} |
| 509 | + ) |
| 510 | + end |
| 511 | + end |
472 | 512 | end |
473 | 513 | end |
474 | 514 | end |
|
0 commit comments