def test_set_properties(self, containerregistry_endpoint):
        repository = self.get_resource_name("repo")
        tag_identifier = self.get_resource_name("tag")
        self.import_image(HELLO_WORLD,
                          ["{}:{}".format(repository, tag_identifier)])
        repo_client = self.create_container_repository(
            containerregistry_endpoint, repository)

        properties = repo_client.get_properties()
        assert isinstance(properties.writeable_properties, ContentProperties)

        c = ContentProperties(can_delete=False,
                              can_read=False,
                              can_list=False,
                              can_write=False)
        properties.writeable_properties = c
        new_properties = repo_client.set_properties(c)

        assert c.can_delete == new_properties.writeable_properties.can_delete
        assert c.can_read == new_properties.writeable_properties.can_read
        assert c.can_list == new_properties.writeable_properties.can_list
        assert c.can_write == new_properties.writeable_properties.can_write

        c = ContentProperties(can_delete=True,
                              can_read=True,
                              can_list=True,
                              can_write=True)
        properties.writeable_properties = c
        new_properties = repo_client.set_properties(c)

        assert c.can_delete == new_properties.writeable_properties.can_delete
        assert c.can_read == new_properties.writeable_properties.can_read
        assert c.can_list == new_properties.writeable_properties.can_list
        assert c.can_write == new_properties.writeable_properties.can_write
예제 #2
0
    def test_set_manifest_properties(self, containerregistry_endpoint):
        repo = self.get_resource_name("repo")
        tag = self.get_resource_name("tag")
        self.import_image(HELLO_WORLD, ["{}:{}".format(repo, tag)])

        reg_artifact = self.set_up(containerregistry_endpoint, name=repo)

        properties = reg_artifact.get_manifest_properties()
        c = ContentProperties(can_delete=False,
                              can_read=False,
                              can_write=False,
                              can_list=False)

        received = reg_artifact.set_manifest_properties(c)

        assert received.writeable_properties.can_delete == c.can_delete
        assert received.writeable_properties.can_read == c.can_read
        assert received.writeable_properties.can_write == c.can_write
        assert received.writeable_properties.can_list == c.can_list

        c = ContentProperties(can_delete=True,
                              can_read=True,
                              can_write=True,
                              can_list=True)
        received = reg_artifact.set_manifest_properties(c)

        assert received.writeable_properties.can_delete == c.can_delete
        assert received.writeable_properties.can_read == c.can_read
        assert received.writeable_properties.can_write == c.can_write
        assert received.writeable_properties.can_list == c.can_list
예제 #3
0
    def test_set_tag_properties(self, containerregistry_endpoint, containerregistry_resource_group):
        repository = self.get_resource_name("repo")
        tag_identifier = self.get_resource_name("tag")
        self.import_image(HELLO_WORLD, ["{}:{}".format(repository, tag_identifier)])

        client = self.create_repository_client(containerregistry_endpoint, repository)

        tag_props = client.get_tag_properties(tag_identifier)
        permissions = tag_props.writeable_properties

        received = client.set_tag_properties(
            tag_identifier,
            ContentProperties(
                can_delete=False,
                can_list=False,
                can_read=False,
                can_write=False,
            ),
        )

        assert not received.writeable_properties.can_write
        assert not received.writeable_properties.can_read
        assert not received.writeable_properties.can_list
        assert not received.writeable_properties.can_delete

        client.set_tag_properties(
            tag_identifier,
            ContentProperties(
                can_delete=True,
                can_list=True,
                can_read=True,
                can_write=True,
            ),
        )
    async def test_set_manifest_properties_does_not_exist(
            self, containerregistry_endpoint):
        client = self.create_repository_client(containerregistry_endpoint,
                                               self.get_resource_name("repo"))

        with pytest.raises(ResourceNotFoundError):
            await client.set_manifest_properties(
                "sha256:abcdef", ContentProperties(can_delete=False))
    def test_set_tag_properties_does_not_exist(self,
                                               containerregistry_endpoint):
        client = self.create_repository_client(containerregistry_endpoint,
                                               self.get_resource_name("repo"))

        with pytest.raises(ResourceNotFoundError):
            client.set_tag_properties(DOES_NOT_EXIST,
                                      ContentProperties(can_delete=False))
    async def test_set_manifest_properties(self, containerregistry_endpoint,
                                           containerregistry_resource_group):
        repository = self.get_resource_name("reposet")
        tag_identifier = self.get_resource_name("tag")
        self.import_image(HELLO_WORLD,
                          ["{}:{}".format(repository, tag_identifier)])

        client = self.create_repository_client(containerregistry_endpoint,
                                               repository)

        async for artifact in client.list_registry_artifacts():
            permissions = artifact.writeable_properties

            received_permissions = await client.set_manifest_properties(
                artifact.digest,
                ContentProperties(
                    can_delete=False,
                    can_list=False,
                    can_read=False,
                    can_write=False,
                ),
            )
            assert not received_permissions.writeable_properties.can_delete
            assert not received_permissions.writeable_properties.can_read
            assert not received_permissions.writeable_properties.can_list
            assert not received_permissions.writeable_properties.can_write

            # Reset and delete
            await client.set_manifest_properties(
                artifact.digest,
                ContentProperties(
                    can_delete=True,
                    can_list=True,
                    can_read=True,
                    can_write=True,
                ),
            )
            await client.delete()

            break