summaryrefslogtreecommitdiff
path: root/test/apiv2/20-containers.at
diff options
context:
space:
mode:
authorEd Santiago <santiago@redhat.com>2022-06-08 13:41:43 -0600
committerEd Santiago <santiago@redhat.com>2022-06-08 19:33:07 -0600
commitbce97a3b5dd1477c74232b49d246491aa289a995 (patch)
treec1258a578d6126df68210c1e3edb332ef63be22a /test/apiv2/20-containers.at
parent576c739e5ff01c760b383a258c62ed3ca7e1c30c (diff)
downloadpodman-bce97a3b5dd1477c74232b49d246491aa289a995.tar.gz
podman-bce97a3b5dd1477c74232b49d246491aa289a995.tar.bz2
podman-bce97a3b5dd1477c74232b49d246491aa289a995.zip
apiv2 tests: clean up
Mostly fix a bad design decision I made early on, re: registry. old: registry starts once, runs to the end new: registry is brought up on demand, then stopped Reason: there are times when we need a password-controlled registry, and times when we need it open. As long as I'm in here, I've also cleaned up some confusing code and fixed things so tests can run rootless again. Signed-off-by: Ed Santiago <santiago@redhat.com>
Diffstat (limited to 'test/apiv2/20-containers.at')
-rw-r--r--test/apiv2/20-containers.at19
1 files changed, 14 insertions, 5 deletions
diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at
index 4d32a1031..8f34b7e05 100644
--- a/test/apiv2/20-containers.at
+++ b/test/apiv2/20-containers.at
@@ -45,16 +45,16 @@ t GET libpod/containers/json?all=true 200 \
.[0].IsInfra=false
# Test compat API for Network Settings (.Network is N/A when rootless)
-network_expect=
+network_expect="Networks=null"
if root; then
- network_expect='.[0].NetworkSettings.Networks.podman.NetworkID=podman'
+ network_expect="Networks.podman.NetworkID=podman"
fi
t GET /containers/json?all=true 200 \
length=1 \
.[0].Id~[0-9a-f]\\{64\\} \
.[0].Image=$IMAGE \
.[0].Mounts~.*/tmp \
- $network_expect
+ .[0].NetworkSettings.$network_expect
# compat API imageid with sha256: prefix
t GET containers/json?limit=1 200 \
@@ -239,11 +239,15 @@ t GET containers/$cid/json 200 \
t POST containers/create Image=$IMAGE Entrypoint='["top"]' 201 \
.Id~[0-9a-f]\\{64\\}
cid_top=$(jq -r '.Id' <<<"$output")
+
+# Unexpected difference between /containers/json and /containers/CID/json:
+# in rootless, the former returns .Networks=none, the latter .Networks={}
+network_expect=${network_expect/=null/='{}'}
t GET containers/${cid_top}/json 200 \
.Config.Entrypoint[0]="top" \
.Config.Cmd='[]' \
.Path="top" \
- .NetworkSettings.Networks.podman.NetworkID=podman
+ .NetworkSettings.$network_expect
t POST containers/${cid_top}/start 204
# make sure the container is running
t GET containers/${cid_top}/json 200 \
@@ -374,8 +378,13 @@ t DELETE containers/$cid?v=true 204
t POST containers/create Image=$IMAGE HostConfig='{"NetworkMode":"default"}' 201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
+if root; then
+ network_type=bridge
+else
+ network_type=slirp4netns
+fi
t GET containers/$cid/json 200 \
- .HostConfig.NetworkMode="bridge"
+ .HostConfig.NetworkMode="$network_type"
t DELETE containers/$cid?v=true 204