@pytest.mark.live_test_only
@GlobalStorageAccountPreparer()
@StorageAccountPreparer(random_name_enabled=True, name_prefix='pyrmtstorage', parameter_name='rmt')
@AsyncStorageTestCase.await_prepared_test
async def test_download_to_file_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)))
    FILE_PATH = '_to_file_with_sas.async.dat'
    blob = BlobClient.from_blob_url(source_blob.url, credential=sas_token)
    (await download_blob_from_url(blob.url, FILE_PATH))
    with open(FILE_PATH, 'rb') as stream:
        actual = stream.read()
        self.assertEqual(data, actual)
    self._teardown(FILE_PATH)
@pytest.mark.live_test_only
@GlobalStorageAccountPreparer()
@StorageAccountPreparer(random_name_enabled=True, name_prefix='pyrmtstorage', parameter_name='rmt')
@AsyncStorageTestCase.await_prepared_test
async def test_download_to_file_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)))
    FILE_PATH = '_to_file_with_sas.async.dat'
    blob = BlobClient.from_blob_url(source_blob.url, credential=sas_token)
    (await download_blob_from_url(blob.url, FILE_PATH))
    with open(FILE_PATH, 'rb') as stream:
        actual = stream.read()
        self.assertEqual(data, actual)
    self._teardown(FILE_PATH)