summaryrefslogtreecommitdiffstats
path: root/testsuite/test2.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 05:55:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 05:55:27 +0000
commit32e0ba8ebdadc47ac1a0da8d9a9668ff21909e4f (patch)
treeebaa5eacafe874b431d69e52f0f73c013c3017ae /testsuite/test2.pl
parentInitial commit. (diff)
downloadadduser-upstream.tar.xz
adduser-upstream.zip
Adding upstream version 3.118+deb11u1.upstream/3.118+deb11u1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testsuite/test2.pl')
-rw-r--r--testsuite/test2.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/testsuite/test2.pl b/testsuite/test2.pl
new file mode 100644
index 0000000..de0aafe
--- /dev/null
+++ b/testsuite/test2.pl
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+
+# expect:
+# - a new system user $USER
+# - added to group nogroup
+# - home directory /home/$USER
+# - removal works
+
+use strict;
+use lib_test;
+
+my $groupname = "nogroup";
+my $username = find_unused_name();
+my $homedir = "/home/$username";
+my $cmd = "adduser --system --home $homedir $username";
+
+if (!defined (getpwnam($username))) {
+ print "Testing $cmd... ";
+ `$cmd`;
+ my $error = ($?>>8);
+ if ($error) {
+ print "failed\n adduser returned an errorcode != 0 ($error)\n";
+ exit $error;
+ }
+ assert(check_user_exist ($username));
+ assert(check_homedir_exist($username,$homedir));
+ assert(check_group_exist($groupname));
+ assert(check_user_in_group ($username,$groupname));
+ print "ok\n";
+}
+
+$cmd = "deluser --remove-home $username";
+if (defined (getpwnam($username))) {
+ print "Testing $cmd... ";
+ `$cmd`;
+ my $error = ($?>>8);
+ if ($error) {
+ print "failed\n deluser returned an errorcode != 0 ($error)\n";
+ exit $error;
+ }
+ assert(check_user_not_exist ($username));
+ assert(check_homedir_not_exist($homedir));
+ print "ok\n";
+}