Skip to content

Commit

Permalink
Merge pull request #427 from konstruktoid/bats
Browse files Browse the repository at this point in the history
update bats tests
  • Loading branch information
konstruktoid committed May 14, 2024
2 parents 23f711d + a19698a commit 572d40d
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/aide.bats
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bats

@test "Verify aide scheduled check is present" {
run bash -c "stat /etc/cron.daily/aide || systemctl is-enabled aidecheck.timer"
run bash -c "stat /etc/cron.daily/aide || systemctl is-enabled aidecheck.timer"
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion tests/journalctl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ load test_helper
}

@test "Verify FileCreateMode in $RSYSLOGCONF" {
run bash -c "grep '^\$FileCreateMode 0600$' $RSYSLOGCONF"
run bash -c "grep -E '^\$FileCreateMode 06(0|4)0$' $RSYSLOGCONF"
[ "$status" -eq 0 ]
}
2 changes: 1 addition & 1 deletion tests/logindefs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load test_helper
}

@test "Verify ENCRYPT_METHOD in $LOGINDEFS" {
run bash -c "grep '^ENCRYPT_METHOD SHA512$' $LOGINDEFS"
run bash -c "grep -E '^ENCRYPT_METHOD (SHA512|YESCRYPT)$' $LOGINDEFS"
[ "$status" -eq 0 ]
}

Expand Down
4 changes: 2 additions & 2 deletions tests/password.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load test_helper
}

@test "Verify minclass in /etc/security/pwquality.conf" {
run bash -c "grep '^minclass = 3$' /etc/security/pwquality.conf"
run bash -c "grep -E '^minclass = (3|4)$' /etc/security/pwquality.conf"
[ "$status" -eq 0 ]
}

Expand All @@ -33,7 +33,7 @@ load test_helper
}

@test "Verify remember in $COMMONPASSWD" {
run bash -c "grep '^password.*required.*pam_pwhistory.so.*[[:space:]]remember=5$' $COMMONPASSWD"
run bash -c "grep -E '^password(.*required.*pam_pwhistory.so|.*pam_unix.so).*[[:space:]]remember=5$' $COMMONPASSWD"
[ "$status" -eq 0 ]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/postfix.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
load test_helper

@test "Verify postfix smtpd_banner" {
run bash -c "postconf | grep '^smtpd_banner = \$myhostname ESMTP$'"
run bash -c "postconf | grep -E '^smtpd_banner.*\$myhostname( | - )ESMTP$'"
[ "$status" -eq 0 ]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/sshd.bats
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ load test_helper
}

@test "Verify OpenSSH sftp" {
run sshdConfig '^Subsystem sftp internal-sftp$'
run sshdConfig '^Subsystem sftp (internal-sftp|internal-sftp -f LOCAL6 -l INFO)$'
[ "$status" -eq 0 ]
}

Expand Down
4 changes: 2 additions & 2 deletions tests/sysctl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ load test_helper
}

@test "Verify kernel.perf_event_paranoid in /etc/sysctl.* /usr/lib/sysctl.*" {
run bash -c "grep -R '^kernel.perf_event_paranoid.*2$' /etc/sysctl.* /usr/lib/sysctl.*"
run bash -c "grep -ER '^kernel.perf_event_paranoid.*(2|3)$' /etc/sysctl.* /usr/lib/sysctl.*"
[ "$status" -eq 0 ]
}

Expand Down Expand Up @@ -322,7 +322,7 @@ load test_helper
}

@test "Verify sysctl runtime kernel.perf_event_paranoid" {
run sysctlRuntime '^kernel.perf_event_paranoid.*2$'
run sysctlRuntime '^kernel.perf_event_paranoid.*(2|3)$'
[ "$status" -eq 0 ]
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sshdConfig() {
}

sysctlRuntime() {
sysctl --all | grep -i "$1"
sysctl --all | grep -iE "$1"
}

moduliSize() {
Expand Down

0 comments on commit 572d40d

Please sign in to comment.