@@ -15,6 +15,16 @@ function verify_prerequisites() {
1515 return 1
1616 fi
1717
18+ if ! command -v git > /dev/null; then
19+ echo " you need to install git as a prerequisite to running the tests" >&3
20+ return 1
21+ fi
22+
23+ if ! command -v docker > /dev/null; then
24+ echo " you need to install docker as a prerequisite to running the tests" >&3
25+ return 1
26+ fi
27+
1828 return 0
1929}
2030
@@ -232,38 +242,40 @@ function helper_delete_manifest() {
232242function helper_push_oras_artifact() {
233243 local artifact_name=${1:- hello-artifact}
234244 local tag=${2:- v2}
235- local zot_port annotations_file
245+ local zot_port annotations_file config_file artifact_file
236246 zot_port=$( get_zot_port)
237247 annotations_file=${BATS_TEST_TMPDIR} /oras-artifact-annotations.json
248+ config_file=${BATS_TEST_TMPDIR} /config.json
249+ artifact_file=${BATS_TEST_TMPDIR} /artifact.txt
238250
239- echo ' {"name":"foo","value":"bar"}' > config.json
240- echo " hello world" > artifact.txt
251+ echo ' {"name":"foo","value":"bar"}' > " ${config_file} "
252+ echo " hello world" > " ${artifact_file} "
241253 cat > " ${annotations_file} " << 'EOF '
242254{
243255 "artifact.txt": {
244256 "org.opencontainers.image.title": "artifact.txt"
245257 }
246258}
247259EOF
248- run oras push --plain-http " 127.0.0.1:${zot_port} /${artifact_name} :${tag} " \
260+ run oras push --disable-path-validation -- plain-http " 127.0.0.1:${zot_port} /${artifact_name} :${tag} " \
249261 --annotation-file " ${annotations_file} " \
250- --config config.json:application/vnd.acme.rocket.config.v1+json artifact.txt:text/plain -d -v
262+ --config " ${config_file} :application/vnd.acme.rocket.config.v1+json" \
263+ " ${artifact_file} :text/plain" -d -v
251264 [ " ${status} " -eq 0 ]
252- rm -f artifact.txt config.json
253265}
254266
255267# Args: $1 = artifact_name, $2 = tag
256268function helper_pull_oras_artifact() {
257269 local artifact_name=${1:- hello-artifact}
258270 local tag=${2:- v2}
259- local zot_port ref digest
271+ local zot_port ref digest artifact_file
260272 zot_port=$( get_zot_port)
261273 ref=" 127.0.0.1:${zot_port} /${artifact_name} :${tag} "
274+ artifact_file=${BATS_TEST_TMPDIR} /artifact.txt
262275
263- rm -f artifact.txt
264- run oras pull --plain-http " ${ref} " -d -v
276+ run oras pull --plain-http -o " ${BATS_TEST_TMPDIR} " " ${ref} " -d -v
265277 [ " ${status} " -eq 0 ]
266- grep -q " hello world" artifact.txt
278+ grep -q " hello world" " ${artifact_file} "
267279
268280 run oras manifest fetch --plain-http " ${ref} "
269281 [ " ${status} " -eq 0 ]
@@ -273,8 +285,6 @@ function helper_pull_oras_artifact() {
273285 run curl -fsSL " http://127.0.0.1:${zot_port} /v2/${artifact_name} /blobs/${digest} "
274286 [ " ${status} " -eq 0 ]
275287 echo " ${output} " | grep -q " hello world"
276-
277- rm -f artifact.txt
278288}
279289
280290# Args: $1 = image_name, $2 = tag
@@ -554,14 +564,15 @@ function helper_pull_oci_artifact_references_with_regclient() {
554564}
555565
556566function helper_push_docker_image() {
557- local zot_port
567+ local zot_port dockerfile
558568 zot_port=$( get_zot_port)
569+ dockerfile=${BATS_TEST_TMPDIR} /Dockerfile
559570
560- cat > Dockerfile << DOCKERFILE
571+ cat > " ${dockerfile} " << DOCKERFILE
561572FROM ghcr.io/project-zot/test-images/busybox-docker:1.37
562573RUN echo "hello world" > /testfile
563574DOCKERFILE
564- run sh -c " unset GODEBUG; docker build -f Dockerfile -t localhost:${zot_port} /test . "
575+ run sh -c " unset GODEBUG; docker build -f ' ${dockerfile} ' -t localhost:${zot_port} /test ' ${BATS_TEST_TMPDIR} ' "
565576 [ " ${status} " -eq 0 ]
566577 run docker push " localhost:${zot_port} /test"
567578 [ " ${status} " -eq 1 ]
0 commit comments