CloudAPI: test /sboms endpoint for Koji composes

Extend the API unit test for Koji composes, to verify that the newly
added /sboms endpoint works correctly.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-09-13 15:02:52 +02:00 committed by Tomáš Hozza
parent cf79bf677b
commit efc251fa02

View file

@ -514,6 +514,44 @@ func TestKojiCompose(t *testing.T) {
// get the logs
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/logs", finalizeID), ``, http.StatusOK, `{"kind":"ComposeLogs"}`, `koji`, `image_builds`, `href`, `id`)
// get the SBOMs
test.TestRoute(t, handler, false, "GET", fmt.Sprintf("/api/image-builder-composer/v2/composes/%v/sboms", finalizeID), ``, http.StatusOK, fmt.Sprintf(`
{
"href": "/api/image-builder-composer/v2/composes/%v/sboms",
"id": "%v",
"kind": "ComposeSBOMs",
"items": [
[
{
"pipeline_name": "build",
"pipeline_purpose": "buildroot",
"sbom": %[3]s,
"sbom_type": %[4]q
},
{
"pipeline_name": "os",
"pipeline_purpose": "image",
"sbom": %[3]s,
"sbom_type": %[4]q
}
],
[
{
"pipeline_name": "build",
"pipeline_purpose": "buildroot",
"sbom": %[3]s,
"sbom_type": %[4]q
},
{
"pipeline_name": "os",
"pipeline_purpose": "image",
"sbom": %[3]s,
"sbom_type": %[4]q
}
]
]
}`, finalizeID, finalizeID, sbomDoc, v2.ImageSBOMSbomTypeSpdx), "details")
})
}
}