async def test_set_manifest_properties(self, containerregistry_baseurl, containerregistry_resource_group): repository = self.get_resource_name("repo_set_mani") tag_identifier = self.get_resource_name("tag") self.import_repo_to_be_deleted( containerregistry_baseurl, resource_group=containerregistry_resource_group, tag=tag_identifier, repository=repository, ) client = self.create_repository_client(containerregistry_baseurl, repository) async for artifact in client.list_registry_artifacts(): permissions = artifact.content_permissions received_permissions = await client.set_manifest_properties( artifact.digest, ContentPermissions( can_delete=False, can_list=False, can_read=False, can_write=False, ), ) assert not received_permissions.content_permissions.can_delete assert not received_permissions.content_permissions.can_read assert not received_permissions.content_permissions.can_list assert not received_permissions.content_permissions.can_write break
async def test_set_tag_properties(self, containerregistry_baseurl, containerregistry_resource_group): repository = self.get_resource_name("repo") tag_identifier = self.get_resource_name("tag") self.import_repo_to_be_deleted( containerregistry_baseurl, resource_group=containerregistry_resource_group, tag=tag_identifier, repository=repository, ) client = self.create_repository_client(containerregistry_baseurl, repository) tag_props = await client.get_tag_properties(tag_identifier) permissions = tag_props.content_permissions received = await client.set_tag_properties( tag_identifier, ContentPermissions( can_delete=False, can_list=False, can_read=False, can_write=False, ), ) assert not received.content_permissions.can_write assert not received.content_permissions.can_read assert not received.content_permissions.can_list assert not received.content_permissions.can_delete
async def test_set_manifest_properties_does_not_exist( self, containerregistry_baseurl): client = self.create_repository_client(containerregistry_baseurl, self.get_resource_name("repo")) with pytest.raises(ResourceNotFoundError): await client.set_manifest_properties( "sha256:abcdef", ContentPermissions(can_delete=False))
async 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): await client.set_tag_properties( DOES_NOT_EXIST, ContentPermissions(can_delete=False))
def test_set_manifest_properties(self, containerregistry_endpoint, containerregistry_resource_group): repository = self.get_resource_name("reposetmani") tag_identifier = self.get_resource_name("tag") self.import_repo_to_be_deleted( containerregistry_endpoint, resource_group=containerregistry_resource_group, tag=tag_identifier, repository=repository, ) client = self.create_repository_client(containerregistry_endpoint, repository) for artifact in client.list_registry_artifacts(): permissions = artifact.content_permissions received_permissions = client.set_manifest_properties( artifact.digest, ContentPermissions( can_delete=False, can_list=False, can_read=False, can_write=False, ), ) assert not received_permissions.content_permissions.can_delete assert not received_permissions.content_permissions.can_read assert not received_permissions.content_permissions.can_list assert not received_permissions.content_permissions.can_write # Reset and delete client.set_manifest_properties( artifact.digest, ContentPermissions( can_delete=True, can_list=True, can_read=True, can_write=True, ), ) self.sleep(10) client.delete() break
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.content_permissions received_permissions = await client.set_manifest_properties( artifact.digest, ContentPermissions( can_delete=False, can_list=False, can_read=False, can_write=False, ), ) assert not received_permissions.content_permissions.can_delete assert not received_permissions.content_permissions.can_read assert not received_permissions.content_permissions.can_list assert not received_permissions.content_permissions.can_write # Reset and delete await client.set_manifest_properties( artifact.digest, ContentPermissions( can_delete=True, can_list=True, can_read=True, can_write=True, ), ) await client.delete() break
async 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 = await client.get_tag_properties(tag_identifier) permissions = tag_props.content_permissions received = await client.set_tag_properties( tag_identifier, ContentPermissions( can_delete=False, can_list=False, can_read=False, can_write=False, ), ) assert not received.content_permissions.can_write assert not received.content_permissions.can_read assert not received.content_permissions.can_list assert not received.content_permissions.can_delete # Reset them await client.set_tag_properties( tag_identifier, ContentPermissions( can_delete=True, can_list=True, can_read=True, can_write=True, ), )