@GlobalStorageAccountPreparer()
@StorageAccountPreparer(random_name_enabled=True, name_prefix='pyrmtstorage', parameter_name='rmt')
@AsyncStorageTestCase.await_prepared_test
async def test_copy_blob_async_private_blob_with_sas(self, resource_group, location, storage_account, storage_account_key, rmt, rmt_key):
    (await self._setup(storage_account.name, storage_account_key))
    data = ((b'12345678' * 1024) * 1024)
    (await self._setup_remote(rmt.name, rmt_key))
    (await self._create_remote_container())
    source_blob = (await self._create_remote_block_blob(blob_data=data))
    sas_token = generate_blob_sas(source_blob.account_name, source_blob.container_name, source_blob.blob_name, snapshot=source_blob.snapshot, account_key=source_blob.credential.account_key, permission=BlobSasPermissions(read=True), expiry=(datetime.utcnow() + timedelta(hours=1)))
    blob = BlobClient.from_blob_url(source_blob.url, credential=sas_token)
    target_blob_name = 'targetblob'
    target_blob = self.bsc.get_blob_client(self.container_name, target_blob_name)
    copy_resp = (await target_blob.start_copy_from_url(blob.url))
    props = (await self._wait_for_async_copy(target_blob))
    self.assertEqual(props.copy.status, 'success')
    actual_data = (await (await target_blob.download_blob()).readall())
    self.assertEqual(actual_data, data)
@GlobalStorageAccountPreparer()
@StorageAccountPreparer(random_name_enabled=True, name_prefix='pyrmtstorage', parameter_name='rmt')
@AsyncStorageTestCase.await_prepared_test
async def test_copy_blob_async_private_blob_with_sas(self, resource_group, location, storage_account, storage_account_key, rmt, rmt_key):
    (await self._setup(storage_account.name, storage_account_key))
    data = ((b'12345678' * 1024) * 1024)
    (await self._setup_remote(rmt.name, rmt_key))
    (await self._create_remote_container())
    source_blob = (await self._create_remote_block_blob(blob_data=data))
    sas_token = generate_blob_sas(source_blob.account_name, source_blob.container_name, source_blob.blob_name, snapshot=source_blob.snapshot, account_key=source_blob.credential.account_key, permission=BlobSasPermissions(read=True), expiry=(datetime.utcnow() + timedelta(hours=1)))
    blob = BlobClient.from_blob_url(source_blob.url, credential=sas_token)
    target_blob_name = 'targetblob'
    target_blob = self.bsc.get_blob_client(self.container_name, target_blob_name)
    copy_resp = (await target_blob.start_copy_from_url(blob.url))
    props = (await self._wait_for_async_copy(target_blob))
    self.assertEqual(props.copy.status, 'success')
    actual_data = (await (await target_blob.download_blob()).readall())
    self.assertEqual(actual_data, data)