#!/usr/share/ucs-test/runner bash
# shellcheck shell=bash
## desc: Check for APT archive keyrings
## tags: [apptest]
## exposure: safe
## versions:
##  4.2-0: skip
##  5.0-2: fixed

# shellcheck source=../../lib/base.sh
. "$TESTLIBPATH/base.sh" || exit 137
set -e -u

found_ucs=
found_other=false
while read -r pkg status
do
	case "$pkg" in
	univention-archive-key)
		found_ucs="$status"
		;;
	*-archive-keyring)
		case "$status" in
		"install"*|*" installed")
			fail_test 1 "found other APT keyring: $pkg $status"
			found_other=true
			;;
		esac
		;;
	esac
done <<__EOF__
$(dpkg-query -W -f '${Package} ${Status}\n' \*-archive-key\*)
__EOF__

case "$found_ucs" in
	"install ok installed") info "GOOD: found APT keyring for UCS" ;;
	*) fail_test 1 "missing APT keyring for UCS: $found_ucs" ;;
esac

if ! "$found_other"
then
	info "GOOD: found no other APT keyrings"
fi

exit "$RETVAL"
# vim:set ft=sh:
