pulp_smash.tests.docker.cli.test_sync_publish

Location: Pulp SmashAPI Documentationpulp_smash.tests.docker.cli.test_sync_publish

Tests for syncing and publishing docker repositories.

pulp_smash.tests.docker.cli.test_sync_publish.IMAGE_MANIFEST_V2_SCHEMA_1 = {'description': 'Derived from: https://docs.docker.com/registry/spec/manifest-v2-1/', 'type': 'object', '$schema': 'http://json-schema.org/schema#', 'properties': {'name': {'type': 'string'}, 'history': {'items': {'type': 'object', 'properties': {'v1Compatibility': {'type': 'string'}}}, 'type': 'array'}, 'architecture': {'type': 'string'}, 'tag': {'type': 'string'}, 'fsLayers': {'items': {'type': 'object', 'properties': {'blobSum': {'type': 'string'}}}, 'type': 'array'}, 'schemaVersion': {'type': 'integer'}, 'signatures': {'items': {'type': 'object', 'properties': {'protected': {'type': 'string'}, 'header': {'type': 'object', 'properties': {'alg': {'type': 'string'}, 'jwk': {'type': 'object', 'properties': {'kty': {'type': 'string'}, 'y': {'type': 'string'}, 'x': {'type': 'string'}, 'kid': {'type': 'string'}, 'crv': {'type': 'string'}}}}}, 'signature': {'type': 'string'}}}, 'type': 'array'}}, 'title': 'Image Manifest Version 2, Schema 1'}

A schema for docker v2 image manifests, schema 1.

pulp_smash.tests.docker.cli.test_sync_publish.IMAGE_MANIFEST_V2_SCHEMA_2 = {'description': 'Derived from: https://docs.docker.com/registry/spec/manifest-v2-2/', 'type': 'object', '$schema': 'http://json-schema.org/schema#', 'properties': {'schemaVersion': {'type': 'integer'}, 'config': {'type': 'object', 'properties': {'size': {'type': 'integer'}, 'digest': {'type': 'string'}, 'mediaType': {'type': 'string'}}}, 'layers': {'items': {'type': 'object', 'properties': {'urls': {'items': {'type': 'string'}, 'type': 'array'}, 'size': {'type': 'integer'}, 'digest': {'type': 'string'}, 'mediaType': {'type': 'string'}}}, 'type': 'array'}, 'mediaType': {'type': 'string'}}, 'title': 'Image Manifest Version 2, Schema 2'}

A schema for docker v2 image manifests, schema 2.

class pulp_smash.tests.docker.cli.test_sync_publish.InvalidFeedTestCase(methodName='runTest')

Show Pulp behaves correctly when syncing a repo with an invalid feed.

test_all()

Create a docker repo with an invalid feed and sync it.

class pulp_smash.tests.docker.cli.test_sync_publish.RepoRegistryIdTestCase(methodName='runTest')

Show Pulp can publish repos with varying repo_registry_id values.

The repo_registry_id setting defines a repository’s name as seen by clients such as the Docker CLI. It’s traditionally a two-part name such as docker/busybox, but according to Pulp #2368, it can contain an arbitrary number of slashes. This test case verifies that the repo_registry_id can be set to values containing varying numbers of slashes.

create_sync_publish_repo(repo_registry_id)

Create, sync and publish a Docker repository.

Also, schedule the repository for deletion with addCleanup.

Parameters:repo_registry_id – Passed to pulp_smash.tests.docker.cli.utils.repo_create().
Returns:Nothing.
test_one_slash()

Give repo_registry_id one slash.

test_two_slashes()

Give repo_registry_id two slashes.

test_zero_slashes()

Give repo_registry_id zero slashes.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncNonNamespacedV2TestCase(methodName='runTest')

Create, sync and publish a non-namespaced repository.

test_all()

Create, sync and publish a non-namespaced repository.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishMixin

Tools for test cases that test repository syncing and publishing.

This class must be mixed in to a class that inherits from unittest.TestCase.

static adjust_url(url)

Return a URL that can be used for talking with Crane.

The URL returned is the same as url, except that the scheme is set to HTTP, and the port is set to (or replaced by) 5000.

Parameters:url – A string, such as https://pulp.example.com/foo.
Returns:A string, such as http://pulp.example.com:5000/foo.
static make_crane_client(cfg)

Make an API client for talking with Crane.

Create an API client for talking to Crane. The client returned by this method is similar to the following client:

>>> client = api.Client(cfg, api.json_handler)

However:

  • The client’s base URL is adjusted as described by adjust_url().
  • The client will send an accept:application/json header with each request.
Parameters:cfg (pulp_smash.config.PulpSmashConfig) – Information about a Pulp deployment.
Returns:An API client for talking with Crane.
Return type:pulp_smash.api.Client
verify_proc(proc)

Assert proc.stdout has correct contents.

Assert “Task Succeeded” is present and “Task Failed” is absent.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishV1TestCase(methodName='runTest')

Create, sync, publish and interact with a Docker v1 repository.

classmethod setUpClass()

Maybe skip this test case, and execute pulp-admin login.

classmethod tearDownClass()

Destroy resources created by this test case.

test_01_set_up()

Create, sync and publish a repository.

Specifically, do the following:

  1. Create, sync and publish a Docker repository. Set the repository’s feed to a v1 feed.
  2. Make Crane immediately re-read the metadata files published by Pulp. (Restart Apache.)
test_02_get_crane_repositories()

Issue an HTTP GET request to /crane/repositories.

Assert that the response is as described by Crane Admin.

class pulp_smash.tests.docker.cli.test_sync_publish.SyncPublishV2TestCase(methodName='runTest')

Create, sync, publish and interact with a Docker v2 repository.

classmethod setUpClass()

Maybe skip this test case, and execute pulp-admin login.

classmethod tearDownClass()

Destroy resources created by this test case.

test_01_set_up()

Create, sync and publish a repository.

Specifically, do the following:

  1. Create, sync and publish a Docker repository. Set the repository’s feed to a v2 feed.
  2. Make Crane immediately re-read the metadata files published by Pulp. (Restart Apache.)
test_02_get_crane_repositories()

Issue an HTTP GET request to /crane/repositories.

Assert that the response is as described by Crane Admin.

test_02_get_manifest_v1()

Issue an HTTP GET request to /v2/{repo_id}/manifests/latest.

Pass a header of accept:application/vnd.docker.distribution.manifest.v1+json. Assert that the response is as described by Image Manifest Version 2, Schema 1.

This test targets Pulp #2336.

test_02_get_manifest_v2()

Issue an HTTP GET request to /v2/{repo_id}/manifests/latest.

Pass a header of accept:application/vnd.docker.distribution.manifest.v2+json. Assert that the response is as described by Image Manifest Version 2, Schema 2.

This test targets Pulp #2336.

pulp_smash.tests.docker.cli.test_sync_publish.setUpModule()

Execute pulp-admin login.