From f12ef3fd3851bb69aa2fbadd713ccff3298b7fab Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 14 Oct 2019 10:35:45 -0600 Subject: Create script for detecting duplicate login names --- test/duplicate-login-names_test.bats | 15 +++++++++++++++ test/fixtures/passwd_with_duplicate_login_names | 3 +++ 2 files changed, 18 insertions(+) create mode 100644 test/duplicate-login-names_test.bats create mode 100644 test/fixtures/passwd_with_duplicate_login_names (limited to 'test') 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 -- cgit v1.2.3