spiegel_podman/test/apiv2
Rudraksha Singh 2ac2529bf7
compat: ignore dead and restarting status filters
Docker documents `dead` and `restarting` as valid values for the
`status` filter on `/containers/json`. Podman returns HTTP 500 when
either of them is used even though no Podman container can ever be in
those states.

Ignore these values in the compat API. If they are the only status
filters, return an empty list like Docker does. Invalid status values
still return an error.

The libpod API still rejects these values since they are Docker
specific. Update the libpod API docs to list the states Podman
actually supports.

Reference:
https://docs.docker.com/reference/api/engine/version/v1.51/#tag/Container/operation/ContainerList

Fixes: #28904
Signed-off-by: Rudraksha Singh <rudraksharss@gmail.com>
2026-09-29 00:21:19 +05:30
..
python Update dependency setuptools to v84 2026-08-08 20:26:03 +00:00
00-TEMPLATE Tests for API v2 2020-01-17 09:59:22 -07:00
01-basic.at test/apiv2: remove cgroupv2 check 2026-09-10 12:37:52 +02:00
10-images.at Merge pull request #28358 from aaron-ang/issue-17726-distribution-api 2026-09-23 10:49:31 +02:00
12-imagesMore.at Merge pull request #29395 from scallaway/image-scp-compression 2026-09-17 17:09:06 +02:00
14-commit.at Accept a config blob alongside the "changes" slice when committing 2023-11-30 09:00:52 -05:00
15-manifest.at test/apiv2: cover the manifest-create images query param 2026-06-29 12:01:34 +02:00
19-stats.at api: reflect container stats errors in HTTP status codes 2026-09-04 20:42:55 +09:00
20-containers.at compat: ignore dead and restarting status filters 2026-09-29 00:21:19 +05:30
21-restart.at Respect container StopTimeout in container restart REST APIs 2026-09-02 10:39:55 -07:00
22-stop.at Add support for passing container stop timeout as -1 (infinite) 2023-08-04 08:36:45 -04:00
23-containersArchive.at Revert "Fix copyUIDGID parameter inversion in Docker compat API" 2025-11-14 12:39:04 +01:00
25-containersMore.at test/apiv2: remove cgroupv2 check 2026-09-10 12:37:52 +02:00
26-containersWait.at Preserve exited state for logs-only HTTP attach 2026-08-31 20:31:24 +02:00
27-containersEvents.at api/compat: switch to moby/moby 2026-03-09 11:09:23 +01:00
28-containersAnnotations.at Add support for annotations 2024-03-22 19:38:22 +00:00
29-containersUpdate.at api/libpod: fix r_limits cleared on update 2026-05-27 13:32:31 +02:00
30-volumes.at libpod: add volume rename support 2026-06-11 21:56:15 +01:00
35-networks.at fix: include IPRange in Docker-compat network IPAM config 2026-09-16 10:01:35 +05:30
36-quadlets.at test/quadlet: pass Containerfile as part of a named application 2026-06-26 12:29:37 +05:30
37-autoupdate.at auto-update: Add container filters 2026-09-17 11:16:58 -04:00
40-pods.at test/apiv2: remove cgroupv2 check 2026-09-10 12:37:52 +02:00
44-mounts.at Compat v1.46: Support HostConfig.Mounts.TmpfsOptions for containers/create 2026-08-14 21:14:49 -04:00
45-system.at compat: Add status for runtimes to GET /info 2026-09-04 11:37:47 +02:00
47-subnet-pools.at compat: Add DefaultAddressPools field to GET /info 2025-05-16 13:16:27 +02:00
50-secrets.at compat/secrets: do not expose secret data on inspect endpoint 2026-08-19 14:30:37 +03:30
60-auth.at test/apiv2/60-auth.at: use doesnotexists.podman.io 2023-08-24 16:22:02 +02:00
70-short-names.at compat API push: fix error handling 2023-06-21 16:35:55 +02:00
80-kube.at fix: set correct content-type for generate kube 2026-09-05 23:21:50 +00:00
90-build.at Add local build API for direct filesystem builds on MacOS and Windows (only WSL) 2025-10-09 15:14:48 +02:00
containers.conf compat API: allow enforcing short-names resolution to Docker Hub 2021-11-30 14:22:52 +01:00
containers.host-netns.conf [docker compat] Don't overwrite the NetworkMode if containers.conf overrides netns. 2023-01-11 17:44:09 +00:00
containers.no_hosts.conf API: use no_hosts from containers.conf 2022-04-11 18:41:19 +02:00
README.md APIv2 test cleanup, part 2 of 2 2022-08-25 11:07:11 -06:00
storage.partial-pull.conf test: Add API test for partial pull with pullProgress flag 2026-07-01 14:55:55 +02:00
test-apiv2 Merge pull request #29758 from haneul-24/fix/api-endpoint-content-type 2026-09-15 11:09:46 +02:00

API v2 tests

This directory contains tests for the podman version 2 API (HTTP).

Tests themselves are in files of the form 'NN-NAME.at' where NN is a two-digit number, NAME is a descriptive name, and '.at' is just an extension I picked.

Running Tests

The main test runner is test-apiv2. Usage is:

$ sudo ./test-apiv2 [NAME [...]]

...where NAME is one or more optional test names, e.g. 'image' or 'pod' or both. By default, test-apiv2 will invoke all *.at tests.

test-apiv2 connects to localhost only and via TCP. There is no support here for remote hosts or for UNIX sockets. This is a framework for testing the API, not all possible protocols.

test-apiv2 will start the service if it isn't already running.

Writing Tests

The main test function is t. It runs curl against the server, with POST parameters if present, and compares return status and (optionally) string results from the server:

t GET /_ping 200 OK
  ^^^ ^^^^^^ ^^^ ^^
  |   |      |   +--- expected string result
  |   |      +------- expected return code
  |   +-------------- endpoint to access
  +------------------ method (GET, POST, DELETE, HEAD)


t POST libpod/volumes/create name=foo 201 .ID~[0-9a-f]\\{12\\}
       ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^ ^^^^^^^^^^^^^^^^^^^^
       |                     |        |   JSON '.ID': expect 12-char hex
       |                     |        +-- expected code
       |                     +----------- POST params
       +--------------------------------- note the missing slash

Never, ever, ever, seriously EVER exit from a test. Just don't. That skips cleanup, and leaves the system in a broken state.

Notes:

  • If the endpoint has a leading slash (/_ping), t leaves it unchanged. If there's no leading slash, t prepends /v1.40. This is a simple convenience for simplicity of writing tests.

  • When method is POST, the argument(s) after the endpoint may be a series of POST parameters in the form 'key=value', separated by spaces: t POST myentrypoint 200 ! no params t POST myentrypoint id=$id 200 ! just one t POST myentrypoint id=$id filter='{"foo":"bar"}' 200 ! two, with json t POST myentrypoint name=$name badparam='["foo","bar"]' 500 ! etc... t will convert the param list to JSON form for passing to the server. A numeric status code terminates processing of POST parameters. ** As a special case, when one POST argument is a string ending in .tar, .yaml, or .json, t will invoke curl with --data-binary @PATH and set Content-type as appropriate. This is useful for build endpoints. (To override Content-type, simply pass along an extra string argument matching application/*): t POST myentrypoint /mytmpdir/myfile.tar application/foo 400 ** Like above, when using PUT, t does --upload-time instead of --data-binary

  • The final arguments are one or more expected string results. If an argument starts with a dot, t will invoke jq on the output to fetch that field, and will compare it to the right-hand side of the argument. If the separator is = (equals), t will require an exact match; if ~ (tilde), t will use expr to compare.

  • If your test expects curl to time out: APIV2_TEST_EXPECT_TIMEOUT=5 t POST /foo 999