tests: abuild-sign: refactor owner 0/0 test

Refactor test that verifies that owner in tar archive is numeric 0/0
This commit is contained in:
Natanael Copa 2022-06-15 12:43:45 +02:00
parent ea4c0e0eba
commit 0a9f7d1e31
2 changed files with 15 additions and 33 deletions

View File

@ -1,32 +0,0 @@
#/usr/bin/env bats
setup() {
export ABUILD="$PWD/../abuild"
export ABUILD_SHAREDIR="$PWD/.."
export ABUILD_CONF=/dev/null
export REPODEST="$BATS_TEST_TMPDIR"/packages
export CLEANUP="srcdir bldroot pkgdir deps"
export WORKDIR="$BATS_TEST_TMPDIR"/work
export APORTSDIR="$PWD"/testrepo
export PATH="$PWD/../:$PATH"
export ARCH=$(apk --print-arch)
if ! abuild-sign --installed 2>/dev/null; then
abuild-keygen -ain >/dev/null 2>&1
fi
mkdir -p "$BATS_TEST_TMPDIR" "$WORKDIR"
}
@test 'abuild-sign: do not record user name/id in index' {
cd testrepo/pkg1
$ABUILD
tar tvzf "$REPODEST"/testrepo/"$ARCH"/APKINDEX.tar.gz --numeric-owner|
while read -r _ user _ _ _ f; do
if [ "$user" != "0/0" ]; then
echo "file '$f' is not owned by 0/0 (owned by $user)" >&2
exit 1
fi
done
}

View File

@ -8,7 +8,8 @@ init_tests \
abuild_sign_installed_missing \
abuild_sign_installed_missing_pub \
abuild_sign_installed_missing_priv \
abuild_sign_installed
abuild_sign_installed \
abuild_sign_owner
export ABUILD_SHAREDIR="$(atf_get_srcdir)/.."
@ -62,3 +63,16 @@ abuild_sign_installed_body() {
abuild-sign --installed
}
abuild_sign_owner_body() {
init_keys
echo foo > .PKGINFO
tar -zcf foo.tar.gz .PKGINFO || atf_fail "Failed to create unsigned test archive"
atf_check -s exit:0 \
-e match:"Signed" \
abuild-sign foo.tar.gz
atf_check -s exit:0 \
-o match:"0/0.*\.SIGN\.RSA" \
tar -ztvf foo.tar.gz
}