Fix registry tests to not terminate prematurely when looking for errors
Also reorders a check in the V1 protocol to have better error messaging for the users
This commit is contained in:
parent
1f04b3ea03
commit
701eac5466
4 changed files with 42 additions and 20 deletions
|
@ -13,6 +13,7 @@ class V1ProtocolSteps(Enum):
|
|||
PUT_IMAGES = 'put-images'
|
||||
GET_IMAGES = 'get-images'
|
||||
PUT_TAG = 'put-tag'
|
||||
PUT_IMAGE_JSON = 'put-image-json'
|
||||
|
||||
|
||||
class V1Protocol(RegistryProtocol):
|
||||
|
@ -34,6 +35,9 @@ class V1Protocol(RegistryProtocol):
|
|||
Failures.DISALLOWED_LIBRARY_NAMESPACE: 400,
|
||||
Failures.NAMESPACE_DISABLED: 400,
|
||||
},
|
||||
V1ProtocolSteps.PUT_IMAGE_JSON: {
|
||||
Failures.INVALID_IMAGES: 400,
|
||||
},
|
||||
V1ProtocolSteps.PUT_TAG: {
|
||||
Failures.MISSING_TAG: 404,
|
||||
Failures.INVALID_TAG: 400,
|
||||
|
@ -77,7 +81,7 @@ class V1Protocol(RegistryProtocol):
|
|||
headers = {'X-Docker-Token': 'true'}
|
||||
result = self.conduct(session, 'GET', prefix + 'images', auth=auth, headers=headers,
|
||||
expected_status=(200, expected_failure, V1ProtocolSteps.GET_IMAGES))
|
||||
if expected_failure is not None:
|
||||
if result.status_code != 200:
|
||||
return
|
||||
|
||||
headers = {}
|
||||
|
@ -91,6 +95,10 @@ class V1Protocol(RegistryProtocol):
|
|||
assert len(image_ids.values()) == len(tag_names)
|
||||
|
||||
for tag_name in tag_names:
|
||||
if tag_name not in image_ids:
|
||||
assert expected_failure == Failures.UNKNOWN_TAG
|
||||
return None
|
||||
|
||||
tag_image_id = image_ids[tag_name]
|
||||
if not options.munge_shas:
|
||||
# Ensure we have a matching image ID.
|
||||
|
@ -133,8 +141,7 @@ class V1Protocol(RegistryProtocol):
|
|||
expected_status=(201, expected_failure, V1ProtocolSteps.PUT_IMAGES),
|
||||
json_data={},
|
||||
auth=auth)
|
||||
|
||||
if expected_failure is not None:
|
||||
if result.status_code != 201:
|
||||
return
|
||||
|
||||
headers = {}
|
||||
|
@ -152,8 +159,12 @@ class V1Protocol(RegistryProtocol):
|
|||
if image.config is not None:
|
||||
image_json_data['config'] = image.config
|
||||
|
||||
self.conduct(session, 'PUT', '/v1/images/%s/json' % image.id,
|
||||
json_data=image_json_data, headers=headers)
|
||||
response = self.conduct(session, 'PUT', '/v1/images/%s/json' % image.id,
|
||||
json_data=image_json_data, headers=headers,
|
||||
expected_status=(200, expected_failure,
|
||||
V1ProtocolSteps.PUT_IMAGE_JSON))
|
||||
if response.status_code != 200:
|
||||
break
|
||||
|
||||
# PUT /v1/images/{imageID}/layer
|
||||
self.conduct(session, 'PUT', '/v1/images/%s/layer' % image.id,
|
||||
|
|
Reference in a new issue