コード例 #1
0
 def test_compute_layers(self):
     """Test that computing the layers produces the expected data"""
     cnv = schema_convert.Schema2toSchema1Converter(MANIFEST, CONFIG_LAYER,
                                                    'test-repo', 'tes-tag')
     cnv.compute_layers()
     empty = dict(blobSum=cnv.EMPTY_LAYER)
     assert [
         dict(blobSum="sha256:layer1"), empty, empty, empty,
         dict(blobSum="sha256:base")
     ] == cnv.fs_layers
     assert [
         {
             'v1Compatibility':
             '{"architecture":"amd64","author":"Mihai Ibanescu <*****@*****.**>","config":{"Cmd":["/bin/bash"],"Hostname":"decafbad"},"container_config":{"Hostname":"decafbad","Tty":false},"created":"2019-09-05T21:28:52.173079282Z","docker_version":"1.13.1","id":"d7b329ed9d186ff20c25399e848116430ee9b6ae022cb9f3dc3406144ec3685d","parent":"6474547c15d178825c70a42efdc59a88c6e30d764d184b415f32484562803446"}'
         },  # noqa
         {
             'v1Compatibility':
             '{"container_config":{"Cmd":"/bin/sh -c #(nop)  MAINTAINER Mihai Ibanescu <*****@*****.**>"},"created":"2019-09-05T21:28:43.305854958Z","id":"6474547c15d178825c70a42efdc59a88c6e30d764d184b415f32484562803446","parent":"5708420291e0a86d8dc08ec40b2c1b1799117c33fe85032b87227632f70c1018","throwaway":true}'
         },  # noqa
         {
             'v1Compatibility':
             '{"container_config":{"Cmd":"/bin/sh -c #(nop)  CMD [\\"/bin/bash\\"]"},"created":"2018-03-06T00:48:12.679169547Z","id":"5708420291e0a86d8dc08ec40b2c1b1799117c33fe85032b87227632f70c1018","parent":"9e9220abceaf86f2ad7820ae8124d01223d8ec022b9a6cb8c99a8ae1747137ea","throwaway":true}'
         },  # noqa
         {
             'v1Compatibility':
             '{"container_config":{"Cmd":"/bin/sh -c #(nop)  LABEL name=CentOS Base Image vendor=CentOS license=GPLv2 build-date=20180302"},"created":"2018-03-06T00:48:12.458578213Z","id":"9e9220abceaf86f2ad7820ae8124d01223d8ec022b9a6cb8c99a8ae1747137ea","parent":"cb48c1db9c0a1ede7c85c85351856fc3e40e750931295c8fac837c63b403586a","throwaway":true}'
         },  # noqa
         {
             'v1Compatibility':
             '{"container_config":{"Cmd":"/bin/sh -c #(nop) ADD file:FILE_CHECKSUM in / "},"created":"2018-03-06T00:48:12.077095981Z","id":"cb48c1db9c0a1ede7c85c85351856fc3e40e750931295c8fac837c63b403586a"}'
         },  # noqa
     ] == cnv.history
コード例 #2
0
 def test_manifest_with_foreign_layers_conversion(self):
     """Test if the conversion of a manifest with foreign layers fails gracefully"""
     try:
         schema_convert.Schema2toSchema1Converter(
             MANIFEST_WITH_FOREIGN_LAYERS, CONFIG_LAYER, 'test-repo',
             'tes-tag')
     except ValueError:
         pass
     else:
         assert False
コード例 #3
0
    def test_convert(self):
        """Test schema converter on a known manifest"""
        cnv = schema_convert.Schema2toSchema1Converter(MANIFEST, CONFIG_LAYER,
                                                       'test-repo', 'tes-tag')
        signed_mf = cnv.convert()
        validate_signature(signed_mf)

        empty = dict(blobSum=cnv.EMPTY_LAYER)
        assert [
            dict(blobSum="sha256:layer1"), empty, empty, empty,
            dict(blobSum="sha256:base")
        ] == cnv.fs_layers
コード例 #4
0
 def test_compute_layers(self):
     """Test that computing the layers produces the expected data"""
     cnv = schema_convert.Schema2toSchema1Converter(MANIFEST, CONFIG_LAYER,
                                                    "test-repo", "tes-tag")
     cnv.compute_layers()
     empty = dict(blobSum=cnv.EMPTY_LAYER)
     assert [
         dict(blobSum="sha256:layer1"),
         empty,
         empty,
         empty,
         empty,
         dict(blobSum="sha256:base"),
     ] == cnv.fs_layers
     assert [
         {
             "v1Compatibility":
             '{"architecture":"amd64","author":"Mihai Ibanescu <*****@*****.**>","config":{"Cmd":["/bin/bash"],"Hostname":"decafbad"},"container_config":{"Hostname":"decafbad","Tty":false},"created":"2019-09-05T21:28:52.173079282Z","docker_version":"1.13.1","id":"8e1cc996a0d319582f770dbded72777c5b8c5c46859c506db5acc674bc42ee51","parent":"3d0d31cc2270f872e56b7b7e35fb4fb7796797a8979ae180a2baee7107a5eb5b"}'  # noqa
         },
         {
             "v1Compatibility":
             '{"container_config":{"Cmd":[""]},"created":"2019-09-05T21:28:46.173079282Z","id":"3d0d31cc2270f872e56b7b7e35fb4fb7796797a8979ae180a2baee7107a5eb5b","parent":"6474547c15d178825c70a42efdc59a88c6e30d764d184b415f32484562803446","throwaway":true}'  # noqa
         },
         {
             "v1Compatibility":
             '{"container_config":{"Cmd":["/bin/sh -c #(nop)  MAINTAINER Mihai Ibanescu <*****@*****.**>"]},"created":"2019-09-05T21:28:43.305854958Z","id":"6474547c15d178825c70a42efdc59a88c6e30d764d184b415f32484562803446","parent":"5708420291e0a86d8dc08ec40b2c1b1799117c33fe85032b87227632f70c1018","throwaway":true}'  # noqa
         },
         {
             "v1Compatibility":
             '{"container_config":{"Cmd":["/bin/sh -c #(nop)  CMD [\\"/bin/bash\\"]"]},"created":"2018-03-06T00:48:12.679169547Z","id":"5708420291e0a86d8dc08ec40b2c1b1799117c33fe85032b87227632f70c1018","parent":"9e9220abceaf86f2ad7820ae8124d01223d8ec022b9a6cb8c99a8ae1747137ea","throwaway":true}'  # noqa
         },
         {
             "v1Compatibility":
             '{"container_config":{"Cmd":["/bin/sh -c #(nop)  LABEL name=CentOS Base Image vendor=CentOS license=GPLv2 build-date=20180302"]},"created":"2018-03-06T00:48:12.458578213Z","id":"9e9220abceaf86f2ad7820ae8124d01223d8ec022b9a6cb8c99a8ae1747137ea","parent":"cb48c1db9c0a1ede7c85c85351856fc3e40e750931295c8fac837c63b403586a","throwaway":true}'  # noqa
         },
         {
             "v1Compatibility":
             '{"container_config":{"Cmd":["/bin/sh -c #(nop) ADD file:FILE_CHECKSUM in / "]},"created":"2018-03-06T00:48:12.077095981Z","id":"cb48c1db9c0a1ede7c85c85351856fc3e40e750931295c8fac837c63b403586a"}'  # noqa
         },
     ] == cnv.history