Test/koji.sh: adjust for SBOM documents

Adjust the test case to cope with the SPDX SBOM documents uploaded to
the Koji. Also explicitly check that there is the expected number of
SBOM documents uploaded as the image build output.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-09-11 13:32:29 +02:00 committed by Tomáš Hozza
parent 71a12742d4
commit fd33a37366

View file

@ -185,7 +185,7 @@ function verify_buildinfo() {
fi
local outputs_manifests
outputs_manifests="$(koji -s "${KOJI_HUB_URL}" --noauth call --json listArchives "${buildid}" | jq -r 'map(select(.btype == "image" and .type_name == "json"))')"
outputs_manifests="$(koji -s "${KOJI_HUB_URL}" --noauth call --json listArchives "${buildid}" | jq -r 'map(select(.btype == "image" and .type_name == "json" and (.filename | contains(".manifest."))))')"
local outputs_manifests_count
outputs_manifests_count="$(echo "${outputs_manifests}" | jq 'length')"
if [ "${outputs_manifests_count}" -ne "${outputs_images_count}" ]; then
@ -193,6 +193,16 @@ function verify_buildinfo() {
exit 1
fi
local outputs_sboms
outputs_sboms="$(koji -s "${KOJI_HUB_URL}" --noauth call --json listArchives "${buildid}" | jq -r 'map(select(.btype == "image" and .type_name == "json" and (.filename | contains(".spdx."))))')"
local outputs_sboms_count
outputs_sboms_count="$(echo "${outputs_sboms}" | jq 'length')"
# there should be two SPDX files for each image, one for the image payload and one for the buildroot
if [ "${outputs_sboms_count}" -ne $((outputs_images_count * 2)) ]; then
echo "Mismatch between the number of image archives and SPDX SBOM files in the buildinfo"
exit 1
fi
local outputs_logs
outputs_logs="$(koji -s "${KOJI_HUB_URL}" --noauth call --json getBuildLogs "${buildid}" | jq -r 'map(select(.name != "cg_import.log"))')"
local outputs_logs_count