Update registry tests

This commit is contained in:
Joseph Schorr 2018-11-19 14:01:29 +02:00
parent e6c2ddfa93
commit 45db1d27e7
3 changed files with 47 additions and 12 deletions

View file

@ -1390,17 +1390,14 @@ def test_push_pull_manifest_list_back_compat(v22_protocol, legacy_puller, basic_
second_manifest = v22_protocol.build_schema2(different_images, blobs, options)
# Add the manifests themselves to the blobs map.
blobs[str(first_manifest.digest)] = first_manifest.bytes
blobs[str(second_manifest.digest)] = second_manifest.bytes
# Create and push the manifest list.
builder = DockerSchema2ManifestListBuilder()
builder.add_manifest(first_manifest, 'amd64' if is_amd else 'something', 'linux')
builder.add_manifest(second_manifest, 'arm', 'linux')
manifestlist = builder.build()
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist, blobs,
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
[first_manifest, second_manifest], blobs,
credentials=credentials, options=options)
# Pull the tag and ensure we (don't) get back the basic images, since they are(n't) part of the
@ -1435,17 +1432,14 @@ def test_push_pull_manifest_list(v22_protocol, basic_images, different_images, l
second_manifest = v22_protocol.build_schema2(different_images, blobs, options)
# Add the manifests themselves to the blobs map.
blobs[str(first_manifest.digest)] = first_manifest.bytes
blobs[str(second_manifest.digest)] = second_manifest.bytes
# Create and push the manifest list.
builder = DockerSchema2ManifestListBuilder()
builder.add_manifest(first_manifest, 'amd64', 'linux')
builder.add_manifest(second_manifest, 'arm', 'linux')
manifestlist = builder.build()
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist, blobs,
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
[first_manifest, second_manifest], blobs,
credentials=credentials, options=options)
# Pull and verify the manifest list.
@ -1474,3 +1468,28 @@ def test_push_pull_manifest_remote_layers(v22_protocol, legacy_puller, liveserve
# Ensure that the image cannot be pulled by a legacy protocol.
legacy_puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', remote_images,
credentials=credentials, expected_failure=Failures.UNKNOWN_TAG)
def test_push_pull_manifest_list_missing_manifest(v22_protocol, basic_images, liveserver_session,
app_reloader, data_model):
""" Test: Attempt to push a new tag with a manifest list containing an invalid manifest.
"""
if data_model != 'oci_model':
return
credentials = ('devtable', 'password')
options = ProtocolOptions()
# Build the manifests that will go in the list.
blobs = {}
manifest = v22_protocol.build_schema2(basic_images, blobs, options)
# Create and push the manifest list, but without the manifest itself.
builder = DockerSchema2ManifestListBuilder()
builder.add_manifest(manifest, 'amd64', 'linux')
manifestlist = builder.build()
v22_protocol.push_list(liveserver_session, 'devtable', 'newrepo', 'latest', manifestlist,
[], blobs,
credentials=credentials, options=options,
expected_failure=Failures.INVALID_MANIFEST)