github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/apiv2/70-short-names.at (about) 1 # -*- sh -*- 2 # 3 # Tests for exercising short-name resolution in the compat API. 4 # 5 6 # Pull the libpod/quay image which is used in all tests below. 7 t POST "images/create?fromImage=quay.io/libpod/alpine:latest" 200 .error~null .status~".*Download complete.*" 8 9 # 14291 - let a short-name resolve to a *local* non Docker-Hub image. 10 t POST containers/create Image=alpine 201 .Id~[0-9a-f]\\{64\\} 11 cid=$(jq -r '.Id' <<<"$output") 12 t GET containers/$cid/json 200 .Image="quay.io/libpod/alpine:latest" 13 podman rm -f $cid 14 15 ########## TAG 16 17 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 18 t DELETE "images/docker.io/library/foo" 200 19 20 21 ########## BUILD 22 23 function test_build { 24 from=$1 25 tag=$2 26 fqn=$3 27 28 TMPD=$(mktemp -d podman-apiv2-test.build.XXXXXXXX) 29 CONTAINERFILE_TAR="${TMPD}/containerfile.tar" 30 cat > $TMPD/containerfile << EOF 31 FROM $from 32 RUN touch /foo 33 EOF 34 tar --format=posix -C $TMPD -cvf ${CONTAINERFILE_TAR} containerfile &> /dev/null 35 36 curl -XPOST --data-binary @<(cat $CONTAINERFILE_TAR) \ 37 -H "content-type: application/x-tar" \ 38 --dump-header "${TMPD}/headers.txt" \ 39 -o "${TMPD}/response.txt" \ 40 "http://$HOST:$PORT/build?dockerfile=containerfile&t=$tag" &> /dev/null 41 42 if ! grep -q '200 OK' "${TMPD}/headers.txt"; then 43 cat "${TMPD}/headers.txt" 44 cat "${TMPD}/response.txt" 45 echo -e "${red}NOK: Image build from tar failed response was not 200 OK (application/x-tar)" 46 exit 1 47 fi 48 49 rm -rf $TMPD 50 t DELETE "images/$fqn" 200 51 } 52 53 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 54 test_build foo bar "docker.io/library/bar:latest" 55 t DELETE "images/foo" 200 56 57 58 ########## TAG 59 60 # The libpod endpoint will resolve to it without issues. 61 t GET "libpod/images/alpine/exists" 204 62 63 # Now let's tag the image with 'foo'. Remember, it will be normalized to 64 # docker.io/library/foo. 65 t GET "libpod/images/docker.io/library/foo/exists" 404 66 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 67 t GET "libpod/images/docker.io/library/foo/exists" 204 68 69 70 ########## REMOVE 71 72 t DELETE "images/foo" 200 # removes the previously tagged image 73 74 75 ########## GET 76 77 # Same procedure as above but with the /get endpoint. 78 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 79 t GET "images/foo/get" 200 '[POSIX tar archive]' 80 t DELETE "images/foo" 200 81 t GET "images/alpine/get" 200 82 83 84 ########## HISTORY 85 86 t GET "images/alpine/history" 200 87 t GET "images/quay.io/libpod/alpine/history" 200 88 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 89 t GET "libpod/images/foo/history" 200 90 t DELETE "images/foo" 200 91 92 93 ########## PUSH 94 95 t POST "images/alpine/push?destination=localhost:9999/do:exist" 200 96 t POST "images/quay.io/libpod/alpine/push?destination=localhost:9999/do/not:exist" 200 # Error is in the response 97 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 98 t POST "images/foo/push?destination=localhost:9999/do/not:exist" 200 # Error is in the response 99 t DELETE "images/foo" 200 100 101 102 ########## CREATE A CONTAINER 103 104 t POST "containers/create" Image=alpine 201 105 t POST "containers/create" Image=quay.io/libpod/alpine:latest 201 106 cid=$(jq -r '.Id' <<<"$output") 107 t POST "images/quay.io/libpod/alpine/tag?repo=foo" 201 108 t POST "containers/create" Image=foo 201 109 cid=$(jq -r '.Id' <<<"$output") 110 t DELETE "images/foo" 200 111 t DELETE "containers/$cid" 204 112 113 ########## COMMIT CONTAINER 114 115 t POST "containers/create" Image=quay.io/libpod/alpine:latest 201 116 cid=$(jq -r '.Id' <<<"$output") 117 t GET "images/alpine/get" 200 118 t POST "commit?container=$cid&repo=foo&tag=tag" 201 119 t GET "images/foo/get" 404 .cause="image not known" 120 t GET "images/foo:tag/get" 200 121 t DELETE "images/docker.io/library/foo:tag" 200 122 t DELETE "containers/$cid" 204 123 124 125 ######### SMOKE TESTS WITHOUT DOCKER.IO ENFORCEMENT 126 127 # Note that we need to restart the service with a custom containers.conf to 128 # disable the docker.io enforcement. 129 130 stop_service 131 CONTAINERS_CONF=$TESTS_DIR/containers.conf start_service 132 133 t POST "images/create?fromImage=quay.io/libpod/alpine:latest" 200 .error~null .status~".*Download complete.*" 134 t POST "images/alpine/tag?repo=foo" 201 135 t GET "images/localhost/foo:latest/get" 200 136 t DELETE "images/foo" 200 137 t GET "images/alpine/history" 200 138 t POST "images/alpine/push?destination=localhost:9999/do/not:exist" 200 # Error is in the response 139 t POST "containers/create" Image=alpine 201 140 cid=$(jq -r '.Id' <<<"$output") 141 t POST "commit?container=$cid&repo=foo&tag=tag" 201 142 t DELETE "images/localhost/foo:tag" 200 143 t DELETE "containers/$cid" 204 144 145 test_build alpine bar "localhost/bar:latest" 146 147 148 stop_service 149 start_service