summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2019-10-14 10:35:45 -0600
committermo khan <mo.khan@gmail.com>2019-10-14 10:35:45 -0600
commitf12ef3fd3851bb69aa2fbadd713ccff3298b7fab (patch)
treed70ad5378717ba288aea01a71fe1d32084eeecae /test
parentd32e87b86f6ddad2c2e427718bc9f480e0905055 (diff)
Create script for detecting duplicate login names
Diffstat (limited to 'test')
-rw-r--r--test/duplicate-login-names_test.bats15
-rw-r--r--test/fixtures/passwd_with_duplicate_login_names3
2 files changed, 18 insertions, 0 deletions
diff --git a/test/duplicate-login-names_test.bats b/test/duplicate-login-names_test.bats
new file mode 100644
index 0000000..f91d0a2
--- /dev/null
+++ b/test/duplicate-login-names_test.bats
@@ -0,0 +1,15 @@
+#!/usr/bin/env bats
+
+load test_helper
+
+@test "it finds users with duplicate login names" {
+ run ./bin/duplicate-login-names test/fixtures/passwd_with_duplicate_login_names
+
+ assert_failure $'root'
+}
+
+@test "it does not find any duplicate login names" {
+ run ./bin/duplicate-login-names test/fixtures/passwd
+
+ assert_success
+}
diff --git a/test/fixtures/passwd_with_duplicate_login_names b/test/fixtures/passwd_with_duplicate_login_names
new file mode 100644
index 0000000..e943ab4
--- /dev/null
+++ b/test/fixtures/passwd_with_duplicate_login_names
@@ -0,0 +1,3 @@
+root:x:0:0:root:/root:/bin/bash
+bin:x:1:1:bin:/bin:/sbin/nologin
+root:x:2:2:daemon:/sbin:/sbin/nologin