[master 1/1] User operation kickstart tests.

KosiehBarter installerbot-noreply at redhat.com
Wed Jul 8 10:42:30 UTC 2015


From: Karel Valek <kvalek at redhat.com>

Kickstart scripts for adding specified user during installation as well
as check-up if the user was successfully added to the system, including
password, /home/<user> directory and specified group.

Signed-off-by: Karel Valek <kvalek at redhat.com>
---
 tests/kickstart_tests/user.ks | 88 +++++++++++++++++++++++++++++++++++++++++++
 tests/kickstart_tests/user.sh | 20 ++++++++++
 2 files changed, 108 insertions(+)
 create mode 100644 tests/kickstart_tests/user.ks
 create mode 100755 tests/kickstart_tests/user.sh

diff --git a/tests/kickstart_tests/user.ks b/tests/kickstart_tests/user.ks
new file mode 100644
index 0000000..5fae356
--- /dev/null
+++ b/tests/kickstart_tests/user.ks
@@ -0,0 +1,88 @@
+# Set basic URL
+url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/$releasever/$basearch/os/"
+
+# perform install
+install
+
+# Set network - automatical DHCP
+network --bootproto=dhcp
+
+bootloader --timeout=1
+zerombr
+
+# Remove whole disk info and recreate it.
+clearpart --all
+autopart --type=lvm
+
+# Set locales and Keyboard.
+keyboard us
+lang en
+timezone America/New_York
+
+# set users. Root first, others next
+rootpw qweqwe
+
+## TEST CREATE USER
+# First, we need to create a group where we can assign user..
+group --name=kosygroup --gid=5001
+
+# ..then create the user and assign him/her to group we created before.
+user --name=kosieh --gecos="Kosieh Barter" --homedir=/home/kbarter --password="$6$QsJCB9E6geIjWNvn$UZLEtnHYgKmFgrPo0fY1qNBc/aRi9b01f19w9mpdFm9.MPblckUuFYvpRLSzeYeR/6lO/2uY4WtjhbryC0k2L/" --iscrypted --shell=/bin/bash --uid=4001 --gid=5001
+
+# After all, shut down the machine.
+shutdown
+
+%packages
+%end
+
+%post
+
+## TEST CREATE USER CHECK
+
+# First, check if the group is properly set up.
+cat /etc/group | grep 5001
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: Group failed to create." >> /root/RESULT
+fi
+
+# If it succeeds, lets go to higher level. Check, if the user is present..
+cat /etc/passwd | grep kosieh
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: User is not present in system." >> /root/RESULT
+fi
+
+# ..if successfull, let's check if the user has his / her real name...
+cat /etc/passwd | grep kosieh | grep "Kosieh Barter"
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: User is present, but not all details: REAL NAME (GEDOS)" >> /root/RESULT
+fi
+
+# ...and if so, let's presume that all GEDOS data should be in "OK" state. Next step is to check bash...
+cat /etc/passwd | grep kosieh | grep "/bin/bash"
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: User is present, but /bin/bash is not set (EXPERIMENTAL!)" >> /root/RESULT
+fi
+
+# ...that will also confirm that the user should have his/her password (already in crypted version, EXPERIMENTAL!!)...
+cat /etc/shadow | grep kosieh | grep "$6$QsJCB9E6geIjWNvn$UZLEtnHYgKmFgrPo0fY1qNBc/aRi9b01f19w9mpdFm9.MPblckUuFYvpRLSzeYeR/6lO/2uY4WtjhbryC0k2L/"
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: User is present, passwords DO NOT match" >> /root/RESULT
+fi
+
+# ...and the best for last, does the user BELONG to the group stated in kickstart script?
+cat /etc/passwd | grep kosieh |  grep 5001
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: User is present, group assignment failed" >> /root/RESULT
+fi
+
+# ..And I forgot! What about the home directory? Let's fix this by a simple test.
+ls /home/ | grep kbarter
+if [[ $? -ne 0 ]]; then
+    echo "FAILED: Home directory not found" >> /root/RESULT
+fi
+
+# If everything succeeds, give the tester permission to go and grab a cookie.
+if [[ ! -e /root/RESULT ]]; then
+    echo SUCCESS > /root/RESULT
+fi
+%end
diff --git a/tests/kickstart_tests/user.sh b/tests/kickstart_tests/user.sh
new file mode 100755
index 0000000..7b2f4f0
--- /dev/null
+++ b/tests/kickstart_tests/user.sh
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2015  Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.  You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Chris Lumens <clumens at redhat.com>
+
+. ${KSTESTDIR}/functions.sh


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/232240e25f814e87f2ff6189e5b00d9779b3ca96


More information about the anaconda-patches mailing list