From 40ac17abf30722f8b643d8b0813f823ef5849c8d Mon Sep 17 00:00:00 2001 From: xiafu Date: Tue, 10 Sep 2019 10:44:49 -0700 Subject: [PATCH 1/5] Update HISTORY.md --- sdk/storage/azure-storage-blob/HISTORY.md | 4 ++-- sdk/storage/azure-storage-file/HISTORY.md | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azure-storage-blob/HISTORY.md b/sdk/storage/azure-storage-blob/HISTORY.md index d0b3f9805305..27922f18151d 100644 --- a/sdk/storage/azure-storage-blob/HISTORY.md +++ b/sdk/storage/azure-storage-blob/HISTORY.md @@ -6,8 +6,8 @@ **New features** - Added SAS support for snapshot and identity. - Distributed tracing framework OpenCensus is now supported. -- Added support for append block from URL for append blobs. -- Added support for update page from URL for page blobs. +- Added support for append_block_from_url API for append blobs. +- Added support for upload_pages_from_url API for page blobs. - Added support for client provided encryption key to numerous APIs. **Dependency updates** diff --git a/sdk/storage/azure-storage-file/HISTORY.md b/sdk/storage/azure-storage-file/HISTORY.md index c60dcde9bd57..d290b9c88a89 100644 --- a/sdk/storage/azure-storage-file/HISTORY.md +++ b/sdk/storage/azure-storage-file/HISTORY.md @@ -4,8 +4,6 @@ ## Version 12.0.0b3: **New features** -- Added FileSmbProperties REST Parity. -- Added support for PutRangeThroughURL. - Added upload_range_from_url API to write the bytes from one Azure File endpoint into the specified range of another Azure File endpoint. - Added set_http_headers for directory_client, create_permission_for_share and get_permission_for_share APIs. - Added optional parameters for smb properties related parameters for create_file*, create_directory* related APIs and set_http_headers API. From 268b064ea346287263a3df4425dfb3cf81dfe1c4 Mon Sep 17 00:00:00 2001 From: xiafu Date: Tue, 10 Sep 2019 11:15:15 -0700 Subject: [PATCH 2/5] Fix some typo in error message --- .../azure-storage-blob/azure/storage/blob/blob_client.py | 2 +- .../azure/storage/file/aio/file_client_async.py | 2 +- .../azure-storage-file/azure/storage/file/file_client.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py b/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py index e882ed80f29e..0033f93adf0e 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/blob_client.py @@ -559,7 +559,7 @@ def _download_blob_options(self, offset=None, length=None, validate_content=Fals if self.require_encryption and not self.key_encryption_key: raise ValueError("Encryption required but no key was provided.") if length is not None and offset is None: - raise ValueError("Offset value must not be None is length is set.") + raise ValueError("Offset value must not be None if length is set.") access_conditions = get_access_conditions(kwargs.pop('lease', None)) mod_conditions = ModifiedAccessConditions( diff --git a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py b/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py index 8ad8b1c1beeb..2b4277d957a5 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/aio/file_client_async.py @@ -460,7 +460,7 @@ async def download_file( if self.require_encryption or (self.key_encryption_key is not None): raise ValueError("Encryption not supported.") if length is not None and offset is None: - raise ValueError("Offset value must not be None is length is set.") + raise ValueError("Offset value must not be None if length is set.") downloader = StorageStreamDownloader( service=self._client.file, diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py index a4ec1db3d35d..3c2b8dbfc837 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py @@ -646,7 +646,7 @@ def download_file( if self.require_encryption or (self.key_encryption_key is not None): raise ValueError("Encryption not supported.") if length is not None and offset is None: - raise ValueError("Offset value must not be None is length is set.") + raise ValueError("Offset value must not be None if length is set.") return StorageStreamDownloader( service=self._client.file, From 602d95796b8ead84071572eb6bc59b818a2f1f39 Mon Sep 17 00:00:00 2001 From: xiafu Date: Tue, 10 Sep 2019 12:40:13 -0700 Subject: [PATCH 3/5] Fix Some Tests --- .../tests/test_append_blob_async.py | 4 +- .../tests/test_common_blob.py | 31 +++++++------- .../tests/test_common_blob_async.py | 41 ++++++++++--------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py index 8321a57e8578..72a74be54f6a 100644 --- a/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py @@ -697,7 +697,7 @@ async def _test_append_block_from_url_with_if_modified(self): await destination_blob_client.append_block_from_url(source_blob_client.url + '?' + sas, source_range_start=0, source_range_end=LARGE_BLOB_SIZE - 1, - if_modified_since=source_properties.get( + if_modified_since=destination_blob_properties.get( 'last_modified')) @record @@ -739,7 +739,7 @@ async def _test_append_block_from_url_with_if_unmodified(self): await destination_blob_client.append_block_from_url(source_blob_client.url + '?' + sas, source_range_start=0, source_range_end=LARGE_BLOB_SIZE - 1, - if_unmodified_since=source_properties.get( + if_unmodified_since=destination_blob_properties.get( 'last_modified') - timedelta(minutes=15)) @record diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob.py b/sdk/storage/azure-storage-blob/tests/test_common_blob.py index 5cd2a7f5be2f..6830c3ff035d 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob.py @@ -863,21 +863,22 @@ def test_copy_blob_with_existing_blob(self): copy_content = copyblob.download_blob().content_as_bytes() self.assertEqual(copy_content, self.byte_data) - @record - def test_copy_blob_with_external_blob_fails(self): - # Arrange - source_blob = "http://www.gutenberg.org/files/59466/59466-0.txt" - copied_blob = self.bsc.get_blob_client(self.container_name, '59466-0.txt') - - # Act - copy = copied_blob.start_copy_from_url(source_blob) - self.assertEqual(copy['copy_status'], 'pending') - props = self._wait_for_async_copy(copied_blob) - - # Assert - self.assertEqual(props.copy.status_description, '500 InternalServerError "Copy failed."') - self.assertEqual(props.copy.status, 'failed') - self.assertIsNotNone(props.copy.id) + # TODO: external copy was supported since 2019-02-02 + # @record + # def test_copy_blob_with_external_blob_fails(self): + # # Arrange + # source_blob = "http://www.google.com" + # copied_blob = self.bsc.get_blob_client(self.container_name, '59466-0.txt') + # + # # Act + # copy = copied_blob.start_copy_from_url(source_blob) + # self.assertEqual(copy['copy_status'], 'pending') + # props = self._wait_for_async_copy(copied_blob) + # + # # Assert + # self.assertEqual(props.copy.status_description, '500 InternalServerError "Copy failed."') + # self.assertEqual(props.copy.status, 'success') + # self.assertIsNotNone(props.copy.id) @record def test_copy_blob_async_private_blob_no_sas(self): diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py index ba8fa6cc8ac6..05cf4e25546d 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py @@ -1146,26 +1146,27 @@ def test_copy_blob_with_existing_blob(self): loop = asyncio.get_event_loop() loop.run_until_complete(self._test_copy_blob_with_existing_blob()) - async def _test_copy_blob_with_external_blob_fails(self): - # Arrange - await self._setup() - source_blob = "http://www.gutenberg.org/files/59466/59466-0.txt" - copied_blob = self.bsc.get_blob_client(self.container_name, '59466-0.txt') - - # Act - copy = await copied_blob.start_copy_from_url(source_blob) - self.assertEqual(copy['copy_status'], 'pending') - props = await self._wait_for_async_copy(copied_blob) - - # Assert - self.assertEqual(props.copy.status_description, '500 InternalServerError "Copy failed."') - self.assertEqual(props.copy.status, 'failed') - self.assertIsNotNone(props.copy.id) - - @record - def test_copy_blob_with_external_blob_fails(self): - loop = asyncio.get_event_loop() - loop.run_until_complete(self._test_copy_blob_with_external_blob_fails()) + # TODO: external copy was supported since 2019-02-02 + # async def _test_copy_blob_with_external_blob_fails(self): + # # Arrange + # await self._setup() + # source_blob = "http://www.gutenberg.org/files/59466/59466-0.txt" + # copied_blob = self.bsc.get_blob_client(self.container_name, '59466-0.txt') + # + # # Act + # copy = await copied_blob.start_copy_from_url(source_blob) + # self.assertEqual(copy['copy_status'], 'pending') + # props = await self._wait_for_async_copy(copied_blob) + # + # # Assert + # self.assertEqual(props.copy.status_description, '500 InternalServerError "Copy failed."') + # self.assertEqual(props.copy.status, 'failed') + # self.assertIsNotNone(props.copy.id) + # + # @record + # def test_copy_blob_with_external_blob_fails(self): + # loop = asyncio.get_event_loop() + # loop.run_until_complete(self._test_copy_blob_with_external_blob_fails()) async def _test_copy_blob_async_private_blob_no_sas(self): # Arrange From 768dbacd75f5c43b820fba7640233f043ccc1f31 Mon Sep 17 00:00:00 2001 From: Rakshith Bhyravabhotla Date: Tue, 10 Sep 2019 15:04:09 -0700 Subject: [PATCH 4/5] some more fixes --- sdk/storage/azure-storage-blob/tests/test_append_blob_async.py | 2 +- sdk/storage/azure-storage-blob/tests/test_common_blob_async.py | 1 + sdk/storage/azure-storage-blob/tests/test_page_blob_async.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py index 72a74be54f6a..843eb66b334e 100644 --- a/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_append_blob_async.py @@ -722,7 +722,7 @@ async def _test_append_block_from_url_with_if_unmodified(self): resp = await destination_blob_client. \ append_block_from_url(source_blob_client.url + '?' + sas, source_range_start=0, source_range_end=LARGE_BLOB_SIZE - 1, - if_unmodified_since=source_properties.get('last_modified')) + if_unmodified_since=source_properties.get('last_modified') + timedelta(minutes=15)) self.assertEqual(resp.get('blob_append_offset'), '0') self.assertEqual(resp.get('blob_committed_block_count'), 1) self.assertIsNotNone(resp.get('etag')) diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py index 05cf4e25546d..feb71f805d0d 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py @@ -1692,6 +1692,7 @@ async def _test_token_credential(self): @record def test_token_credential(self): + pytest.skip("not set up to use async azure-identity") loop = asyncio.get_event_loop() loop.run_until_complete(self._test_token_credential()) diff --git a/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py index 01fc04e30803..9e409089d25b 100644 --- a/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_page_blob_async.py @@ -758,7 +758,7 @@ async def _test_upload_pages_from_url_with_if_unmodified(self): SOURCE_BLOB_SIZE - 1, 0, if_unmodified_since=source_properties.get( - 'last_modified')) + 'last_modified') + timedelta(minutes=15)) self.assertIsNotNone(resp.get('etag')) self.assertIsNotNone(resp.get('last_modified')) From 8e36e3836447de5465042f202ade64a5883449ed Mon Sep 17 00:00:00 2001 From: xiafu Date: Tue, 10 Sep 2019 15:20:43 -0700 Subject: [PATCH 5/5] Skip OAUTH Test --- sdk/storage/azure-storage-blob/tests/test_common_blob.py | 1 + sdk/storage/azure-storage-blob/tests/test_common_blob_async.py | 2 ++ sdk/storage/azure-storage-blob/tests/test_container.py | 1 + 3 files changed, 4 insertions(+) diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob.py b/sdk/storage/azure-storage-blob/tests/test_common_blob.py index 6830c3ff035d..a2439b14fc48 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob.py @@ -1297,6 +1297,7 @@ def test_get_user_delegation_key(self): self.assertEqual(user_delegation_key_1.value, user_delegation_key_2.value) def test_user_delegation_sas_for_blob(self): + pytest.skip("Current Framework Cannot Support OAUTH") # SAS URL is calculated from storage key, so this test runs live only if TestMode.need_recording_file(self.test_mode): return diff --git a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py index feb71f805d0d..66253ba67dc9 100644 --- a/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_common_blob_async.py @@ -1632,6 +1632,7 @@ def test_account_sas(self): async def _test_get_user_delegation_key(self): # TODO: figure out why recording does not work + pytest.skip("Current Framework Cannot Support OAUTH") if TestMode.need_recording_file(self.test_mode): return # Act @@ -1668,6 +1669,7 @@ def test_get_user_delegation_key_async(self): loop.run_until_complete(self._test_get_user_delegation_key()) async def _test_token_credential(self): + pytest.skip("Current Framework Cannot Support OAUTH") if TestMode.need_recording_file(self.test_mode): return diff --git a/sdk/storage/azure-storage-blob/tests/test_container.py b/sdk/storage/azure-storage-blob/tests/test_container.py index 18420af2b91c..d04a74e8b3bf 100644 --- a/sdk/storage/azure-storage-blob/tests/test_container.py +++ b/sdk/storage/azure-storage-blob/tests/test_container.py @@ -1079,6 +1079,7 @@ def test_web_container_normal_operations_working(self): def test_user_delegation_sas_for_container(self): # SAS URL is calculated from storage key, so this test runs live only + pytest.skip("Current Framework Cannot Support OAUTH") if TestMode.need_recording_file(self.test_mode): return