summaryrefslogtreecommitdiff
path: root/test/apiv2/12-imagesMore.at
blob: d4b09174f1969439909b0d471c591966d0c3abbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- sh -*-
#
# Tests for more image-related endpoints
#

red='\e[31m'
nc='\e[0m'

start_registry

podman pull -q $IMAGE

t GET libpod/images/json 200 \
  .[0].Id~[0-9a-f]\\{64\\}
iid=$(jq -r '.[0].Id' <<<"$output")

# Retrieve the image tree
t GET libpod/images/$IMAGE/tree 200 \
  .Tree~^Image

# Tag nonesuch image
t POST "libpod/images/nonesuch/tag?repo=myrepo&tag=mytag" 404

# Tag the image
t POST "libpod/images/$IMAGE/tag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201

t GET libpod/images/$IMAGE/json 200 \
  .RepoTags[1]=localhost:$REGISTRY_PORT/myrepo:mytag

# Push to local registry...
t POST "images/localhost:$REGISTRY_PORT/myrepo/push?tlsVerify=false&tag=mytag" 200

# ...and check output. We can't use our built-in checks because this output
# is a sequence of JSON objects, i.e., individual ones, not in a JSON array.
# The lines themselves are valid JSON, but taken together they are not.
readarray lines <<<"$output"
s0=$(jq -r .status <<<"${lines[0]}")
is "$s0" "The push refers to repository [localhost:$REGISTRY_PORT/myrepo:mytag]" \
   "Push to local registry: first status line"

# FIXME: is there a way to test the actual digest?
s1=$(jq -r .status <<<"${lines[1]}")
like "$s1" "mytag: digest: sha256:[0-9a-f]\{64\} size: [0-9]\+" \
     "Push to local registry: second status line"

# Untag the image
t POST "libpod/images/$iid/untag?repo=localhost:$REGISTRY_PORT/myrepo&tag=mytag" 201

# Try to push non-existing image
t POST "images/localhost:$REGISTRY_PORT/idonotexist/push?tlsVerify=false" 404

t GET libpod/images/$IMAGE/json 200 \
  .RepoTags[-1]=$IMAGE

# Remove image
t DELETE libpod/images/$IMAGE 200 \
  .ExitCode=0

podman pull -q $IMAGE

# test podman image SCP
# ssh needs to work so we can validate that the failure is past argument parsing
podman system connection add --default test ssh://$USER@localhost/run/user/$UID/podman/podman.sock
# should fail but need to check the output...
# status 125 here means that the save/load fails due to
# cirrus weirdness with exec.Command. All of the args have been parsed successfully.
t POST "libpod/images/scp/$IMAGE?destination=QA::" 500 \
    .cause="exit status 125"
t DELETE libpod/images/$IMAGE 200 \
  .ExitCode=0

stop_registry