summaryrefslogtreecommitdiff
path: root/test/apiv2/23-containersArchive.at
diff options
context:
space:
mode:
authorMatej Vasek <mvasek@redhat.com>2020-11-19 18:13:04 +0100
committerMatej Vasek <mvasek@redhat.com>2020-11-19 20:31:47 +0100
commit0dcdb3cc9bfbec56ad545031f3a3472823cd6e8b (patch)
tree4146be16c055af39245aef2a4533acb09b84d37a /test/apiv2/23-containersArchive.at
parentd5cabc33375340fd59591dbba7c4474901bacd32 (diff)
downloadpodman-0dcdb3cc9bfbec56ad545031f3a3472823cd6e8b.tar.gz
podman-0dcdb3cc9bfbec56ad545031f3a3472823cd6e8b.tar.bz2
podman-0dcdb3cc9bfbec56ad545031f3a3472823cd6e8b.zip
few more tests
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Diffstat (limited to 'test/apiv2/23-containersArchive.at')
-rw-r--r--test/apiv2/23-containersArchive.at45
1 files changed, 43 insertions, 2 deletions
diff --git a/test/apiv2/23-containersArchive.at b/test/apiv2/23-containersArchive.at
index fcbc4373c..ee3e6e104 100644
--- a/test/apiv2/23-containersArchive.at
+++ b/test/apiv2/23-containersArchive.at
@@ -12,7 +12,7 @@ CTR="ArchiveTestingCtr"
TMPD=$(mktemp -d)
pushd "${TMPD}"
-echo "Hello!" > "hello.txt" &> /dev/null
+echo "Hello" > "hello.txt"
tar --format=posix -cvf "hello.tar" "hello.txt" &> /dev/null
popd
@@ -24,5 +24,46 @@ t HEAD "containers/nonExistentCtr/archive?path=%2F" 404
t HEAD "containers/${CTR}/archive?path=%2Fnon%2Fexistent%2Fpath" 404
t HEAD "containers/${CTR}/archive?path=%2Fetc%2Fpasswd" 200
-curl "http://127.0.0.1:$PORT/containers/${CTR}/archive?path=%2Ftmp" -X PUT --upload-file "${HELLO_TAR}"
+curl "http://$HOST:$PORT/containers/${CTR}/archive?path=%2Ftmp%2F" \
+ -X PUT \
+ -H "Content-Type: application/x-tar" \
+ --upload-file "${HELLO_TAR}" &> /dev/null
+
+
t HEAD "containers/${CTR}/archive?path=%2Ftmp%2Fhello.txt" 200
+
+curl "http://$HOST:$PORT/containers/${CTR}/archive?path=%2Ftmp%2Fhello.txt" \
+ --dump-header "${TMPD}/headers.txt" \
+ -o "${TMPD}/body.tar" \
+ -X GET &> /dev/null
+
+PATH_STAT="$(grep X-Docker-Container-Path-Stat "${TMPD}/headers.txt" | cut -d " " -f 2 | base64 -d --ignore-garbage)"
+
+ARCHIVE_TEST_ERROR=""
+
+red='\e[31m'
+nc='\e[0m'
+
+if [ "$(echo "${PATH_STAT}" | jq ".name")" != '"hello.txt"' ]; then
+ echo -e "${red}NOK: Wrong name in X-Docker-Container-Path-Stat header.${nc}" 1>&2;
+ ARCHIVE_TEST_ERROR="1"
+fi
+
+if [ "$(echo "${PATH_STAT}" | jq ".size")" != "6" ]; then
+ echo -e "${red}NOK: Wrong size in X-Docker-Container-Path-Stat header.${nc}" 1>&2;
+ ARCHIVE_TEST_ERROR="1"
+fi
+
+if ! tar -tf "${TMPD}/body.tar" | grep "hello.txt" &> /dev/null; then
+ echo -e "${red}NOK: Body doesn't contain expected file.${nc}" 1>&2;
+ ARCHIVE_TEST_ERROR="1"
+fi
+
+if [ "$(tar -xf "${TMPD}/body.tar" hello.txt --to-stdout)" != "Hello" ]; then
+ echo -e "${red}NOK: Content of file doesn't match.${nc}" 1>&2;
+ ARCHIVE_TEST_ERROR="1"
+fi
+
+if [[ "${ARCHIVE_TEST_ERROR}" ]] ; then
+ exit 1;
+fi