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

Nicolas FRANCOIS nekral-guest at costa.debian.org
Sun Aug 6 14:57:56 UTC 2006


Author: nekral-guest
Date: 2006-08-06 14:57:49 +0000 (Sun, 06 Aug 2006)
New Revision: 1077

Added:
   trunk/tests/usertools/01/run10
   trunk/tests/usertools/01/run11
   trunk/tests/usertools/01/run9
Modified:
   trunk/tests/run_all
Log:
Add some tests for usermod.


Modified: trunk/tests/run_all
===================================================================
--- trunk/tests/run_all	2006-08-05 23:56:47 UTC (rev 1076)
+++ trunk/tests/run_all	2006-08-06 14:57:49 UTC (rev 1077)
@@ -34,6 +34,9 @@
 run_test ./usertools/01/run6
 run_test ./usertools/01/run7
 run_test ./usertools/01/run8
+run_test ./usertools/01/run9
+run_test ./usertools/01/run10
+run_test ./usertools/01/run11
 
 echo "$succeded test(s) passed"
 echo "$failed test(s) failed"

Added: trunk/tests/usertools/01/run10
===================================================================
--- trunk/tests/usertools/01/run10	2006-08-05 23:56:47 UTC (rev 1076)
+++ trunk/tests/usertools/01/run10	2006-08-06 14:57:49 UTC (rev 1077)
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that usermod can rename a user.
+
+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"
+
+uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p")
+
+echo -n "Rename user test1..."
+usermod -l test2 test1
+echo "OK"
+
+echo "test if the user was changed"
+echo -n "  passwd no user test1..."
+getent passwd test1 && exit 1 || true
+echo "  OK"
+echo -n "  passwd user test2..."
+getent passwd test2 |
+	egrep "^test2:x:$uid:$uid::/home/test1:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow no user test1..."
+getent shadow test1 && exit 1 || true
+echo "  OK"
+echo -n "  shadow user test2..."
+getent shadow test2 | egrep "^test2:!:[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"
+


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

Added: trunk/tests/usertools/01/run11
===================================================================
--- trunk/tests/usertools/01/run11	2006-08-05 23:56:47 UTC (rev 1076)
+++ trunk/tests/usertools/01/run11	2006-08-06 14:57:49 UTC (rev 1077)
@@ -0,0 +1,147 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that useradd can add an user, usermod can change it
+
+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"
+
+uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p")
+
+echo -n "Change user's password..."
+usermod -p '$1$12345678$0jEt1CYOyE.5NxWFMZyZy1' test1
+# (test1F00barbaz)
+echo "OK"
+
+echo "test if the user was changed"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test1 | egrep "^test1:\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[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 "Lock user's password..."
+usermod -L test1
+echo "OK"
+
+echo "test if the user was changed"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test1 | egrep "^test1:\!\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[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 "Unlock user's password..."
+usermod --unlock test1
+echo "OK"
+
+echo "test if the user was changed"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$"
+echo "  OK"
+echo -n "  group..."
+getent group test1  | egrep "^test1:x:$uid:$"
+echo "  OK"
+echo -n "  shadow..."
+getent shadow test1 | egrep "^test1:\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[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"
+


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

Added: trunk/tests/usertools/01/run9
===================================================================
--- trunk/tests/usertools/01/run9	2006-08-05 23:56:47 UTC (rev 1076)
+++ trunk/tests/usertools/01/run9	2006-08-06 14:57:49 UTC (rev 1077)
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that useradd can add an user, usermod can change it
+
+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"
+
+uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p")
+
+echo -n "Change user test1..."
+usermod -g 1 --comment "comment" -e 2000-01-01 -f 17 -s /bin/bash -d /tmp test1
+echo "OK"
+
+echo "test if the user was changed"
+echo -n "  passwd..."
+getent passwd test1 |
+	egrep "^test1:x:$uid:1:comment:/tmp:/bin/bash$"
+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:17:10957:$"
+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"
+


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




More information about the Pkg-shadow-commits mailing list