mirror of
https://github.com/flatpak/flatpak.git
synced 2026-04-16 13:00:48 -04:00
tests: Add tests for oci registries using labels instead of annotations
Closes: #2978 Approved by: alexlarsson
This commit is contained in:
committed by
Atomic Bot
parent
52e20d4a59
commit
9ec61ae328
@@ -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)
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user