[Pkg-shadow-commits] r837 - in trunk/tests: . usertools usertools/01 usertools/01/data

Nicolas FRANCOIS nekral-guest at costa.debian.org
Sun Feb 5 00:22:10 UTC 2006


Author: nekral-guest
Date: 2006-02-05 00:22:09 +0000 (Sun, 05 Feb 2006)
New Revision: 837

Added:
   trunk/tests/usertools/
   trunk/tests/usertools/01/
   trunk/tests/usertools/01/data/
   trunk/tests/usertools/01/data/group
   trunk/tests/usertools/01/data/gshadow
   trunk/tests/usertools/01/data/passwd
   trunk/tests/usertools/01/data/shadow
   trunk/tests/usertools/01/run1
   trunk/tests/usertools/01/run2
   trunk/tests/usertools/01/run3
   trunk/tests/usertools/01/run4
Modified:
   trunk/tests/run_all
Log:
Add some tests for useradd


Modified: trunk/tests/run_all
===================================================================
--- trunk/tests/run_all	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/run_all	2006-02-05 00:22:09 UTC (rev 837)
@@ -26,6 +26,10 @@
 run_test ./chage/02/run
 run_test ./chsh/01/run
 run_test ./debian/01/run
+run_test ./usertools/01/run1
+run_test ./usertools/01/run2
+run_test ./usertools/01/run3
+run_test ./usertools/01/run4
 
 echo "$succeded test(s) passed"
 echo "$failed test(s) failed"

Added: trunk/tests/usertools/01/data/group
===================================================================
--- trunk/tests/usertools/01/data/group	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/data/group	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,41 @@
+root:x:0:
+daemon:x:1:
+bin:x:2:
+sys:x:3:
+adm:x:4:
+tty:x:5:
+disk:x:6:
+lp:x:7:
+mail:x:8:
+news:x:9:
+uucp:x:10:
+man:x:12:
+proxy:x:13:
+kmem:x:15:
+dialout:x:20:
+fax:x:21:
+voice:x:22:
+cdrom:x:24:
+floppy:x:25:
+tape:x:26:
+sudo:x:27:
+audio:x:29:
+dip:x:30:
+www-data:x:33:
+backup:x:34:
+operator:x:37:
+list:x:38:
+irc:x:39:
+src:x:40:
+gnats:x:41:
+shadow:x:42:
+utmp:x:43:
+video:x:44:
+sasl:x:45:
+plugdev:x:46:
+staff:x:50:
+games:x:60:
+users:x:100:
+nogroup:x:65534:
+crontab:x:101:
+Debian-exim:x:102:

Added: trunk/tests/usertools/01/data/gshadow
===================================================================
--- trunk/tests/usertools/01/data/gshadow	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/data/gshadow	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,41 @@
+root:*::
+daemon:*::
+bin:*::
+sys:*::
+adm:*::
+tty:*::
+disk:*::
+lp:*::
+mail:*::
+news:*::
+uucp:*::
+man:*::
+proxy:*::
+kmem:*::
+dialout:*::
+fax:*::
+voice:*::
+cdrom:*::
+floppy:*::
+tape:*::
+sudo:*::
+audio:*::
+dip:*::
+www-data:*::
+backup:*::
+operator:*::
+list:*::
+irc:*::
+src:*::
+gnats:*::
+shadow:*::
+utmp:*::
+video:*::
+sasl:*::
+plugdev:*::
+staff:*::
+games:*::
+users:*::
+nogroup:*::
+crontab:x::
+Debian-exim:x::

Added: trunk/tests/usertools/01/data/passwd
===================================================================
--- trunk/tests/usertools/01/data/passwd	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/data/passwd	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,19 @@
+root:x:0:0:root:/root:/bin/bash
+daemon:x:1:1:daemon:/usr/sbin:/bin/sh
+bin:x:2:2:bin:/bin:/bin/sh
+sys:x:3:3:sys:/dev:/bin/sh
+sync:x:4:65534:sync:/bin:/bin/sync
+games:x:5:60:games:/usr/games:/bin/sh
+man:x:6:12:man:/var/cache/man:/bin/sh
+lp:x:7:7:lp:/var/spool/lpd:/bin/sh
+mail:x:8:8:mail:/var/mail:/bin/sh
+news:x:9:9:news:/var/spool/news:/bin/sh
+uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
+proxy:x:13:13:proxy:/bin:/bin/sh
+www-data:x:33:33:www-data:/var/www:/bin/sh
+backup:x:34:34:backup:/var/backups:/bin/sh
+list:x:38:38:Mailing List Manager:/var/list:/bin/sh
+irc:x:39:39:ircd:/var/run/ircd:/bin/sh
+gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
+nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
+Debian-exim:x:102:102::/var/spool/exim4:/bin/false

Added: trunk/tests/usertools/01/data/shadow
===================================================================
--- trunk/tests/usertools/01/data/shadow	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/data/shadow	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,19 @@
+root:$1$NBLBLIXb$WUgojj1bNuxWEADQGt1m9.:12991:0:99999:7:::
+daemon:*:12977:0:99999:7:::
+bin:*:12977:0:99999:7:::
+sys:*:12977:0:99999:7:::
+sync:*:12977:0:99999:7:::
+games:*:12977:0:99999:7:::
+man:*:12977:0:99999:7:::
+lp:*:12977:0:99999:7:::
+mail:*:12977:0:99999:7:::
+news:*:12977:0:99999:7:::
+uucp:*:12977:0:99999:7:::
+proxy:*:12977:0:99999:7:::
+www-data:*:12977:0:99999:7:::
+backup:*:12977:0:99999:7:::
+list:*:12977:0:99999:7:::
+irc:*:12977:0:99999:7:::
+gnats:*:12977:0:99999:7:::
+nobody:*:12977:0:99999:7:::
+Debian-exim:!:12977:0:99999:7:::

Added: trunk/tests/usertools/01/run1
===================================================================
--- trunk/tests/usertools/01/run1	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/run1	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# no testsuite password
+# root password: rootF00barbaz
+# myuser password: myuserF00barbaz
+
+save()
+{
+	[ ! -d tmp ] && mkdir tmp
+	for i in passwd group shadow gshadow
+	do
+		[ -f /etc/$i  ] && cp /etc/$i  tmp/$i
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
+lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
+lines_group=$(wc -l /etc/group | cut -f1 -d" ")
+lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
+
+echo -n "Create user test1..."
+useradd test1
+echo "OK"
+
+echo "test if the user was added"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:([0-9]+):\\1::/home/test1:/bin/sh$"
+echo "  OK"
+uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p")
+# uid must be greater than UID_MIN (in login.defs)
+echo -n "  uid: $uid < 1000..."
+test $uid -ge 1000
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test1:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test1 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete this user..."
+userdel test1
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test1:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test1 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $lines_passwd  = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $lines_group   = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $lines_shadow  = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+


Property changes on: trunk/tests/usertools/01/run1
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/usertools/01/run2
===================================================================
--- trunk/tests/usertools/01/run2	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/run2	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,162 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# no testsuite password
+# root password: rootF00barbaz
+# myuser password: myuserF00barbaz
+
+save()
+{
+	[ ! -d tmp ] && mkdir tmp
+	for i in passwd group shadow gshadow
+	do
+		[ -f /etc/$i  ] && cp /etc/$i  tmp/$i
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
+lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
+lines_group=$(wc -l /etc/group | cut -f1 -d" ")
+lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
+
+echo -n "Create user test1..."
+useradd test1
+echo "OK"
+
+echo "test if the user was added"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:([0-9]+):\\1::/home/test1:/bin/sh$"
+echo "  OK"
+uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p")
+# uid must be greater than UID_MIN (in login.defs)
+echo -n "  uid: $uid < 1000..."
+test $uid -ge 1000
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test1:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test1 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete this user..."
+userdel test1
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test1:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test1 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $lines_passwd  = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $lines_group   = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $lines_shadow  = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "Create user test2..."
+useradd test2
+echo "OK"
+
+echo "test if the user was added with the same uid"
+echo -n "  passwd..."
+getent passwd test2 |
+	egrep "^test2:x:$uid:$uid::/home/test2:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test2  | egrep "^test2:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test2 | egrep "^test2:!:[0-9]+:0:99999:7:::$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test2:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test2 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete this user..."
+userdel test2
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test2:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test2 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $lines_passwd  = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $lines_group   = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $lines_shadow  = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+


Property changes on: trunk/tests/usertools/01/run2
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/usertools/01/run3
===================================================================
--- trunk/tests/usertools/01/run3	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/run3	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,110 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# no testsuite password
+# root password: rootF00barbaz
+# myuser password: myuserF00barbaz
+
+save()
+{
+	[ ! -d tmp ] && mkdir tmp
+	for i in passwd group shadow gshadow
+	do
+		[ -f /etc/$i  ] && cp /etc/$i  tmp/$i
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
+lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
+lines_group=$(wc -l /etc/group | cut -f1 -d" ")
+lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
+
+echo -n "Create user test3, using options..."
+useradd --comment "comment test3" \
+	--expiredate "2006-02-04" \
+	--shell "/bin/bash" \
+	--inactive "12" \
+	--home-dir "/nonexistenthomedir" \
+	test3
+echo "OK"
+
+echo "test if the user was added with the same uid"
+echo -n "  passwd..."
+getent passwd test3 |
+	egrep "^test3:x:([0-9]+):\\1:comment test3:/nonexistenthomedir:/bin/bash$"
+echo "  OK"
+uid=$(getent passwd test3|sed -ne "s/test3:x:\([0-9]*\):.*/\\1/p")
+# uid must be greater than UID_MIN (in login.defs)
+echo -n "  uid: $uid < 1000..."
+test $uid -ge 1000
+echo -n "  group..."
+getent group test3  | egrep "^test3:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test3 | egrep "^test3:!:[0-9]+:0:99999:7:12:13183:$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test3:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test3 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete this user..."
+userdel test3
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test3:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test3 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $lines_passwd  = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $lines_group   = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $lines_shadow  = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+


Property changes on: trunk/tests/usertools/01/run3
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/usertools/01/run4
===================================================================
--- trunk/tests/usertools/01/run4	2006-02-04 20:57:26 UTC (rev 836)
+++ trunk/tests/usertools/01/run4	2006-02-05 00:22:09 UTC (rev 837)
@@ -0,0 +1,182 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# no testsuite password
+# root password: rootF00barbaz
+# myuser password: myuserF00barbaz
+
+save()
+{
+	[ ! -d tmp ] && mkdir tmp
+	for i in passwd group shadow gshadow
+	do
+		[ -f /etc/$i  ] && cp /etc/$i  tmp/$i
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ")
+lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ")
+lines_group=$(wc -l /etc/group | cut -f1 -d" ")
+lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ")
+
+echo -n "Create user test4..."
+useradd -u 4242 test4
+echo "OK"
+
+echo "test if the user was added with the right uid"
+echo -n "  passwd..."
+getent passwd test4 |
+	egrep "^test4:x:4242:4242::/home/test4:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test4 | egrep "^test4:x:4242:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test4 | egrep "^test4:!:[0-9]+:0:99999:7:::$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test4:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test4 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo "do NOT delete this user"
+
+echo -n "Create user test5 with the same uid..."
+useradd -u 4242 test5 && exit 1 || true
+echo "All right, useradd return an error."
+
+echo "This user should not exist"
+echo -n "  no entries..."
+egrep "^test5:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test5 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "Create user test6 with the same uid..."
+useradd -o -u 4242 test6
+echo "OK"
+
+echo "test if the user was added with the right uid"
+echo -n "  passwd..."
+getent passwd test6 |
+	egrep "^test6:x:4242:4243::/home/test6:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test6 | egrep "^test6:x:4243:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test6 | egrep "^test6:!:[0-9]+:0:99999:7:::$"
+echo "  OK"
+echo -n "  gshadow..."
+egrep "^test6:!::$" /etc/gshadow
+echo "  OK"
+# the home directory should not exist
+echo -n "  no homedir..."
+test -d /home/test6 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 2 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 2 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 2 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 2 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete user test4..."
+userdel test4
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test4:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test4 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $(( lines_passwd  + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $(( lines_group   + 1 )) = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $(( lines_shadow  + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+
+echo -n "delete user test6..."
+userdel test6
+echo "OK"
+
+echo "check if the user was deleted"
+echo -n "  no entries..."
+egrep "^test6:" \
+      /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true
+echo "  OK"
+echo -n "  no homedir..."
+test -d /home/test6 && exit 1 || true
+echo "  OK"
+echo -n "  number of lines"
+test $lines_passwd  = $(wc -l /etc/passwd | cut -f1 -d" ")
+echo -n "."
+test $lines_group   = $(wc -l /etc/group | cut -f1 -d" ")
+echo -n "."
+test $lines_shadow  = $(wc -l /etc/shadow | cut -f1 -d" ")
+echo -n "."
+test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ")
+echo -n "."
+echo "  OK"
+


Property changes on: trunk/tests/usertools/01/run4
___________________________________________________________________
Name: svn:executable
   + *




More information about the Pkg-shadow-commits mailing list