Fix auth and add V2 tests!

This commit is contained in:
Joseph Schorr 2015-08-27 14:55:33 -04:00
parent afdd687192
commit 42dba8655c
5 changed files with 180 additions and 51 deletions

View file

@ -63,8 +63,10 @@ class SignedManifest(object):
def __init__(self, manifest_bytes):
self._bytes = manifest_bytes
self._parsed = yaml.safe_load(manifest_bytes)
# TODO(jakedt): If the manifest_bytes doesn't parse as valid YAML, safe_load returns the
# same string again. We should throw some sort of exception.
self._parsed = yaml.safe_load(manifest_bytes)
self._signatures = self._parsed[_SIGNATURES_KEY]
self._namespace, self._repo_name = self._parsed[_REPO_NAME_KEY].split('/')
self._tag = self._parsed[_REPO_TAG_KEY]
@ -107,8 +109,10 @@ class SignedManifest(object):
self._parsed[_HISTORY_KEY])):
image_digest = digest_tools.Digest.parse_digest(blob_sum_obj[_BLOB_SUM_KEY])
metadata_string = history_obj[_V1_COMPAT_KEY]
v1_metadata = yaml.safe_load(metadata_string)
# TODO(jakedt): If the metadata_string doesn't parse as valid YAML, safe_load returns the
# same string again. We should throw some sort of exception.
v1_metadata = yaml.safe_load(metadata_string)
command_list = v1_metadata.get('container_config', {}).get('Cmd', None)
command = json.dumps(command_list) if command_list else None