# Note: Intended to be run as "make run-blackbox-tests" or "make run-blackbox-ci" # Makefile target installs & checks all necessary tooling # Extra tools that are not covered in Makefile target needs to be added in verify_prerequisites() load helpers_zot load ../port_helper function verify_prerequisites { if [ ! $(command -v curl) ]; then echo "you need to install curl as a prerequisite to running the tests" >&3 return 1 fi if [ ! $(command -v jq) ]; then echo "you need to install jq as a prerequisite to running the tests" >&3 return 1 fi if [ ! $(command -v podman) ]; then echo "you need to install podman as a prerequisite to running the tests" >&3 return 1 fi if [ ! $(command -v cosign) ]; then echo "you need to install cosign as a prerequisite to running the tests" >&3 return 1 fi return 0 } function setup_file() { export COSIGN_PASSWORD="" # Verify prerequisites are available if ! verify_prerequisites; then exit 1 fi # Download test data to folder common for the entire suite, not just this file skopeo --insecure-policy copy --format=oci docker://ghcr.io/project-zot/golang:1.20 oci:${TEST_DATA_DIR}/golang:1.20 # Setup zot server local zot_root_dir=${BATS_FILE_TMPDIR}/zot local zot_config_file=${BATS_FILE_TMPDIR}/zot_config.json mkdir -p ${zot_root_dir} zot_port=$(get_free_port_for_service "zot") echo ${zot_port} > ${BATS_FILE_TMPDIR}/zot.port cat > ${zot_config_file}< ${BATS_FILE_TMPDIR}/stacker.yaml< ${BATS_FILE_TMPDIR}/Dockerfile<"${trust_policy_file}" { "version": "1.0", "trustPolicies": [ { "name": "notation-sign-test", "registryScopes": [ "*" ], "signatureVerification": { "level" : "strict" }, "trustStores": [ "ca:notation-sign-test" ], "trustedIdentities": [ "*" ] } ] } EOF run notation policy import --force "${trust_policy_file}" [ "$status" -eq 0 ] run notation sign --debug --verbose --force-referrers-tag=true --key "notation-sign-test" --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] run notation verify --debug --verbose --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] run notation list --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] } @test "sign/verify with notation using referrers api" { zot_port=`cat ${BATS_FILE_TMPDIR}/zot.port` run curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ ImageList(repo: \"annotations\") { Results { RepoName Tag Manifests {Digest ConfigDigest Size Layers { Size Digest }} Vendor Licenses }}}"}' http://localhost:${zot_port}/v2/_zot/ext/search [ "$status" -eq 0 ] [ $(echo "${lines[-1]}" | jq '.data.ImageList.Results[0].RepoName') = '"annotations"' ] [ "$status" -eq 0 ] run notation cert generate-test "notation-sign-test-experimental" [ "$status" -eq 0 ] local trust_policy_file=/tmp/trustpolicy.json cat <"${trust_policy_file}" { "version": "1.0", "trustPolicies": [ { "name": "notation-sign-test-experimental", "registryScopes": [ "*" ], "signatureVerification": { "level" : "strict" }, "trustStores": [ "ca:notation-sign-test-experimental" ], "trustedIdentities": [ "*" ] } ] } EOF run notation policy import --force "${trust_policy_file}" [ "$status" -eq 0 ] run notation sign --debug --verbose --force-referrers-tag=false --key "notation-sign-test-experimental" --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] run notation verify --debug --verbose --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] run notation list --insecure-registry localhost:${zot_port}/annotations:latest [ "$status" -eq 0 ] }