[master 3/3] Add a test for proxy authentication

dashea installerbot-noreply at redhat.com
Mon Aug 3 15:04:23 UTC 2015


From: David Shea <dshea at redhat.com>

---
 tests/kickstart_tests/proxy-auth.ks | 64 +++++++++++++++++++++++++++++++++++++
 tests/kickstart_tests/proxy-auth.sh | 36 +++++++++++++++++++++
 2 files changed, 100 insertions(+)
 create mode 100644 tests/kickstart_tests/proxy-auth.ks
 create mode 100755 tests/kickstart_tests/proxy-auth.sh

diff --git a/tests/kickstart_tests/proxy-auth.ks b/tests/kickstart_tests/proxy-auth.ks
new file mode 100644
index 0000000..f7462b6
--- /dev/null
+++ b/tests/kickstart_tests/proxy-auth.ks
@@ -0,0 +1,64 @@
+url --url=http://dl.fedoraproject.org/pub/fedora/linux/development/$releasever/$basearch/os/ --proxy=http://anaconda:qweqwe@127.0.0.1:8080
+repo --name=kstest-http --baseurl=HTTP-ADDON-REPO --proxy=http://anaconda:qweqwe@127.0.0.1:8080 --install
+install
+network --bootproto=dhcp
+
+bootloader --timeout=1
+zerombr
+clearpart --all
+autopart
+
+keyboard us
+lang en
+timezone America/New_York
+rootpw qweqwe
+shutdown
+
+# Install @core, which will also pull in testpkg-http-core from the addon repo
+%packages
+%end
+
+# Start the proxy server
+%include proxy-common.ks
+
+# Set a password on the proxy server
+%pre
+echo 'anaconda:qweqwe' > /tmp/proxy.password
+%end
+
+%post --nochroot
+# Look for the following as evidence that a proxy was used:
+# a .treeinfo request
+# primary.xml from the repodata
+# the kernel package from the Fedora repo
+# testpkg-http-core from the addon repo
+
+if ! grep -q '\.treeinfo$' /tmp/proxy.log; then
+    result='.treeinfo request was not proxied'
+elif ! grep -q 'repodata/.*primary.xml' /tmp/proxy.log; then
+    result='repodata requests were not proxied'
+elif ! grep -q 'kernel-.*\.rpm' /tmp/proxy.log; then
+    result='base repo package requests were not proxied'
+elif ! grep -q 'testpkg-http-core.*\.rpm' /tmp/proxy.log; then
+    result='addon repo package requests were not proxied'
+elif [[ ! -f $ANA_INSTALL_PATH/etc/yum.repos.d/kstest-http.repo ]]; then
+    result='kstest-http.repo does not exist'
+elif ! grep -q 'proxy=http://anaconda:qweqwe@127.0.0.1:8080' $ANA_INSTALL_PATH/etc/yum.repos.d/kstest-http.repo; then
+    result='kstest-http.repo does not contain proxy information'
+# Check that the installed repo file is usable
+# dnf exits with 0 even if something goes wrong, so do a repoquery and look for
+# the package in the output
+elif ! chroot $ANA_INSTALL_PATH \
+         dnf --disablerepo=\* --enablerepo=kstest-http --quiet repoquery testpkg-http-core 2>/dev/null | \
+         grep -q 'testpkg-http-core'; then
+    result='unable to query kstest-http repo'
+# Finally, check that the repoquery used the proxy
+elif ! tail -1 /tmp/proxy.log | grep -q repodata; then
+    result='repoquery on installed system was not proxied'
+else
+    result='SUCCESS'
+fi
+
+# Write the result to the installed /root
+echo "$result" > $ANA_INSTALL_PATH/root/RESULT
+%end
diff --git a/tests/kickstart_tests/proxy-auth.sh b/tests/kickstart_tests/proxy-auth.sh
new file mode 100755
index 0000000..fa15deb
--- /dev/null
+++ b/tests/kickstart_tests/proxy-auth.sh
@@ -0,0 +1,36 @@
+#
+# 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): David Shea <dshea at redhat.com>
+
+. ${KSTESTDIR}/functions.sh
+
+prepare() {
+    ks=$1
+    tmpdir=$2
+
+    if [[ "${KSTEST_ADDON_HTTP_REPO}" == "" ]]; then
+        echo \$KSTEST_ADDON_HTTP_REPO is not set.
+        return 1.
+    fi
+
+    # Flatten the kickstart to include the proxy %pre script
+    ( cd "$(dirname ${ks})" && ksflatten -o ${tmpdir}/kickstart.ks -c "$(basename $ks)" )
+
+    sed -e "/^repo/ s|HTTP-ADDON-REPO|${KSTEST_ADDON_HTTP_REPO}|" ${tmpdir}/kickstart.ks > ${tmpdir}/kickstart-repo.ks
+    echo ${tmpdir}/kickstart-repo.ks
+}


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


More information about the anaconda-patches mailing list