summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-12 14:57:21 -0600
committermo khan <mo.khan@gmail.com>2019-10-12 14:57:21 -0600
commit2e2f6bcfa9c043007765e98f82baa4b461a7fe25 (patch)
tree28a947a72b75c9e8416470b21fbfb2682c059ee6 /test
parentd5beeffb6247a8b0e115d059491255600dd70440 (diff)
add tests for no-password script
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/passwd_with_missing_password3
-rw-r--r--test/no-password_test.bats15
2 files changed, 18 insertions, 0 deletions
diff --git a/test/fixtures/passwd_with_missing_password b/test/fixtures/passwd_with_missing_password
new file mode 100644
index 0000000..37f51ad
--- /dev/null
+++ b/test/fixtures/passwd_with_missing_password
@@ -0,0 +1,3 @@
+nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
+root:*:0:0:System Administrator:/var/root:/bin/sh
+daemon::1:1:daemon:/tmp:/usr/bin/false
diff --git a/test/no-password_test.bats b/test/no-password_test.bats
new file mode 100644
index 0000000..815b25e
--- /dev/null
+++ b/test/no-password_test.bats
@@ -0,0 +1,15 @@
+#!/usr/bin/env bats
+
+load test_helper
+
+@test "it finds a user without a password" {
+ run ./bin/no-password test/fixtures/passwd_with_missing_password
+
+ assert_success $'daemon::1:1:daemon:/tmp:/usr/bin/false'
+}
+
+@test "it does not find any users that are missing a password" {
+ run ./bin/no-password test/fixtures/passwd_with_uid_zero
+
+ assert_failure $''
+}