aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pw/tests
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pw/tests')
-rw-r--r--usr.sbin/pw/tests/Makefile2
-rw-r--r--usr.sbin/pw/tests/Makefile.depend3
-rw-r--r--usr.sbin/pw/tests/crypt.c2
-rw-r--r--usr.sbin/pw/tests/group1
-rwxr-xr-xusr.sbin/pw/tests/helper_functions.shin1
-rw-r--r--usr.sbin/pw/tests/master.passwd1
-rwxr-xr-xusr.sbin/pw/tests/pw_config_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_etcdir_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupadd_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupdel_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupmod_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_groupshow_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_lock_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_useradd_test.sh80
-rwxr-xr-xusr.sbin/pw/tests/pw_userdel_test.sh3
-rwxr-xr-xusr.sbin/pw/tests/pw_usermod_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_usernext_test.sh1
-rwxr-xr-xusr.sbin/pw/tests/pw_usershow_test.sh1
18 files changed, 73 insertions, 30 deletions
diff --git a/usr.sbin/pw/tests/Makefile b/usr.sbin/pw/tests/Makefile
index ecdb0fe1665d..910a563d680d 100644
--- a/usr.sbin/pw/tests/Makefile
+++ b/usr.sbin/pw/tests/Makefile
@@ -1,5 +1,3 @@
-# $FreeBSD$
-
PACKAGE= tests
BINDIR= ${TESTSDIR}
diff --git a/usr.sbin/pw/tests/Makefile.depend b/usr.sbin/pw/tests/Makefile.depend
index 9124664318e7..aed10d8908bf 100644
--- a/usr.sbin/pw/tests/Makefile.depend
+++ b/usr.sbin/pw/tests/Makefile.depend
@@ -1,9 +1,6 @@
-# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- include \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
diff --git a/usr.sbin/pw/tests/crypt.c b/usr.sbin/pw/tests/crypt.c
index 586fccdfec78..2a2023e47393 100644
--- a/usr.sbin/pw/tests/crypt.c
+++ b/usr.sbin/pw/tests/crypt.c
@@ -22,8 +22,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
#include <err.h>
diff --git a/usr.sbin/pw/tests/group b/usr.sbin/pw/tests/group
index 620c588faa38..2812f56cfa98 100644
--- a/usr.sbin/pw/tests/group
+++ b/usr.sbin/pw/tests/group
@@ -1,3 +1,2 @@
-# $FreeBSD$
#
wheel:*:0:root
diff --git a/usr.sbin/pw/tests/helper_functions.shin b/usr.sbin/pw/tests/helper_functions.shin
index 1ee731a786ef..c03ca98d8709 100755
--- a/usr.sbin/pw/tests/helper_functions.shin
+++ b/usr.sbin/pw/tests/helper_functions.shin
@@ -1,4 +1,3 @@
-# $FreeBSD$
# The pw command
PW="pw -V ${HOME}"
diff --git a/usr.sbin/pw/tests/master.passwd b/usr.sbin/pw/tests/master.passwd
index f7dc837dabca..46728369eb17 100644
--- a/usr.sbin/pw/tests/master.passwd
+++ b/usr.sbin/pw/tests/master.passwd
@@ -1,4 +1,3 @@
-# $FreeBSD$
#
root:*:0:0::0:0:Charlie &:/root:/bin/csh
toor:*:0:0::0:0:Bourne-again Superuser:/root:
diff --git a/usr.sbin/pw/tests/pw_config_test.sh b/usr.sbin/pw/tests/pw_config_test.sh
index fb6489a0b31c..e9209190dc5e 100755
--- a/usr.sbin/pw/tests/pw_config_test.sh
+++ b/usr.sbin/pw/tests/pw_config_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_etcdir_test.sh b/usr.sbin/pw/tests/pw_etcdir_test.sh
index b237789ed457..db6f0f30eaf3 100755
--- a/usr.sbin/pw/tests/pw_etcdir_test.sh
+++ b/usr.sbin/pw/tests/pw_etcdir_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# When the '-V directory' option is provided, the directory must exist
atf_test_case etcdir_must_exist
diff --git a/usr.sbin/pw/tests/pw_groupadd_test.sh b/usr.sbin/pw/tests/pw_groupadd_test.sh
index 5fa7bef0fdf1..cf3c401a361c 100755
--- a/usr.sbin/pw/tests/pw_groupadd_test.sh
+++ b/usr.sbin/pw/tests/pw_groupadd_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupdel_test.sh b/usr.sbin/pw/tests/pw_groupdel_test.sh
index 88cc0e08b8bf..fa51b3814205 100755
--- a/usr.sbin/pw/tests/pw_groupdel_test.sh
+++ b/usr.sbin/pw/tests/pw_groupdel_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupmod_test.sh b/usr.sbin/pw/tests/pw_groupmod_test.sh
index 580692553847..ce7106d885d2 100755
--- a/usr.sbin/pw/tests/pw_groupmod_test.sh
+++ b/usr.sbin/pw/tests/pw_groupmod_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_groupshow_test.sh b/usr.sbin/pw/tests/pw_groupshow_test.sh
index f348d0ab1f70..06631e912c0f 100755
--- a/usr.sbin/pw/tests/pw_groupshow_test.sh
+++ b/usr.sbin/pw/tests/pw_groupshow_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_lock_test.sh b/usr.sbin/pw/tests/pw_lock_test.sh
index 5ec1b09a6956..f8fe03a4d147 100755
--- a/usr.sbin/pw/tests/pw_lock_test.sh
+++ b/usr.sbin/pw/tests/pw_lock_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_useradd_test.sh b/usr.sbin/pw/tests/pw_useradd_test.sh
index a50f018ab99d..6413c063d482 100755
--- a/usr.sbin/pw/tests/pw_useradd_test.sh
+++ b/usr.sbin/pw/tests/pw_useradd_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
@@ -295,15 +294,54 @@ user_add_R_body() {
[ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed"
}
-atf_test_case user_add_R_symlink
-user_add_R_symlink_body() {
+atf_test_case user_add_R_no_symlink
+user_add_R_no_symlink_body() {
populate_root_etc_skel
mkdir ${HOME}/usr
atf_check -s exit:0 ${RPW} useradd foo -m
- test -d ${HOME}/usr/home || atf_fail "Home parent directory not created"
- test -h ${HOME}/home || atf_fail "/home directory is not a symlink"
- atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home
+ [ ! -d ${HOME}/usr/home ] || atf_fail "/usr/home created"
+ test -d ${HOME}/home || atf_fail "/home directory not created"
+}
+
+atf_test_case user_add_R_intermed
+user_add_R_intermed_body() {
+ populate_root_etc_skel
+
+ atf_check -s exit:0 ${RPW} useradd foo -m -d /a/b/c/foo
+ test -d ${HOME}/a/b/c || atf_fail "intermediate directories not created"
+ test -d ${HOME}/a/b/c/foo || atf_fail "user directory not created"
+}
+
+atf_test_case user_add_dir
+user_add_dir_body() {
+ populate_root_etc_skel
+
+ atf_check -s exit:0 ${RPW} useradd foo -M 0705 -m
+ atf_check grep -q '^foo:' $HOME/etc/master.passwd
+ atf_check test -d ${HOME}/home/foo
+ atf_check -o save:ugid \
+ awk -F: '$1 == "foo" { print $3, $4 }' \
+ $HOME/etc/master.passwd
+ atf_check -o file:ugid \
+ stat -f '%u %g' ${HOME}/home/foo
+ atf_check -o inline:"40705\n" \
+ stat -f '%p' ${HOME}/home/foo
+}
+
+atf_test_case user_add_existing_dir
+user_add_existing_dir_body() {
+ populate_root_etc_skel
+
+ mkdir -p -m 0777 ${HOME}/home/foo
+ atf_check -o inline:"40777\n" \
+ stat -f '%p' ${HOME}/home/foo
+
+ atf_check -s exit:0 ${RPW} useradd foo -M 0705 -m
+ atf_check grep -q '^foo:' $HOME/etc/master.passwd
+ atf_check test -d ${HOME}/home/foo
+ atf_check -o inline:"40705\n" \
+ stat -f '%p' ${HOME}/home/foo
}
atf_test_case user_add_skel
@@ -455,6 +493,29 @@ user_add_conf_defaultpasswd_body()
grep defaultpasswd ${HOME}/pw.conf
}
+atf_test_case user_add_existing_login_group
+user_add_existing_login_group_body()
+{
+ populate_etc_skel
+
+ atf_check -s exit:0 ${PW} groupadd testuser
+ atf_check -s exit:0 ${PW} useradd user1 -G testuser
+ atf_check -s exit:0 ${PW} useradd testuser
+ atf_check -o match:"1" \
+ sh -c "grep testuser ${HOME}/group | wc -l"
+}
+
+atf_test_case user_add_already_in_group
+user_add_already_in_group_body()
+{
+ populate_etc_skel
+
+ echo "testgroup:*:4242:testuser" >> ${HOME}/group
+ atf_check -s exit:0 ${PW} useradd testuser -G testgroup
+ atf_check -o not-match:"testuser,testuser" \
+ grep testuser ${HOME}/group
+}
+
atf_init_test_cases() {
atf_add_test_case user_add
atf_add_test_case user_add_noupdate
@@ -479,7 +540,10 @@ atf_init_test_cases() {
atf_add_test_case user_add_invalid_group_entry
atf_add_test_case user_add_password_from_h
atf_add_test_case user_add_R
- atf_add_test_case user_add_R_symlink
+ atf_add_test_case user_add_R_no_symlink
+ atf_add_test_case user_add_R_intermed
+ atf_add_test_case user_add_dir
+ atf_add_test_case user_add_existing_dir
atf_add_test_case user_add_skel
atf_add_test_case user_add_uid0
atf_add_test_case user_add_uid_too_large
@@ -494,4 +558,6 @@ atf_init_test_cases() {
atf_add_test_case user_add_defaultgroup
atf_add_test_case user_add_conf_defaultpasswd
+ atf_add_test_case user_add_existing_login_group
+ atf_add_test_case user_add_already_in_group
}
diff --git a/usr.sbin/pw/tests/pw_userdel_test.sh b/usr.sbin/pw/tests/pw_userdel_test.sh
index 694d7bbae6cc..2e11c3534d58 100755
--- a/usr.sbin/pw/tests/pw_userdel_test.sh
+++ b/usr.sbin/pw/tests/pw_userdel_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
@@ -39,12 +38,10 @@ delete_files_body() {
touch ${HOME}/skel/a
mkdir -p ${HOME}/home
mkdir -p ${HOME}/var/mail
- echo "foo wedontcare" > ${HOME}/etc/opiekeys
atf_check -s exit:0 ${RPW} useradd foo -k /skel -m
test -d ${HOME}/home || atf_fail "Fail to create home directory"
test -f ${HOME}/var/mail/foo || atf_fail "Mail file not created"
atf_check -s exit:0 ${RPW} userdel foo -r
- atf_check -s exit:0 -o inline:"#oo wedontcare\n" cat ${HOME}/etc/opiekeys
if test -f ${HOME}/var/mail/foo; then
atf_fail "Mail file not removed"
fi
diff --git a/usr.sbin/pw/tests/pw_usermod_test.sh b/usr.sbin/pw/tests/pw_usermod_test.sh
index cf3622f3b222..f8cb66a45b70 100755
--- a/usr.sbin/pw/tests/pw_usermod_test.sh
+++ b/usr.sbin/pw/tests/pw_usermod_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_usernext_test.sh b/usr.sbin/pw/tests/pw_usernext_test.sh
index 89f938ec8c33..63a688f573d8 100755
--- a/usr.sbin/pw/tests/pw_usernext_test.sh
+++ b/usr.sbin/pw/tests/pw_usernext_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin
diff --git a/usr.sbin/pw/tests/pw_usershow_test.sh b/usr.sbin/pw/tests/pw_usershow_test.sh
index 530597948e4a..06f7f610936a 100755
--- a/usr.sbin/pw/tests/pw_usershow_test.sh
+++ b/usr.sbin/pw/tests/pw_usershow_test.sh
@@ -1,4 +1,3 @@
-# $FreeBSD$
# Import helper functions
. $(atf_get_srcdir)/helper_functions.shin