mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-21 21:17:00 +01:00
Improve user management in test cases
This commit is contained in:
parent
1281860401
commit
1586dae0c5
@ -6,28 +6,25 @@ test_audit() {
|
||||
# shellcheck disable=2154
|
||||
run blank /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||
|
||||
useradd usertest1
|
||||
useradd usertest2
|
||||
sed -i 's/1001/1000/g' /etc/passwd
|
||||
useradd -u 1001 usertest1
|
||||
useradd -o -u 1001 usertest2
|
||||
|
||||
# Proceed to operation that will end up to a non compliant system
|
||||
describe Tests purposely failing
|
||||
register_test retvalshouldbe 1
|
||||
register_test contain "[ KO ] Duplicate UID (1000): usertest1 usertest2"
|
||||
register_test contain "[ KO ] Duplicate UID (1001): usertest1 usertest2"
|
||||
run noncompliant /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||
|
||||
# shellcheck disable=2016
|
||||
echo 'EXCEPTIONS="$EXCEPTIONS 1000"' >> /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||
echo 'EXCEPTIONS="$EXCEPTIONS 1001"' >> /opt/debian-cis/etc/conf.d/"${script}".cfg
|
||||
|
||||
describe Adding exceptions
|
||||
register_test retvalshouldbe 0
|
||||
register_test contain "[ OK ] No duplicate UIDs apart from configured exceptions: (1000): usertest1 usertest2"
|
||||
register_test contain "[ OK ] No duplicate UIDs apart from configured exceptions: (1001): usertest1 usertest2"
|
||||
run exception /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||
|
||||
# Cleanup
|
||||
userdel usertest1
|
||||
userdel usertest2
|
||||
sed -i '/usertest1/d' /etc/group
|
||||
sed -i '/usertest2/d' /etc/group
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,7 @@ test_audit() {
|
||||
# shellcheck disable=2154
|
||||
run blank /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||
|
||||
useradd usertest1
|
||||
sed -i 's/1000/0/g' /etc/passwd
|
||||
useradd -o -u 0 usertest1
|
||||
|
||||
# Proceed to operation that will end up to a non compliant system
|
||||
describe Tests purposely failing
|
||||
@ -24,8 +23,6 @@ test_audit() {
|
||||
run exception /opt/debian-cis/bin/hardening/"${script}".sh --audit-all
|
||||
|
||||
# Cleanup
|
||||
sed -i '/usertest1/d' /etc/passwd
|
||||
sed -i '/usertest1/d' /etc/shadow
|
||||
sed -i '/usertest1/d' /etc/group
|
||||
userdel -f usertest1
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user