Merge pull request #1510 from coreos-inc/unsupported
Reject manifest 2 earlier to make pushes faster
This commit is contained in:
commit
c3588dadde
2 changed files with 21 additions and 2 deletions
|
@ -299,11 +299,11 @@ def _reject_manifest2_schema2(func):
|
|||
|
||||
|
||||
@v2_bp.route(MANIFEST_TAGNAME_ROUTE, methods=['PUT'])
|
||||
@_reject_manifest2_schema2
|
||||
@parse_repository_name()
|
||||
@process_registry_jwt_auth(scopes=['pull', 'push'])
|
||||
@require_repo_write
|
||||
@anon_protect
|
||||
@_reject_manifest2_schema2
|
||||
def write_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
|
||||
try:
|
||||
manifest = SignedManifest(request.data)
|
||||
|
@ -317,11 +317,11 @@ def write_manifest_by_tagname(namespace_name, repo_name, manifest_ref):
|
|||
|
||||
|
||||
@v2_bp.route(MANIFEST_DIGEST_ROUTE, methods=['PUT'])
|
||||
@_reject_manifest2_schema2
|
||||
@parse_repository_name()
|
||||
@process_registry_jwt_auth(scopes=['pull', 'push'])
|
||||
@require_repo_write
|
||||
@anon_protect
|
||||
@_reject_manifest2_schema2
|
||||
def write_manifest_by_digest(namespace_name, repo_name, manifest_ref):
|
||||
try:
|
||||
manifest = SignedManifest(request.data)
|
||||
|
|
|
@ -1090,6 +1090,25 @@ class V1RegistryTests(V1RegistryPullMixin, V1RegistryPushMixin, RegistryTestsMix
|
|||
class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMixin,
|
||||
RegistryTestCaseMixin, LiveServerTestCase):
|
||||
""" Tests for V2 registry. """
|
||||
def test_invalid_manifest_type(self):
|
||||
namespace = 'devtable'
|
||||
repository = 'somerepo'
|
||||
tag_name = 'sometag'
|
||||
|
||||
repo_name = _get_repo_name(namespace, repository)
|
||||
|
||||
self.v2_ping()
|
||||
self.do_auth('devtable', 'password', namespace, repository, scopes=['push', 'pull'])
|
||||
|
||||
# Build a fake manifest.
|
||||
builder = SignedManifestBuilder(namespace, repository, tag_name)
|
||||
builder.add_layer('sha256:' + hashlib.sha256('invalid').hexdigest(), json.dumps({'id': 'foo'}))
|
||||
manifest = builder.build(_JWK)
|
||||
|
||||
self.conduct('PUT', '/v2/%s/manifests/%s' % (repo_name, tag_name),
|
||||
data=manifest.bytes, expected_code=415,
|
||||
headers={'Content-Type': 'application/vnd.docker.distribution.manifest.v2+json'},
|
||||
auth='jwt')
|
||||
|
||||
def test_invalid_blob(self):
|
||||
namespace = 'devtable'
|
||||
|
|
Reference in a new issue