github.com/containers/podman/v5@v5.1.0-rc1/test/apiv2/12-imagesMore.at (about) 1 # -*- sh -*- 2 # 3 # Tests for more image-related endpoints 4 # 5 6 start_registry 7 8 podman pull -q $IMAGE 9 10 t GET libpod/images/json 200 \ 11 .[0].Id~[0-9a-f]\\{64\\} 12 iid=$(jq -r '.[0].Id' <<<"$output") 13 14 # Retrieve the image tree 15 t GET libpod/images/$IMAGE/tree 200 \ 16 .Tree~^Image 17 18 # Tag nonesuch image 19 t POST "libpod/images/nonesuch/tag?repo=myrepo&tag=mytag" 404 20 21 # Tag the image 22 t POST "libpod/images/$IMAGE/tag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201 23 24 t GET libpod/images/$IMAGE/json 200 \ 25 .RepoTags[0]=localhost:$REGISTRY_PORT/myrepo:mytag 26 27 # Push to local registry... 28 t POST "/v1.40/images/localhost:$REGISTRY_PORT/myrepo/push?tag=mytag" 500 \ 29 .error~".*x509: certificate signed by unknown authority" 30 t POST "images/localhost:$REGISTRY_PORT/myrepo/push?tlsVerify=false&tag=mytag" 200 \ 31 .error~null 32 33 # ...and check output. We can't use our built-in checks because this output 34 # is a sequence of JSON objects, i.e., individual ones, not in a JSON array. 35 # The lines themselves are valid JSON, but taken together they are not. 36 readarray lines <<<"$output" 37 s0=$(jq -r .status <<<"${lines[0]}") 38 is "$s0" "The push refers to repository [localhost:$REGISTRY_PORT/myrepo:mytag]" \ 39 "Push to local registry: first status line" 40 41 # FIXME: is there a way to test the actual digest? 42 s1=$(jq -r .status <<<"${lines[1]}") 43 like "$s1" "mytag: digest: sha256:[0-9a-f]\{64\} size: [0-9]\+" \ 44 "Push to local registry: second status line" 45 46 # Push to local registry using the libpod endpoint with quiet=false... 47 # First create a new tag for the image to push 48 t POST "libpod/images/$IMAGE/tag?repo=localhost:$REGISTRY_PORT/myrepo&tag=quiet-false" 201 49 50 t POST "libpod/images/localhost:$REGISTRY_PORT/myrepo:quiet-false/push?tlsVerify=false&quiet=false" 200 51 52 # ...and check output. We can't use our built-in checks because this output 53 # is a sequence of JSON objects, i.e., individual ones, not in a JSON array. 54 # The lines themselves are valid JSON, but taken together they are not. 55 readarray lines <<<"$output" 56 s0=$(jq -r .manifestdigest <<<"${lines[-1]}") 57 like "$s0" "sha256:[0-9a-f]\{64\}" \ 58 "Push to local registry: last line in push report" 59 60 # Untag the image 61 t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201 62 t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=quiet-false" 201 63 64 # Try to push non-existing image 65 t POST "images/localhost:$REGISTRY_PORT/idonotexist/push?tlsVerify=false" 404 66 67 t GET libpod/images/$IMAGE/json 200 \ 68 .RepoTags[-1]=$IMAGE 69 70 # Remove image 71 t DELETE libpod/images/$IMAGE 200 \ 72 .ExitCode=0 73 74 podman pull -q $IMAGE 75 76 # test podman image SCP 77 # ssh needs to work so we can validate that the failure is past argument parsing 78 conn=apiv2test-temp-connection 79 podman system connection add --default $conn \ 80 ssh://$USER@localhost/run/user/$UID/podman/podman.sock 81 # should fail but need to check the output... 82 # status 125 here means that the save/load fails due to 83 # cirrus weirdness with exec.Command. All of the args have been parsed successfully. 84 t POST "libpod/images/scp/$IMAGE?destination=QA::" 500 \ 85 .cause="exit status 125" 86 t DELETE libpod/images/$IMAGE 200 \ 87 .ExitCode=0 88 89 # Clean up 90 podman system connection rm $conn 91 92 stop_registry 93 94 # if an image is a manifest list, it should not have 95 # anything for arch or os 96 podman manifest create foobar 97 t GET libpod/images/json 200 \ .[0].IsManifestList=true \ 98 .[0].Arch=null \ 99 .[0].Os=null 100 101 102 # list images through the libpod endpoint should return 103 # IsManifestList (bool), Arch (string), and Os (string) 104 podman pull -q $IMAGE 105 t GET libpod/images/json 200 \ .[0].IsManifestList=true\ 106 .[0].Arch=null \ 107 .[0].Os=null \ 108 '.[0].RepoDigests | length=1' \ 109 .[1].IsManifestList=false \ 110 .[1].Arch=amd64 \ 111 .[1].Os=linux 112 113 # if a manifest list and an image are returned with libpod images 114 # endpoint, then one should be a manifest with IsManifest only; and 115 # the other image should have IsManifestList, Arch, and Os. 116 podman manifest add --arch amd64 foobar $IMAGE 117 t GET libpod/images/json 200 .[0].IsManifestList=true\ 118 .[0].Arch=null \ 119 .[0].Os=null \ 120 '.[0].RepoDigests | length=2' \ 121 .[1].IsManifestList=false \ 122 .[1].Arch=amd64 \ 123 .[1].Os=linux 124 125 t GET images/json 200 .[0].IsManifestList=null \ 126 .[0].Arch=null \ 127 .[0].Os=null \ 128 .[1].IsManifestList=null \ 129 .[1].Arch=null \ 130 .[1].Os=null \