-
Notifications
You must be signed in to change notification settings - Fork 347
/
Copy pathtest_getent.sh
executable file
·58 lines (45 loc) · 1.41 KB
/
test_getent.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2016-11-20 15:35:37 +0000 (Sun, 20 Nov 2016)
#
# https://github.com/HariSekhon/DevOps-Python-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "$0")" && pwd)"
cd "$srcdir/.."
# shellcheck disable=SC1091
. ./bash-tools/lib/utils.sh
section "Getent"
start_time="$(start_timer "find_active_server.py test")"
system="$(uname -s)"
echo "system = $system"
hr
if [ "$system" = "Linux" ] ||
[ "$system" = Darwin ]; then
run ./getent.py passwd | grep -v ':[x*!]*:'
# counter is lost in subshell, increment manually
run++
# $USER isn't always available in docker containers, use 'id' instead
run ./getent.py passwd "$(id -un)"
run_fail 2 ./getent.py passwd nonexistentuser
run ./getent.py group | grep -v ':[x*!]:'
run++
run ./getent.py group "$(id -gn)"
run_fail 2 ./getent.py group nonexistentgroup
echo
# $run_count defined in lib
# shellcheck disable=SC2154
echo "Tests run: $run_count"
time_taken "$start_time" "find_active_server.py tests completed in"
else
echo "system is not Linux or Mac, skipping..."
fi