diff options
| -rw-r--r-- | test/fixtures/passwd_with_uid_zero | 13 | ||||
| -rw-r--r-- | test/fixtures/passwd_without_uid_zero | 12 | ||||
| -rw-r--r-- | test/uid_zero_test.bats | 8 |
3 files changed, 32 insertions, 1 deletions
diff --git a/test/fixtures/passwd_with_uid_zero b/test/fixtures/passwd_with_uid_zero new file mode 100644 index 0000000..125dee4 --- /dev/null +++ b/test/fixtures/passwd_with_uid_zero @@ -0,0 +1,13 @@ +## +# User Database +# +# Note that this file is consulted directly only when the system is running +# in single-user mode. At other times this information is provided by +# Open Directory. +# +# See the opendirectoryd(8) man page for additional information about +# Open Directory. +## +nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false +root:*:0:0:System Administrator:/var/root:/bin/sh +daemon:*:1:1:System Services:/var/root:/usr/bin/false diff --git a/test/fixtures/passwd_without_uid_zero b/test/fixtures/passwd_without_uid_zero new file mode 100644 index 0000000..055d52e --- /dev/null +++ b/test/fixtures/passwd_without_uid_zero @@ -0,0 +1,12 @@ +## +# User Database +# +# Note that this file is consulted directly only when the system is running +# in single-user mode. At other times this information is provided by +# Open Directory. +# +# See the opendirectoryd(8) man page for additional information about +# Open Directory. +## +nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false +daemon:*:1:1:System Services:/var/root:/usr/bin/false diff --git a/test/uid_zero_test.bats b/test/uid_zero_test.bats index 397312e..f1f1dcb 100644 --- a/test/uid_zero_test.bats +++ b/test/uid_zero_test.bats @@ -3,7 +3,13 @@ load test_helper @test "it finds the user with uid 0" { - run ./bin/uid-zero test/fixtures/passwd + run ./bin/uid-zero test/fixtures/passwd_with_uid_zero assert_success $'root:0' } + +@test "it does not find a user with uid 0" { + run ./bin/uid-zero test/fixtures/passwd_without_uid_zero + + assert_failure $'' +} |
