# 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 helpers_wait 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 return 0 } function setup_file() { export COSIGN_PASSWORD="" export COSIGN_OCI_EXPERIMENTAL=1 export COSIGN_EXPERIMENTAL=1 # 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_sync_per_root_dir=${BATS_FILE_TMPDIR}/zot-per local zot_sync_ondemand_root_dir=${BATS_FILE_TMPDIR}/zot-ondemand local zot_sync_per_config_file=${BATS_FILE_TMPDIR}/zot_sync_per_config.json local zot_sync_ondemand_config_file=${BATS_FILE_TMPDIR}/zot_sync_ondemand_config.json local zot_minimal_root_dir=${BATS_FILE_TMPDIR}/zot-minimal local zot_minimal_config_file=${BATS_FILE_TMPDIR}/zot_minimal_config.json local oci_data_dir=${BATS_FILE_TMPDIR}/oci mkdir -p ${zot_sync_per_root_dir} mkdir -p ${zot_sync_ondemand_root_dir} mkdir -p ${zot_minimal_root_dir} mkdir -p ${oci_data_dir} cat >${zot_sync_per_config_file} <${zot_sync_ondemand_config_file} <${zot_minimal_config_file} <${trust_policy_file} < config.json echo "hello world" > artifact.txt run oras push --plain-http 127.0.0.1:9000/hello-artifact:v2 \ --config config.json:application/vnd.acme.rocket.config.v1+json artifact.txt:text/plain -d -v [ "$status" -eq 0 ] rm -f artifact.txt rm -f config.json } @test "sync oras artifact periodically" { # # wait for oras artifact to be copied run sleep 15s run oras pull --plain-http 127.0.0.1:8081/hello-artifact:v2 -d -v [ "$status" -eq 0 ] grep -q "hello world" artifact.txt rm -f artifact.txt } @test "sync oras artifact on demand" { run oras pull --plain-http 127.0.0.1:8082/hello-artifact:v2 -d -v [ "$status" -eq 0 ] grep -q "hello world" artifact.txt rm -f artifact.txt } # sync helm chart @test "push helm chart" { run helm package ${BATS_FILE_TMPDIR}/helm-charts/charts/zot -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) run helm push ${BATS_FILE_TMPDIR}/zot-${chart_version}.tgz oci://localhost:9000/zot-chart [ "$status" -eq 0 ] } @test "sync helm chart periodically" { # wait for helm chart to be copied run sleep 15s local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) run helm pull oci://localhost:8081/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] } @test "sync helm chart on demand" { local chart_version=$(awk '/version/{printf $2}' ${BATS_FILE_TMPDIR}/helm-charts/charts/zot/Chart.yaml) run helm pull oci://localhost:8082/zot-chart/zot --version ${chart_version} -d ${BATS_FILE_TMPDIR} [ "$status" -eq 0 ] } # sync OCI artifacts @test "push OCI artifact (oci image mediatype) with regclient" { run regctl registry set localhost:9000 --tls disabled run regctl registry set localhost:8081 --tls disabled run regctl registry set localhost:8082 --tls disabled run regctl artifact put localhost:9000/artifact:demo <