171c7e5238
We were occasionally trying to compute schema 2 version 1 signatures on the *unicode* representation, which was failing the signature check. This PR adds a new wrapper type called `Bytes`, which all manifests must take in, and which handles the unicodes vs encoded utf-8 stuff in a central location. This PR also adds a test for the manifest that was breaking in production.
20 lines
1,006 B
Python
20 lines
1,006 B
Python
import pytest
|
|
|
|
from image.docker.schemas import parse_manifest_from_bytes
|
|
from image.docker.schema1 import DOCKER_SCHEMA1_SIGNED_MANIFEST_CONTENT_TYPE
|
|
from image.docker.schema2 import DOCKER_SCHEMA2_MANIFEST_CONTENT_TYPE
|
|
from image.docker.schema2 import DOCKER_SCHEMA2_MANIFESTLIST_CONTENT_TYPE
|
|
from image.docker.test.test_schema1 import MANIFEST_BYTES as SCHEMA1_BYTES
|
|
from image.docker.schema2.test.test_list import MANIFESTLIST_BYTES
|
|
from image.docker.schema2.test.test_manifest import MANIFEST_BYTES as SCHEMA2_BYTES
|
|
from util.bytes import Bytes
|
|
|
|
|
|
@pytest.mark.parametrize('media_type, manifest_bytes', [
|
|
(DOCKER_SCHEMA1_SIGNED_MANIFEST_CONTENT_TYPE, SCHEMA1_BYTES),
|
|
(DOCKER_SCHEMA2_MANIFEST_CONTENT_TYPE, SCHEMA2_BYTES),
|
|
(DOCKER_SCHEMA2_MANIFESTLIST_CONTENT_TYPE, MANIFESTLIST_BYTES),
|
|
])
|
|
def test_parse_manifest_from_bytes(media_type, manifest_bytes):
|
|
assert parse_manifest_from_bytes(Bytes.for_string_or_unicode(manifest_bytes), media_type,
|
|
validate=False)
|