summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-09-03 16:06:06 +0200
committerAlexander Larsson <alexl@redhat.com>2019-09-03 16:06:06 +0200
commit24e5f368d8a6926c4778afc8b215633837d7774e (patch)
tree8a3024d298c5da9e2db266377bcbe13c5df5470f
parent017216633128c5fd58bfad64dd2a05be6d0b66d5 (diff)
downloadflatpak-wip/oci-labels.tar.gz
tests: Add tests for oci registries using labels instead of annotationswip/oci-labels
-rw-r--r--tests/Makefile-test-matrix.am.inc6
-rw-r--r--tests/Makefile.am.inc2
-rw-r--r--tests/oci-registry-server.py11
-rwxr-xr-xtests/test-oci-registry.sh29
-rwxr-xr-xtests/test-wrapper.sh6
5 files changed, 38 insertions, 16 deletions
diff --git a/tests/Makefile-test-matrix.am.inc b/tests/Makefile-test-matrix.am.inc
index 5ffed7d7..e6d68970 100644
--- a/tests/Makefile-test-matrix.am.inc
+++ b/tests/Makefile-test-matrix.am.inc
@@ -16,8 +16,10 @@ TEST_MATRIX= \
tests/test-bundle@user.wrap \
tests/test-bundle@system.wrap \
tests/test-bundle@system-norevokefs.wrap \
- tests/test-oci-registry@user.wrap \
- tests/test-oci-registry@system.wrap \
+ tests/test-oci-registry@user,annotations.wrap \
+ tests/test-oci-registry@user,labels.wrap \
+ tests/test-oci-registry@system,annotations.wrap \
+ tests/test-oci-registry@system,labels.wrap \
tests/test-p2p-security@user,collections.wrap \
tests/test-p2p-security@system,collections.wrap \
$(NULL)
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index 9039c1ed..d2b25ac7 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -138,7 +138,7 @@ TEST_MATRIX_SOURCE = \
tests/test-extensions.sh \
tests/test-bundle.sh{user+system+system-norevokefs} \
tests/test-oci.sh \
- tests/test-oci-registry.sh{user+system} \
+ tests/test-oci-registry.sh{{user+system},{annotations+labels}} \
tests/test-unsigned-summaries.sh \
tests/test-update-remote-configuration.sh \
tests/test-override.sh \
diff --git a/tests/oci-registry-server.py b/tests/oci-registry-server.py
index f123edc7..b8b33cab 100644
--- a/tests/oci-registry-server.py
+++ b/tests/oci-registry-server.py
@@ -179,10 +179,15 @@ class RequestHandler(http_server.BaseHTTPRequestHandler):
if detach_icons:
for size in (64, 128):
annotation = 'org.freedesktop.appstream.icon-{}'.format(size)
- icon = manifest['annotations'].get(annotation)
+ icon = manifest.get('annotations', {}).get(annotation)
if icon:
path = cache_icon(icon)
manifest['annotations'][annotation] = path
+ else:
+ icon = config.get('config', {}).get('Labels', {}).get(annotation)
+ if icon:
+ path = cache_icon(icon)
+ config['config']['Labels'][annotation] = path
image = {
"Tags": [tag],
@@ -190,8 +195,8 @@ class RequestHandler(http_server.BaseHTTPRequestHandler):
"MediaType": "application/vnd.oci.image.manifest.v1+json",
"OS": config['os'],
"Architecture": config['architecture'],
- "Annotations": manifest['annotations'],
- "Labels": {},
+ "Annotations": manifest.get('annotations', {}),
+ "Labels": config.get('config', {}).get('Labels', {}),
}
# Delete old versions
diff --git a/tests/test-oci-registry.sh b/tests/test-oci-registry.sh
index 87021d94..ee345c61 100755
--- a/tests/test-oci-registry.sh
+++ b/tests/test-oci-registry.sh
@@ -25,6 +25,14 @@ skip_without_bwrap
echo "1..14"
+if [ x${USE_OCI_LABELS-} == xyes ] ; then
+ URI_SUFFIX="?index=labels"
+ BUILD_BUNDLE_FLAGS="--oci-use-labels"
+else
+ URI_SUFFIX=""
+ BUILD_BUNDLE_FLAGS=""
+fi
+
# Start the fake registry server
$(dirname $0)/test-webserver.sh "" "python $test_srcdir/oci-registry-server.py 0"
@@ -37,15 +45,15 @@ setup_repo_no_add oci
# Add OCI bundles to it
-${FLATPAK} build-bundle --runtime --oci $FL_GPGARGS repos/oci oci/platform-image org.test.Platform
+${FLATPAK} build-bundle ${BUILD_BUNDLE_FLAGS} --runtime --oci $FL_GPGARGS repos/oci oci/platform-image org.test.Platform
$client add platform latest $(pwd)/oci/platform-image
-${FLATPAK} build-bundle --oci $FL_GPGARGS repos/oci oci/app-image org.test.Hello
+${FLATPAK} build-bundle ${BUILD_BUNDLE_FLAGS} --oci $FL_GPGARGS repos/oci oci/app-image org.test.Hello
$client add hello latest $(pwd)/oci/app-image
# Add an OCI remote
-${FLATPAK} remote-add ${U} oci-registry "oci+http://127.0.0.1:${port}"
+${FLATPAK} remote-add ${U} oci-registry "oci+http://127.0.0.1:${port}${URI_SUFFIX}"
# Check that the images we expect are listed
@@ -103,7 +111,8 @@ echo "ok install"
make_updated_app oci
-${FLATPAK} build-bundle --oci $FL_GPGARGS repos/oci oci/app-image org.test.Hello
+${FLATPAK} build-bundle ${BUILD_BUNDLE_FLAGS} --oci $FL_GPGARGS repos/oci oci/app-image org.test.Hello
+
$client add hello latest $(pwd)/oci/app-image
OLD_COMMIT=`${FLATPAK} ${U} info --show-commit org.test.Hello`
@@ -154,7 +163,7 @@ echo "ok change remote to non-OCI"
# Change it back and refetch
-${FLATPAK} remote-modify ${U} --url=oci+http://127.0.0.1:${port} oci-registry
+${FLATPAK} remote-modify ${U} --url=oci+http://127.0.0.1:${port}${URI_SUFFIX} oci-registry
${FLATPAK} update ${U} --appstream oci-registry
# Delete the remote, check that everything was removed
@@ -178,7 +187,7 @@ cat << EOF > org.test.Platform.flatpakref
Title=Test Platform
Name=org.test.Platform
Branch=master
-Url=oci+http://127.0.0.1:${port}
+Url=oci+http://127.0.0.1:${port}${URI_SUFFIX}
IsRuntime=true
EOF
@@ -205,12 +214,12 @@ echo "ok prune origin remote"
# Install from a (non-OCI) bundle, check that the repo-url is respected
-${FLATPAK} build-bundle --runtime --repo-url "oci+http://127.0.0.1:${port}" $FL_GPGARGS repos/oci org.test.Platform.flatpak org.test.Platform
+${FLATPAK} build-bundle --runtime --repo-url "oci+http://127.0.0.1:${port}${URI_SUFFIX}" $FL_GPGARGS repos/oci org.test.Platform.flatpak org.test.Platform
${FLATPAK} ${U} install -y --bundle org.test.Platform.flatpak
${FLATPAK} remotes -d > remotes-list
-assert_file_has_content remotes-list "^platform-origin.*[ ]oci+http://127\.0\.0\.1:${port}"
+assert_file_has_content remotes-list "^platform-origin.*[ ]oci+http://127\.0\.0\.1:${port}${URI_SUFFIX}"
assert_has_file $base/oci/platform-origin.index.gz
@@ -218,12 +227,12 @@ echo "ok install via bundle"
# Install an app from a bundle
-${FLATPAK} build-bundle --repo-url "oci+http://127.0.0.1:${port}" $FL_GPGARGS repos/oci org.test.Hello.flatpak org.test.Hello
+${FLATPAK} build-bundle --repo-url "oci+http://127.0.0.1:${port}${URI_SUFFIX}" $FL_GPGARGS repos/oci org.test.Hello.flatpak org.test.Hello
${FLATPAK} ${U} install -y --bundle org.test.Hello.flatpak
${FLATPAK} remotes -d > remotes-list
-assert_file_has_content remotes-list "^hello-origin.*[ ]oci+http://127\.0\.0\.1:${port}"
+assert_file_has_content remotes-list "^hello-origin.*[ ]oci+http://127\.0\.0\.1:${port}${URI_SUFFIX}"
assert_has_file $base/oci/hello-origin.index.gz
diff --git a/tests/test-wrapper.sh b/tests/test-wrapper.sh
index 3dd79f45..04770465 100755
--- a/tests/test-wrapper.sh
+++ b/tests/test-wrapper.sh
@@ -26,6 +26,12 @@ for feature in $(echo $1 | sed "s/^.*@\(.*\).wrap/\1/" | tr "," "\n"); do
export USE_COLLECTIONS_IN_SERVER=yes
export USE_COLLECTIONS_IN_CLIENT=no
;;
+ labels)
+ export USE_OCI_LABELS=yes
+ ;;
+ annotations)
+ export USE_OCI_ANNOTATIONS=yes
+ ;;
*)
echo unsupported test feature $feature
exit 1