Skip to content

Commit

Permalink
Add test for ownership and permissions of pihole-FTL.db given a restr…
Browse files Browse the repository at this point in the history
…ictive umask on the testing system

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Jun 10, 2019
1 parent 1d3822c commit 420f58a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ echo "BLOCKING_ENABLED=true" > /etc/pihole/setupVars.conf
# Prepare pihole-FTL.conf
echo "" > /etc/pihole/pihole-FTL.conf

# Set restrictive umask
OLDUMASK=$(umask)
umask 0022

# Start FTL
if ! ./pihole-FTL; then
echo "pihole-FTL failed to start"
Expand All @@ -45,4 +49,10 @@ cat /var/log/pihole-FTL.log

# Run tests
test/libs/bats/bin/bats "test/test_suite.bats"
exit $?
RET=$?

# Restore umask
umask $OLDUMASK

# Exit with return code of bats tests
exit $RET
6 changes: 6 additions & 0 deletions test/test_suite.bats
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@
[[ ${lines[0]} == "0" ]]
}

@test "Ownership and permissions of pihole-FTL.db correct" {
run bash -c 'ls -l /etc/pihole/pihole-FTL.db'
printf "%s\n" "${lines[@]}"
[[ ${lines[0]} == "-rw-r--r-- 1 pihole pihole"* ]]
}

@test "Final part of the tests: Kill pihole-FTL process" {
run bash -c 'kill $(pidof pihole-FTL)'
printf "%s\n" "${lines[@]}"
Expand Down

0 comments on commit 420f58a

Please sign in to comment.