Skip to content

Commit

Permalink
Fix proxy-auth and proxy-kickstart tests
Browse files Browse the repository at this point in the history
This covers issue #1108.
  • Loading branch information
jikortus committed May 17, 2024
1 parent 0e5c614 commit 759cb48
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
24 changes: 20 additions & 4 deletions proxy-auth.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,25 @@ if [[ ! -f /mnt/sysroot/etc/yum.repos.d/addon.repo ]]; then
fi

# Check that the proxy configuration was written to the repo file
grep -q 'proxy=http://anaconda:qweqwe@PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
if [[ $? -ne 0 ]]; then
# The repo configuration has a different format on RHEL-10+/Fedora 40+
os_version=$(. /etc/os-release && echo ${VERSION_ID%%.*})
platform=$(. /etc/os-release && echo ${ID})

if [ "${platform}" == "rhel" ] && [ ${os_version} -lt 10 ]; then
grep -q 'proxy=http://anaconda:qweqwe@PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
proxy_rc=$?
else
grep -qP 'proxy\s?=\s?http://PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo && \
grep -qP 'proxy_username\s?=\s?anaconda' /mnt/sysroot/etc/yum.repos.d/addon.repo && \
grep -qP 'proxy_password\s?=\s?qweqwe' /mnt/sysroot/etc/yum.repos.d/addon.repo
proxy_rc=$?
fi
if [[ ${proxy_rc} -ne 0 ]]; then
echo 'addon.repo does not contain proxy information' >> /mnt/sysroot/root/RESULT
echo "/etc/yum.repos.d/addon.repo content:" >> /mnt/sysroot/root/RESULT
cat /mnt/sysroot/etc/yum.repos.d/addon.repo >> /mnt/sysroot/root/RESULT
echo >> /mnt/sysroot/root/RESULT

fi

# Check that the installed repo file is usable
Expand All @@ -46,8 +62,8 @@ chroot /mnt/sysroot $BIN clean packages

# Download package to test if the installed repository is usable
chroot /mnt/sysroot \
$BIN --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
reinstall mandatory-package-from-addon 2>/dev/null | \
$BIN reinstall --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
mandatory-package-from-addon 2>/dev/null | \
grep -q 'mandatory-package-from-addon'
if [[ $? -ne 0 ]]; then
echo 'unable to query addon repo' >> /mnt/sysroot/root/RESULT
Expand Down
3 changes: 3 additions & 0 deletions proxy-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ prepare() {
local tmp_dir=$2
local httpd_url=""
local proxy_url=""
httpd_url=$(cat ${tmpdir}/httpd_url)
proxy_url=$(cat ${tmpdir}/proxy_url)
local proxy_rc
mkdir "${tmp_dir}/http"

# Create the addon repository.
Expand Down
9 changes: 6 additions & 3 deletions proxy-kickstart.ks.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ if [[ ! -f /mnt/sysroot/etc/yum.repos.d/addon.repo ]]; then
fi

# Check that the proxy configuration was written to the repo file
grep -q 'proxy=PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
grep -qP 'proxy\s?=\s?PROXY-ADDON' /mnt/sysroot/etc/yum.repos.d/addon.repo
if [[ $? -ne 0 ]]; then
echo 'addon.repo does not contain proxy information' >> /mnt/sysroot/root/RESULT
echo "/etc/yum.repos.d/addon.repo content:" >> /mnt/sysroot/root/RESULT
cat /mnt/sysroot/etc/yum.repos.d/addon.repo >> /mnt/sysroot/root/RESULT
echo >> /mnt/sysroot/root/RESULT
fi

# Check that the installed repo file is usable
Expand All @@ -46,8 +49,8 @@ fi
chroot /mnt/sysroot $BIN clean packages
# Download package to test if the installed repository is usable
chroot /mnt/sysroot \
$BIN --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
reinstall mandatory-package-from-addon 2>/dev/null | \
$BIN reinstall --disablerepo=\* --enablerepo=addon --downloadonly --nogpgcheck -y \
mandatory-package-from-addon 2>/dev/null | \
grep -q 'mandatory-package-from-addon'
if [[ $? -ne 0 ]]; then
echo 'unable to query addon repo' >> /mnt/sysroot/root/RESULT
Expand Down
5 changes: 4 additions & 1 deletion proxy-kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ prepare() {
local tmp_dir=$2
local httpd_url=""
local proxy_url=""
httpd_url=$(cat ${tmpdir}/httpd_url)
proxy_url=$(cat ${tmpdir}/proxy_url)
local proxy_rc
mkdir "${tmp_dir}/http"

# Create the addon repository.
Expand All @@ -52,7 +55,7 @@ prepare() {
# Substitute variables in the kickstart file.
sed -e "/^repo/ s|HTTP-ADDON-REPO|${httpd_local_url}|" \
-re "/^(repo|url)/ s|PROXY-ADDON|${proxy_url}|" \
-e "/'proxy=/ s|PROXY-ADDON|${proxy_url%%/*}|" \
-e "/'proxy\\\\s\?=/ s|PROXY-ADDON|${proxy_url%/*}|" \
"${ks}" > "${tmp_dir}/ks.cfg"

echo "${tmp_dir}/ks.cfg"
Expand Down

0 comments on commit 759cb48

Please sign in to comment.