#!/usr/bin/env bats load helpers load helpers.network load helpers.registry # All tests in this file must be able to run in parallel # bats file_tags=ci:parallel # Runs once before all tests in this file function setup_file() { if ! is_remote; then start_registry authfile=${PODMAN_LOGIN_WORKDIR}/auth-manifest.json run_podman login --tls-verify=false \ --username ${PODMAN_LOGIN_USER} \ --password-stdin \ --authfile=$authfile \ localhost:${PODMAN_LOGIN_REGISTRY_PORT} <<<"${PODMAN_LOGIN_PASS}" is "$output" "Login Succeeded!" "output from podman login" fi } function teardown() { # Enumerate every one of the manifest names used everywhere below echo "[ teardown - ignore 'image not known' errors below ]" run_podman '?' manifest rm "m-$(safename):1.0" \ localhost:${PODMAN_LOGIN_REGISTRY_PORT}/"m-$(safename):1.0" basic_teardown } # Helper function for several of the tests which verifies compression. # # Usage: validate_instance_compression INDEX MANIFEST ARCH COMPRESSION # # INDEX instance which needs to be verified in # provided manifest list. # # MANIFEST OCI manifest specification in json format # # ARCH instance architecture # # COMPRESSION compression algorithm name; e.g "zstd". # function validate_instance_compression { case $4 in gzip) run jq -r '.manifests['$1'].annotations' <<< $2 # annotation is `null` for gzip compression assert "$output" = "null" ".manifests[$1].annotations (null means gzip)" ;; zstd) # annotation `'"io.github.containers.compression.zstd": "true"'` must be there for zstd compression run jq -r '.manifests['$1'].annotations."io.github.containers.compression.zstd"' <<< $2 assert "$output" = "true" ".manifests[$1].annotations.'io.github.containers.compression.zstd' (io.github.containers.compression.zstd must be set)" ;; esac run jq -r '.manifests['$1'].platform.architecture' <<< $2 assert "$output" = $3 ".manifests[$1].platform.architecture" } # Regression test for #8931 @test "podman images - bare manifest list" { # Create an empty manifest list and list images. run_podman inspect --format '{{.ID}}' $IMAGE iid=$output mname="m-$(safename):1.0" run_podman manifest create $mname mid=$output run_podman manifest inspect --verbose $mid is "$output" ".*\"mediaType\": \"application/vnd.docker.distribution.manifest.list.v2+json\"" "--insecure is a noop want to make sure manifest inspect is successful" run_podman manifest inspect -v $mid is "$output" ".*\"mediaType\": \"application/vnd.docker.distribution.manifest.list.v2+json\"" "--insecure is a noop want to make sure manifest inspect is successful" run_podman images --format '{{.ID}}' --no-trunc is "$output" ".*sha256:$iid" "Original image ID still shown in podman-images output" run_podman rmi $mname } @test "podman manifest --tls-verify and --authfile" { skip_if_remote "running a local registry doesn't work with podman-remote" manifest1="localhost:${PODMAN_LOGIN_REGISTRY_PORT}/m-$(safename):1.0" run_podman manifest create $manifest1 mid=$output authfile=${PODMAN_LOGIN_WORKDIR}/auth-manifest.json run_podman manifest push --authfile=$authfile \ --tls-verify=false $mid \ $manifest1 run_podman manifest rm $manifest1 run_podman 1 manifest rm $manifest1 is "$output" "Error: $manifest1: image not known" "Missing manifest is reported" run_podman manifest rm --ignore $manifest1 is "$output" "" "Missing manifest is ignored" # Default is to require TLS; also test explicit opts for opt in '' '--insecure=false' '--tls-verify=true' "--authfile=$authfile"; do run_podman 125 manifest inspect $opt $manifest1 assert "$output" =~ "Error: reading image \"docker://$manifest1\": pinging container registry localhost:${PODMAN_LOGIN_REGISTRY_PORT}:.*x509" \ "TLE check: fails (as expected) with ${opt:-default}" done run_podman manifest inspect --authfile=$authfile --tls-verify=false $manifest1 is "$output" ".*\"mediaType\": \"application/vnd.docker.distribution.manifest.list.v2+json\"" "Verify --tls-verify=false --authfile works against an insecure registry" run_podman manifest inspect --authfile=$authfile --insecure $manifest1 is "$output" ".*\"mediaType\": \"application/vnd.docker.distribution.manifest.list.v2+json\"" "Verify --insecure --authfile works against an insecure registry" REGISTRY_AUTH_FILE=$authfile run_podman manifest inspect --tls-verify=false $manifest1 is "$output" ".*\"mediaType\": \"application/vnd.docker.distribution.manifest.list.v2+json\"" "Verify --tls-verify=false with REGISTRY_AUTH_FILE works against an insecure registry" } @test "manifest list --add-compression with zstd:chunked" { skip_if_remote "running a local registry doesn't work with podman-remote" # Using TARGETARCH gives us distinct images for each arch dockerfile=$PODMAN_TMPDIR/Dockerfile cat >$dockerfile < ${PODMAN_TMPDIR}/listed.txt echo '{}' > ${PODMAN_TMPDIR}/minimum-config.json local listFlags platformFlags typeFlag configTypeFlag configFlag layerTypeFlag titleFlag for listFlags in "" "--annotation global=local" ; do manifestListAddArtifactOnce done for platformFlags in "" "--os=linux --arch=amd64" ; do manifestListAddArtifactOnce done for typeFlag in "" --artifact-type="" --artifact-type=application/octet-stream --artifact-type=text/plain ; do manifestListAddArtifactOnce done for configTypeFlag in "" --artifact-config-type=application/octet-stream --artifact-config-type=text/plain ; do for configFlag in "" --artifact-config= --artifact-config=${PODMAN_TMPDIR}/minimum-config.json ; do manifestListAddArtifactOnce done done for layerTypeFlag in "" --artifact-layer-type=application/octet-stream --artifact-layer-type=text/plain ; do manifestListAddArtifactOnce done for titleFlag in "" "--artifact-exclude-titles" ; do manifestListAddArtifactOnce done } # vim: filetype=sh