tests/repo: Make a test more robust by checking files for diff

Instead of trying to read them into variables, which could fail if there
were null bytes in the key.

Fixes: 43642337 ("dir: Try to delete the remote if we failed to add it entirely")
This commit is contained in:
Sebastian Wick
2026-04-28 12:25:10 +02:00
parent 3296c9e619
commit bd75302323

View File

@@ -138,12 +138,12 @@ port=$(cat httpd-port)
echo "bad key" > badkey
gpg2_repo_url=$(ostree config --repo=$FL_DIR/repo get --group 'remote "test-gpg2-repo"' url)
gpg2_repo_key=$(cat "$FL_DIR/repo/test-gpg2-repo.trustedkeys.gpg")
cp "$FL_DIR/repo/test-gpg2-repo.trustedkeys.gpg" gpg2_repo_key
${FLATPAK} ${U} remote-modify --gpg-import=badkey test-gpg2-repo >&2 || true
gpg2_repo_url2=$(ostree config --repo=$FL_DIR/repo get --group 'remote "test-gpg2-repo"' url)
gpg2_repo_key2=$(cat "$FL_DIR/repo/test-gpg2-repo.trustedkeys.gpg")
cp "$FL_DIR/repo/test-gpg2-repo.trustedkeys.gpg" gpg2_repo_key2
if [[ "${gpg2_repo_url}" != "${gpg2_repo_url2}" || "${gpg2_repo_key}" != "${gpg2_repo_key2}" ]]; then
if [[ "${gpg2_repo_url}" != "${gpg2_repo_url2}" ]] || ! diff -q gpg2_repo_key gpg2_repo_key2 > /dev/null 2>&1; then
assert_not_reached "remote-modify failed but remote was modified"
fi