From 4a5391cb0ff8632f09cd552554d327372db5cbed Mon Sep 17 00:00:00 2001 From: Jacob Lauzon Date: Fri, 15 Jul 2022 18:08:53 -0700 Subject: [PATCH 1/2] Migrate test_blob_api_version to test proxy --- ...test_old_api_get_page_ranges_succeeds.json | 241 ++++++++++++ ...test_old_api_get_page_ranges_succeeds.yaml | 347 ------------------ ...test_old_api_get_page_ranges_succeeds.json | 233 ++++++++++++ ...ld_api_get_page_ranges_succeeds_async.yaml | 297 --------------- .../tests/test_blob_api_version.py | 119 +++--- .../tests/test_blob_api_version_async.py | 118 +++--- 6 files changed, 596 insertions(+), 759 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.pyTestStorageBlobApiVersiontest_old_api_get_page_ranges_succeeds.json delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.test_old_api_get_page_ranges_succeeds.yaml create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.pyTestStorageBlobApiVersionAsynctest_old_api_get_page_ranges_succeeds.json delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.test_old_api_get_page_ranges_succeeds_async.yaml diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.pyTestStorageBlobApiVersiontest_old_api_get_page_ranges_succeeds.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.pyTestStorageBlobApiVersiontest_old_api_get_page_ranges_succeeds.json new file mode 100644 index 000000000000..33a1d3147cc9 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.pyTestStorageBlobApiVersiontest_old_api_get_page_ranges_succeeds.json @@ -0,0 +1,241 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:52 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C77823E94A\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-blob-content-length": "2048", + "x-ms-blob-type": "PageBlob", + "x-ms-date": "Sat, 16 Jul 2022 01:06:52 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C778318636\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=snapshot", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:52 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C778318636\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "false", + "x-ms-snapshot": "2022-07-16T01:06:52.8302562Z", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=page", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1536", + "Content-Type": "application/octet-stream", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:52 GMT", + "x-ms-page-write": "update", + "x-ms-range": "bytes=0-1535", + "x-ms-version": "2019-02-02" + }, + "RequestBody": "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C7784A13A0\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-blob-sequence-number": "0", + "x-ms-content-crc64": "h0C9OBmisio=", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=snapshot", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:53 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C7784A13A0\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "false", + "x-ms-snapshot": "2022-07-16T01:06:52.9671772Z", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=page", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:53 GMT", + "x-ms-page-write": "clear", + "x-ms-range": "bytes=512-1023", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C7785F1F2A\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-blob-sequence-number": "0", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=pagelist\u0026prevsnapshot=2022-07-16T01%3A06%3A52.8302562Z", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:53 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Sat, 16 Jul 2022 01:06:52 GMT", + "ETag": "\u00220x8DA66C7785F1F2A\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-blob-content-length": "2048", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CPageList\u003E\u003CPageRange\u003E\u003CStart\u003E0\u003C/Start\u003E\u003CEnd\u003E511\u003C/End\u003E\u003C/PageRange\u003E\u003CClearRange\u003E\u003CStart\u003E512\u003C/Start\u003E\u003CEnd\u003E1023\u003C/End\u003E\u003C/ClearRange\u003E\u003CPageRange\u003E\u003CStart\u003E1024\u003C/Start\u003E\u003CEnd\u003E1535\u003C/End\u003E\u003C/PageRange\u003E\u003C/PageList\u003E" + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerd1893417/blobd1893417?comp=pagelist\u0026prevsnapshot=2022-07-16T01%3A06%3A52.9671772Z", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:53 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Sat, 16 Jul 2022 01:06:53 GMT", + "ETag": "\u00220x8DA66C7785F1F2A\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-blob-content-length": "2048", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CPageList\u003E\u003CClearRange\u003E\u003CStart\u003E512\u003C/Start\u003E\u003CEnd\u003E1023\u003C/End\u003E\u003C/ClearRange\u003E\u003C/PageList\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.test_old_api_get_page_ranges_succeeds.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.test_old_api_get_page_ranges_succeeds.yaml deleted file mode 100644 index 80475728b35b..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version.test_old_api_get_page_ranges_succeeds.yaml +++ /dev/null @@ -1,347 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:23 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a?restype=container - response: - body: - string: "\uFEFFContainerAlreadyExistsThe - specified container already exists.\nRequestId:148893db-a01e-00ad-3157-d8446a000000\nTime:2020-01-31T16:59:23.9680391Z" - headers: - content-length: - - '230' - content-type: - - application/xml - date: - - Fri, 31 Jan 2020 16:59:23 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-error-code: - - ContainerAlreadyExists - x-ms-version: - - '2019-02-02' - status: - code: 409 - message: The specified container already exists. -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-blob-content-length: - - '2048' - x-ms-blob-type: - - PageBlob - x-ms-date: - - Fri, 31 Jan 2020 16:59:23 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 31 Jan 2020 16:59:24 GMT - etag: - - '"0x8D7A66EEC91589E"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: - - 'true' - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:24 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?comp=snapshot - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 31 Jan 2020 16:59:24 GMT - etag: - - '"0x8D7A66EEC91589E"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: - - 'false' - x-ms-snapshot: - - '2020-01-31T16:59:24.4518214Z' - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '1536' - Content-Type: - - application/octet-stream - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:24 GMT - x-ms-page-write: - - update - x-ms-range: - - bytes=0-1535 - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?comp=page - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 31 Jan 2020 16:59:24 GMT - etag: - - '"0x8D7A66EECD01AA5"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-blob-sequence-number: - - '0' - x-ms-content-crc64: - - h0C9OBmisio= - x-ms-request-server-encrypted: - - 'true' - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:24 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?comp=snapshot - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 31 Jan 2020 16:59:24 GMT - etag: - - '"0x8D7A66EECD01AA5"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: - - 'false' - x-ms-snapshot: - - '2020-01-31T16:59:24.7980659Z' - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:24 GMT - x-ms-page-write: - - clear - x-ms-range: - - bytes=512-1023 - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?comp=page - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 31 Jan 2020 16:59:24 GMT - etag: - - '"0x8D7A66EED0899F2"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-blob-sequence-number: - - '0' - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:24 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?prevsnapshot=2020-01-31T16%3A59%3A24.4518214Z&comp=pagelist - response: - body: - string: "\uFEFF0511512102310241535" - headers: - content-type: - - application/xml - date: - - Fri, 31 Jan 2020 16:59:25 GMT - etag: - - '"0x8D7A66EED0899F2"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - vary: - - Origin - x-ms-blob-content-length: - - '2048' - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 16:59:25 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/utcontainerd2de180a/blobd2de180a?prevsnapshot=2020-01-31T16%3A59%3A24.7980659Z&comp=pagelist - response: - body: - string: "\uFEFF5121023" - headers: - content-type: - - application/xml - date: - - Fri, 31 Jan 2020 16:59:25 GMT - etag: - - '"0x8D7A66EED0899F2"' - last-modified: - - Fri, 31 Jan 2020 16:59:24 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - vary: - - Origin - x-ms-blob-content-length: - - '2048' - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.pyTestStorageBlobApiVersionAsynctest_old_api_get_page_ranges_succeeds.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.pyTestStorageBlobApiVersionAsynctest_old_api_get_page_ranges_succeeds.json new file mode 100644 index 000000000000..eb58e6f0543e --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.pyTestStorageBlobApiVersionAsynctest_old_api_get_page_ranges_succeeds.json @@ -0,0 +1,233 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:39 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:39 GMT", + "ETag": "\u00220x8DA66C770C07186\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-blob-content-length": "2048", + "x-ms-blob-type": "PageBlob", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:39 GMT", + "ETag": "\u00220x8DA66C770D16CEC\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=snapshot", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:39 GMT", + "ETag": "\u00220x8DA66C770D16CEC\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "false", + "x-ms-snapshot": "2022-07-16T01:06:40.4344248Z", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=page", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "1536", + "Content-Type": "application/octet-stream", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-page-write": "update", + "x-ms-range": "bytes=0-1535", + "x-ms-version": "2019-02-02" + }, + "RequestBody": "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFh", + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:39 GMT", + "ETag": "\u00220x8DA66C770E6786C\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-blob-sequence-number": "0", + "x-ms-content-crc64": "h0C9OBmisio=", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=snapshot", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:40 GMT", + "ETag": "\u00220x8DA66C770E6786C\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-request-server-encrypted": "false", + "x-ms-snapshot": "2022-07-16T01:06:40.5683471Z", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=page", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-page-write": "clear", + "x-ms-range": "bytes=512-1023", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Sat, 16 Jul 2022 01:06:40 GMT", + "ETag": "\u00220x8DA66C770FAC0B7\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-blob-sequence-number": "0", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=pagelist\u0026prevsnapshot=2022-07-16T01:06:40.4344248Z", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Sat, 16 Jul 2022 01:06:40 GMT", + "ETag": "\u00220x8DA66C770FAC0B7\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-blob-content-length": "2048", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CPageList\u003E\u003CPageRange\u003E\u003CStart\u003E0\u003C/Start\u003E\u003CEnd\u003E511\u003C/End\u003E\u003C/PageRange\u003E\u003CClearRange\u003E\u003CStart\u003E512\u003C/Start\u003E\u003CEnd\u003E1023\u003C/End\u003E\u003C/ClearRange\u003E\u003CPageRange\u003E\u003CStart\u003E1024\u003C/Start\u003E\u003CEnd\u003E1535\u003C/End\u003E\u003C/PageRange\u003E\u003C/PageList\u003E" + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer3b5a3892/blob3b5a3892?comp=pagelist\u0026prevsnapshot=2022-07-16T01:06:40.5683471Z", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Sat, 16 Jul 2022 01:06:40 GMT", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Sat, 16 Jul 2022 01:06:40 GMT", + "ETag": "\u00220x8DA66C770FAC0B7\u0022", + "Last-Modified": "Sat, 16 Jul 2022 01:06:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-blob-content-length": "2048", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CPageList\u003E\u003CClearRange\u003E\u003CStart\u003E512\u003C/Start\u003E\u003CEnd\u003E1023\u003C/End\u003E\u003C/ClearRange\u003E\u003C/PageList\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.test_old_api_get_page_ranges_succeeds_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.test_old_api_get_page_ranges_succeeds_async.yaml deleted file mode 100644 index d95795da17a2..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_api_version_async.test_old_api_get_page_ranges_succeeds_async.yaml +++ /dev/null @@ -1,297 +0,0 @@ -interactions: -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:44 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04?restype=container - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:44 GMT - etag: '"0x8D7A672770D0050"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04 - - restype=container - - '' -- request: - body: null - headers: - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-blob-content-length: - - '2048' - x-ms-blob-type: - - PageBlob - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04 - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:44 GMT - etag: '"0x8D7A67277163305"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: 'true' - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - '' - - '' -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?comp=snapshot - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:44 GMT - etag: '"0x8D7A67277163305"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: 'false' - x-ms-snapshot: '2020-01-31T17:24:45.1201053Z' - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - comp=snapshot - - '' -- request: - body: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - headers: - Content-Length: - - '1536' - Content-Type: - - application/octet-stream - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-page-write: - - update - x-ms-range: - - bytes=0-1535 - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?comp=page - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:44 GMT - etag: '"0x8D7A67277263B7E"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-blob-sequence-number: '0' - x-ms-content-crc64: h0C9OBmisio= - x-ms-request-server-encrypted: 'true' - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - comp=page - - '' -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?comp=snapshot - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:44 GMT - etag: '"0x8D7A67277263B7E"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-request-server-encrypted: 'false' - x-ms-snapshot: '2020-01-31T17:24:45.2171729Z' - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - comp=snapshot - - '' -- request: - body: null - headers: - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-page-write: - - clear - x-ms-range: - - bytes=512-1023 - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?comp=page - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 31 Jan 2020 17:24:45 GMT - etag: '"0x8D7A6727734BD15"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-blob-sequence-number: '0' - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - comp=page - - '' -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?prevsnapshot=2020-01-31T17:24:45.1201053Z&comp=pagelist - response: - body: - string: "\uFEFF0511512102310241535" - headers: - content-type: application/xml - date: Fri, 31 Jan 2020 17:24:45 GMT - etag: '"0x8D7A6727734BD15"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - vary: Origin - x-ms-blob-content-length: '2048' - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - prevsnapshot=2020-01-31T17:24:45.1201053Z&comp=pagelist - - '' -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - azsdk-python-storage-blob/12.2.0 Python/3.7.4 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 31 Jan 2020 17:24:45 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/utcontainer164c1d04/blob164c1d04?prevsnapshot=2020-01-31T17:24:45.2171729Z&comp=pagelist - response: - body: - string: "\uFEFF5121023" - headers: - content-type: application/xml - date: Fri, 31 Jan 2020 17:24:45 GMT - etag: '"0x8D7A6727734BD15"' - last-modified: Fri, 31 Jan 2020 17:24:45 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - vary: Origin - x-ms-blob-content-length: '2048' - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - amqptest.blob.core.windows.net - - /utcontainer164c1d04/blob164c1d04 - - prevsnapshot=2020-01-31T17:24:45.2171729Z&comp=pagelist - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_api_version.py b/sdk/storage/azure-storage-blob/tests/test_blob_api_version.py index d387b6b32676..6ed00bc5a1dd 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_api_version.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_api_version.py @@ -3,37 +3,31 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import unittest -import pytest -import platform -from datetime import datetime, timedelta -from azure.core.exceptions import AzureError, ResourceExistsError +import pytest +from azure.core.exceptions import ResourceExistsError from azure.storage.blob import ( - VERSION, - generate_blob_sas, - BlobServiceClient, ContainerClient, BlobClient, - BlobSasPermissions + BlobServiceClient, ) from azure.storage.blob._shared.constants import X_MS_VERSION -from devtools_testutils import ResourceGroupPreparer, StorageAccountPreparer + +from devtools_testutils import recorded_by_proxy +from devtools_testutils.storage import StorageRecordedTestCase from settings.testcase import BlobPreparer -from devtools_testutils.storage import StorageTestCase -# ------------------------------------------------------------------------------ + TEST_BLOB_PREFIX = 'blob' -class StorageClientTest(StorageTestCase): - def setUp(self): - super(StorageClientTest, self).setUp() +class TestStorageBlobApiVersion(StorageRecordedTestCase): + + # --Helpers----------------------------------------------------------------- + def _setup(self): self.api_version_1 = "2019-02-02" self.api_version_2 = X_MS_VERSION self.container_name = self.get_resource_name('utcontainer') - # --Helpers----------------------------------------------------------------- - def _get_blob_reference(self, prefix=TEST_BLOB_PREFIX): return self.get_resource_name(prefix) @@ -48,11 +42,12 @@ def _create_container(self, bsc): # --Test Cases-------------------------------------------------------------- def test_service_client_api_version_property(self): + self._setup() service_client = BlobServiceClient( "https://foo.blob.core.windows.net/account", credential="fake_key") - self.assertEqual(service_client.api_version, self.api_version_2) - self.assertEqual(service_client._client._config.version, self.api_version_2) + assert service_client.api_version == self.api_version_2 + assert service_client._client._config.version == self.api_version_2 with pytest.raises(AttributeError): service_client.api_version = "foo" @@ -61,62 +56,65 @@ def test_service_client_api_version_property(self): "https://foo.blob.core.windows.net/account", credential="fake_key", api_version=self.api_version_1) - self.assertEqual(service_client.api_version, self.api_version_1) - self.assertEqual(service_client._client._config.version, self.api_version_1) + assert service_client.api_version == self.api_version_1 + assert service_client._client._config.version == self.api_version_1 container_client = service_client.get_container_client("foo") - self.assertEqual(container_client.api_version, self.api_version_1) - self.assertEqual(container_client._client._config.version, self.api_version_1) + assert container_client.api_version == self.api_version_1 + assert container_client._client._config.version == self.api_version_1 blob_client = service_client.get_blob_client("foo", "bar") - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 def test_container_client_api_version_property(self): + self._setup() container_client = ContainerClient( "https://foo.blob.core.windows.net/account", self.container_name, credential="fake_key") - self.assertEqual(container_client.api_version, self.api_version_2) - self.assertEqual(container_client._client._config.version, self.api_version_2) + assert container_client.api_version == self.api_version_2 + assert container_client._client._config.version == self.api_version_2 container_client = ContainerClient( "https://foo.blob.core.windows.net/account", self.container_name, credential="fake_key", api_version=self.api_version_1) - self.assertEqual(container_client.api_version, self.api_version_1) - self.assertEqual(container_client._client._config.version, self.api_version_1) + assert container_client.api_version == self.api_version_1 + assert container_client._client._config.version == self.api_version_1 blob_client = container_client.get_blob_client("foo") - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 def test_blob_client_api_version_property(self): + self._setup() blob_client = BlobClient( "https://foo.blob.core.windows.net/account", self.container_name, self._get_blob_reference(), credential="fake_key", api_version=self.api_version_1) - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 blob_client = BlobClient( "https://foo.blob.core.windows.net/account", self.container_name, self._get_blob_reference(), credential="fake_key") - self.assertEqual(blob_client.api_version, self.api_version_2) - self.assertEqual(blob_client._client._config.version, self.api_version_2) + assert blob_client.api_version == self.api_version_2 + assert blob_client._client._config.version == self.api_version_2 def test_invalid_api_version(self): + self._setup() with pytest.raises(ValueError) as error: BlobServiceClient( "https://foo.blob.core.windows.net/account", credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") with pytest.raises(ValueError) as error: ContainerClient( @@ -124,7 +122,7 @@ def test_invalid_api_version(self): self.container_name, credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") with pytest.raises(ValueError) as error: BlobClient( @@ -133,10 +131,15 @@ def test_invalid_api_version(self): self._get_blob_reference(), credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") @BlobPreparer() - def test_old_api_get_page_ranges_succeeds(self, storage_account_name, storage_account_key): + @recorded_by_proxy + def test_old_api_get_page_ranges_succeeds(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() bsc = BlobServiceClient( self.account_url(storage_account_name, "blob"), credential=storage_account_key, @@ -160,24 +163,24 @@ def test_old_api_get_page_ranges_succeeds(self, storage_account_name, storage_ac ranges2, cleared2 = blob.get_page_ranges(previous_snapshot_diff=snapshot2['snapshot']) # Assert - self.assertIsNotNone(ranges1) - self.assertIsInstance(ranges1, list) - self.assertEqual(len(ranges1), 2) - self.assertIsInstance(cleared1, list) - self.assertEqual(len(cleared1), 1) - self.assertEqual(ranges1[0]['start'], 0) - self.assertEqual(ranges1[0]['end'], 511) - self.assertEqual(cleared1[0]['start'], 512) - self.assertEqual(cleared1[0]['end'], 1023) - self.assertEqual(ranges1[1]['start'], 1024) - self.assertEqual(ranges1[1]['end'], 1535) - - self.assertIsNotNone(ranges2) - self.assertIsInstance(ranges2, list) - self.assertEqual(len(ranges2), 0) - self.assertIsInstance(cleared2, list) - self.assertEqual(len(cleared2), 1) - self.assertEqual(cleared2[0]['start'], 512) - self.assertEqual(cleared2[0]['end'], 1023) + assert ranges1 is not None + assert isinstance(ranges1, list) + assert len(ranges1) == 2 + assert isinstance(cleared1, list) + assert len(cleared1) == 1 + assert ranges1[0]['start'] == 0 + assert ranges1[0]['end'] == 511 + assert cleared1[0]['start'] == 512 + assert cleared1[0]['end'] == 1023 + assert ranges1[1]['start'] == 1024 + assert ranges1[1]['end'] == 1535 + + assert ranges2 is not None + assert isinstance(ranges2, list) + assert len(ranges2) == 0 + assert isinstance(cleared2, list) + assert len(cleared2) == 1 + assert cleared2[0]['start'] == 512 + assert cleared2[0]['end'] == 1023 # ------------------------------------------------------------------------------ diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_api_version_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_api_version_async.py index 9ed52eaac509..9f40d21c7afc 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_api_version_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_api_version_async.py @@ -3,35 +3,31 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import unittest -import pytest -import platform -from datetime import datetime, timedelta -from azure.core.exceptions import AzureError, ResourceExistsError -from azure.storage.blob import generate_blob_sas, BlobSasPermissions -from azure.storage.blob._shared.constants import X_MS_VERSION +import pytest +from azure.core.exceptions import ResourceExistsError from azure.storage.blob.aio import ( - BlobServiceClient, ContainerClient, BlobClient, + BlobServiceClient, ) +from azure.storage.blob._shared.constants import X_MS_VERSION + +from devtools_testutils.aio import recorded_by_proxy_async +from devtools_testutils.storage.aio import AsyncStorageRecordedTestCase from settings.testcase import BlobPreparer -from devtools_testutils.storage.aio import AsyncStorageTestCase -# ------------------------------------------------------------------------------ TEST_BLOB_PREFIX = 'blob' -class StorageClientTest(AsyncStorageTestCase): - def setUp(self): - super(StorageClientTest, self).setUp() +class TestStorageBlobApiVersionAsync(AsyncStorageRecordedTestCase): + + # --Helpers----------------------------------------------------------------- + def _setup(self): self.api_version_1 = "2019-02-02" self.api_version_2 = X_MS_VERSION self.container_name = self.get_resource_name('utcontainer') - # --Helpers----------------------------------------------------------------- - def _get_blob_reference(self, prefix=TEST_BLOB_PREFIX): return self.get_resource_name(prefix) @@ -46,11 +42,12 @@ async def _create_container(self, bsc): # --Test Cases-------------------------------------------------------------- def test_service_client_api_version_property(self): + self._setup() service_client = BlobServiceClient( "https://foo.blob.core.windows.net/account", credential="fake_key") - self.assertEqual(service_client.api_version, self.api_version_2) - self.assertEqual(service_client._client._config.version, self.api_version_2) + assert service_client.api_version == self.api_version_2 + assert service_client._client._config.version == self.api_version_2 with pytest.raises(AttributeError): service_client.api_version = "foo" @@ -59,62 +56,65 @@ def test_service_client_api_version_property(self): "https://foo.blob.core.windows.net/account", credential="fake_key", api_version=self.api_version_1) - self.assertEqual(service_client.api_version, self.api_version_1) - self.assertEqual(service_client._client._config.version, self.api_version_1) + assert service_client.api_version == self.api_version_1 + assert service_client._client._config.version == self.api_version_1 container_client = service_client.get_container_client("foo") - self.assertEqual(container_client.api_version, self.api_version_1) - self.assertEqual(container_client._client._config.version, self.api_version_1) + assert container_client.api_version == self.api_version_1 + assert container_client._client._config.version == self.api_version_1 blob_client = service_client.get_blob_client("foo", "bar") - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 def test_container_client_api_version_property(self): + self._setup() container_client = ContainerClient( "https://foo.blob.core.windows.net/account", self.container_name, credential="fake_key") - self.assertEqual(container_client.api_version, self.api_version_2) - self.assertEqual(container_client._client._config.version, self.api_version_2) + assert container_client.api_version == self.api_version_2 + assert container_client._client._config.version == self.api_version_2 container_client = ContainerClient( "https://foo.blob.core.windows.net/account", self.container_name, credential="fake_key", api_version=self.api_version_1) - self.assertEqual(container_client.api_version, self.api_version_1) - self.assertEqual(container_client._client._config.version, self.api_version_1) + assert container_client.api_version == self.api_version_1 + assert container_client._client._config.version == self.api_version_1 blob_client = container_client.get_blob_client("foo") - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 def test_blob_client_api_version_property(self): + self._setup() blob_client = BlobClient( "https://foo.blob.core.windows.net/account", self.container_name, self._get_blob_reference(), credential="fake_key", api_version=self.api_version_1) - self.assertEqual(blob_client.api_version, self.api_version_1) - self.assertEqual(blob_client._client._config.version, self.api_version_1) + assert blob_client.api_version == self.api_version_1 + assert blob_client._client._config.version == self.api_version_1 blob_client = BlobClient( "https://foo.blob.core.windows.net/account", self.container_name, self._get_blob_reference(), credential="fake_key") - self.assertEqual(blob_client.api_version, self.api_version_2) - self.assertEqual(blob_client._client._config.version, self.api_version_2) + assert blob_client.api_version == self.api_version_2 + assert blob_client._client._config.version == self.api_version_2 def test_invalid_api_version(self): + self._setup() with pytest.raises(ValueError) as error: BlobServiceClient( "https://foo.blob.core.windows.net/account", credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") with pytest.raises(ValueError) as error: ContainerClient( @@ -122,7 +122,7 @@ def test_invalid_api_version(self): self.container_name, credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") with pytest.raises(ValueError) as error: BlobClient( @@ -131,11 +131,15 @@ def test_invalid_api_version(self): self._get_blob_reference(), credential="fake_key", api_version="foo") - self.assertTrue(str(error.value).startswith("Unsupported API version 'foo'.")) + assert str(error.value).startswith("Unsupported API version 'foo'.") @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_old_api_get_page_ranges_succeeds_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_old_api_get_page_ranges_succeeds(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() bsc = BlobServiceClient( self.account_url(storage_account_name, "blob"), credential=storage_account_key, @@ -159,24 +163,24 @@ async def test_old_api_get_page_ranges_succeeds_async(self, storage_account_name ranges2, cleared2 = await blob.get_page_ranges(previous_snapshot_diff=snapshot2['snapshot']) # Assert - self.assertIsNotNone(ranges1) - self.assertIsInstance(ranges1, list) - self.assertEqual(len(ranges1), 2) - self.assertIsInstance(cleared1, list) - self.assertEqual(len(cleared1), 1) - self.assertEqual(ranges1[0]['start'], 0) - self.assertEqual(ranges1[0]['end'], 511) - self.assertEqual(cleared1[0]['start'], 512) - self.assertEqual(cleared1[0]['end'], 1023) - self.assertEqual(ranges1[1]['start'], 1024) - self.assertEqual(ranges1[1]['end'], 1535) - - self.assertIsNotNone(ranges2) - self.assertIsInstance(ranges2, list) - self.assertEqual(len(ranges2), 0) - self.assertIsInstance(cleared2, list) - self.assertEqual(len(cleared2), 1) - self.assertEqual(cleared2[0]['start'], 512) - self.assertEqual(cleared2[0]['end'], 1023) + assert ranges1 is not None + assert isinstance(ranges1, list) + assert len(ranges1) == 2 + assert isinstance(cleared1, list) + assert len(cleared1) == 1 + assert ranges1[0]['start'] == 0 + assert ranges1[0]['end'] == 511 + assert cleared1[0]['start'] == 512 + assert cleared1[0]['end'] == 1023 + assert ranges1[1]['start'] == 1024 + assert ranges1[1]['end'] == 1535 + + assert ranges2 is not None + assert isinstance(ranges2, list) + assert len(ranges2) == 0 + assert isinstance(cleared2, list) + assert len(cleared2) == 1 + assert cleared2[0]['start'] == 512 + assert cleared2[0]['end'] == 1023 # ------------------------------------------------------------------------------ From 2787f3ff6f3cd7c034e56af1946de00814723abe Mon Sep 17 00:00:00 2001 From: Jacob Lauzon Date: Mon, 18 Jul 2022 13:18:53 -0700 Subject: [PATCH 2/2] Migrate test_blob_client to test proxy --- ...nttest_request_callback_signed_header.json | 93 ++++ ...stStorageClienttest_response_callback.json | 36 ++ ...stStorageClienttest_user_agent_append.json | 31 ++ ...stStorageClienttest_user_agent_custom.json | 57 ++ ...tStorageClienttest_user_agent_default.json | 31 ++ ...t.test_request_callback_signed_header.yaml | 126 ----- ...st_blob_client.test_response_callback.yaml | 39 -- ...st_blob_client.test_user_agent_append.yaml | 38 -- ...st_blob_client.test_user_agent_custom.yaml | 72 --- ...t_blob_client.test_user_agent_default.yaml | 37 -- ...nctest_request_callback_signed_header.json | 90 +++ ...rageClientAsynctest_response_callback.json | 35 ++ ...rageClientAsynctest_user_agent_append.json | 30 + ...rageClientAsynctest_user_agent_custom.json | 55 ++ ...ageClientAsynctest_user_agent_default.json | 30 + ..._request_callback_signed_header_async.yaml | 105 ---- ...nt_async.test_response_callback_async.yaml | 35 -- ...nt_async.test_user_agent_append_async.yaml | 37 -- ...nt_async.test_user_agent_custom_async.yaml | 70 --- ...t_async.test_user_agent_default_async.yaml | 36 -- .../tests/test_blob_client.py | 527 ++++++++++-------- .../tests/test_blob_client_async.py | 495 +++++++++------- 22 files changed, 1077 insertions(+), 1028 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_request_callback_signed_header.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_response_callback.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_append.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_custom.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_default.json delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_request_callback_signed_header.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_response_callback.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_append.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_custom.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_default.yaml create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_request_callback_signed_header.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_response_callback.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_append.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_custom.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_default.json delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_request_callback_signed_header_async.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_response_callback_async.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_append_async.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_custom_async.yaml delete mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_default_async.yaml diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_request_callback_signed_header.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_request_callback_signed_header.json new file mode 100644 index 000000000000..20d911654658 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_request_callback_signed_header.json @@ -0,0 +1,93 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/contdfad2e0d?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:44 GMT", + "x-ms-meta-hello": "world", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 19:18:45 GMT", + "ETag": "\u00220x8DA68F255AD82C1\u0022", + "Last-Modified": "Mon, 18 Jul 2022 19:18:45 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/contdfad2e0d?restype=container", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:45 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 19:18:45 GMT", + "ETag": "\u00220x8DA68F255AD82C1\u0022", + "Last-Modified": "Mon, 18 Jul 2022 19:18:45 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-default-encryption-scope": "$account-encryption-key", + "x-ms-deny-encryption-scope-override": "false", + "x-ms-has-immutability-policy": "false", + "x-ms-has-legal-hold": "false", + "x-ms-immutable-storage-with-versioning-enabled": "false", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-hello": "world", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/contdfad2e0d?restype=container", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:45 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 19:18:45 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_response_callback.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_response_callback.json new file mode 100644 index 000000000000..92f62f7ca754 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_response_callback.json @@ -0,0 +1,36 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/cont9e4f28d2?restype=container", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:46 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Content-Length": "225", + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 19:18:46 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-error-code": "ContainerNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": [ + "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CError\u003E\u003CCode\u003EContainerNotFound\u003C/Code\u003E\u003CMessage\u003EThe specified container does not exist.\n", + "RequestId:0e9460ba-a01e-0070-38db-9a6335000000\n", + "Time:2022-07-18T19:18:46.3890394Z\u003C/Message\u003E\u003C/Error\u003E" + ] + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_append.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_append.json new file mode 100644 index 000000000000..12c258cd2038 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_append.json @@ -0,0 +1,31 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "customer_user_agent azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:48 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 19:18:48 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_custom.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_custom.json new file mode 100644 index 000000000000..5c01978b1fb8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_custom.json @@ -0,0 +1,57 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "TestApp/v1.0 azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:48 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 19:18:48 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:48 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 19:18:48 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_default.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_default.json new file mode 100644 index 000000000000..cdb5f2d048b8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.pyTestStorageClienttest_user_agent_default.json @@ -0,0 +1,31 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 19:18:47 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 19:18:47 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_request_callback_signed_header.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_request_callback_signed_header.yaml deleted file mode 100644 index a2d221af60f1..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_request_callback_signed_header.yaml +++ /dev/null @@ -1,126 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:06 GMT - x-ms-meta-hello: - - world - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/cont32941520?restype=container - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 25 Oct 2019 17:34:06 GMT - etag: - - '"0x8D759718969BAE1"' - last-modified: - - Fri, 25 Oct 2019 17:34:06 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-version: - - '2019-02-02' - status: - code: 201 - message: Created -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/cont32941520?restype=container - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 25 Oct 2019 17:34:06 GMT - etag: - - '"0x8D759718969BAE1"' - last-modified: - - Fri, 25 Oct 2019 17:34:06 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-default-encryption-scope: - - $account-encryption-key - x-ms-deny-encryption-scope-override: - - 'false' - x-ms-has-immutability-policy: - - 'false' - x-ms-has-legal-hold: - - 'false' - x-ms-lease-state: - - available - x-ms-lease-status: - - unlocked - x-ms-meta-hello: - - world - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: DELETE - uri: https://storagename.blob.core.windows.net/cont32941520?restype=container - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Fri, 25 Oct 2019 17:34:06 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-version: - - '2019-02-02' - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_response_callback.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_response_callback.yaml deleted file mode 100644 index 9a84e650631c..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_response_callback.yaml +++ /dev/null @@ -1,39 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/cont3f420fe5?restype=container - response: - body: - string: "\uFEFFContainerNotFoundThe - specified container does not exist.\nRequestId:6e53c47c-501e-00c1-545a-8bdf6d000000\nTime:2019-10-25T17:34:07.1155022Z" - headers: - content-length: - - '225' - content-type: - - application/xml - date: - - Fri, 25 Oct 2019 17:34:06 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-error-code: - - ContainerNotFound - x-ms-version: - - '2019-02-02' - status: - code: 404 - message: The specified container does not exist. -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_append.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_append.yaml deleted file mode 100644 index ea026c229ebf..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_append.yaml +++ /dev/null @@ -1,38 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - customer_user_agent - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: - - application/xml - date: - - Fri, 25 Oct 2019 17:34:07 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_custom.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_custom.yaml deleted file mode 100644 index 35b053702dc1..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_custom.yaml +++ /dev/null @@ -1,72 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - TestApp/v1.0 azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: - - application/xml - date: - - Fri, 25 Oct 2019 17:34:07 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - TestApp/v2.0 azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: - - application/xml - date: - - Fri, 25 Oct 2019 17:34:07 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_default.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_default.yaml deleted file mode 100644 index 31a85a76ac8b..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client.test_user_agent_default.yaml +++ /dev/null @@ -1,37 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:34:07 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: - - application/xml - date: - - Fri, 25 Oct 2019 17:34:07 GMT - server: - - Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: - - chunked - x-ms-version: - - '2019-02-02' - status: - code: 200 - message: OK -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_request_callback_signed_header.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_request_callback_signed_header.json new file mode 100644 index 000000000000..777d0fd970a4 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_request_callback_signed_header.json @@ -0,0 +1,90 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/cont5a03288?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:33 GMT", + "x-ms-meta-hello": "world", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 20:13:33 GMT", + "ETag": "\u00220x8DA68F9FDA447EC\u0022", + "Last-Modified": "Mon, 18 Jul 2022 20:13:33 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/cont5a03288?restype=container", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:33 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 20:13:33 GMT", + "ETag": "\u00220x8DA68F9FDA447EC\u0022", + "Last-Modified": "Mon, 18 Jul 2022 20:13:33 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-default-encryption-scope": "$account-encryption-key", + "x-ms-deny-encryption-scope-override": "false", + "x-ms-has-immutability-policy": "false", + "x-ms-has-legal-hold": "false", + "x-ms-immutable-storage-with-versioning-enabled": "false", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-hello": "world", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/cont5a03288?restype=container", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:33 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Mon, 18 Jul 2022 20:13:33 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_response_callback.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_response_callback.json new file mode 100644 index 000000000000..a25f1ce4cd5d --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_response_callback.json @@ -0,0 +1,35 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/cont89f42d4d?restype=container", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:34 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Content-Length": "225", + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 20:13:33 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-error-code": "ContainerNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": [ + "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CError\u003E\u003CCode\u003EContainerNotFound\u003C/Code\u003E\u003CMessage\u003EThe specified container does not exist.\n", + "RequestId:f6a7c955-701e-0001-5ae2-9a851e000000\n", + "Time:2022-07-18T20:13:34.7088668Z\u003C/Message\u003E\u003C/Error\u003E" + ] + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_append.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_append.json new file mode 100644 index 000000000000..21afef00e5e7 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_append.json @@ -0,0 +1,30 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "customer_user_agent azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:36 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 20:13:35 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_custom.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_custom.json new file mode 100644 index 000000000000..8f4a6e94253b --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_custom.json @@ -0,0 +1,55 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "TestApp/v1.0 azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:35 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 20:13:34 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:35 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 20:13:35 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_default.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_default.json new file mode 100644 index 000000000000..f2b190fa4c53 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.pyTestStorageClientAsynctest_user_agent_default.json @@ -0,0 +1,30 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/?restype=service\u0026comp=properties", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "User-Agent": "azsdk-python-storage-blob/12.14.0b1 Python/3.10.5 (Windows-10-10.0.22000-SP0)", + "x-ms-date": "Mon, 18 Jul 2022 20:13:35 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Content-Type": "application/xml", + "Date": "Mon, 18 Jul 2022 20:13:34 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CStorageServiceProperties\u003E\u003CLogging\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CRead\u003Etrue\u003C/Read\u003E\u003CWrite\u003Etrue\u003C/Write\u003E\u003CDelete\u003Etrue\u003C/Delete\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/Logging\u003E\u003CHourMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/HourMetrics\u003E\u003CMinuteMetrics\u003E\u003CVersion\u003E1.0\u003C/Version\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CIncludeAPIs\u003Etrue\u003C/IncludeAPIs\u003E\u003CRetentionPolicy\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CDays\u003E5\u003C/Days\u003E\u003C/RetentionPolicy\u003E\u003C/MinuteMetrics\u003E\u003CCors\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders /\u003E\u003CExposedHeaders /\u003E\u003CMaxAgeInSeconds\u003E0\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003CCorsRule\u003E\u003CAllowedMethods\u003EGET,PUT\u003C/AllowedMethods\u003E\u003CAllowedOrigins\u003Ewww.xyz.com,www.ab.com,www.bc.com\u003C/AllowedOrigins\u003E\u003CAllowedHeaders\u003Ex-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*\u003C/AllowedHeaders\u003E\u003CExposedHeaders\u003Ex-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*\u003C/ExposedHeaders\u003E\u003CMaxAgeInSeconds\u003E500\u003C/MaxAgeInSeconds\u003E\u003C/CorsRule\u003E\u003C/Cors\u003E\u003CDeleteRetentionPolicy\u003E\u003CEnabled\u003Efalse\u003C/Enabled\u003E\u003CAllowPermanentDelete\u003Efalse\u003C/AllowPermanentDelete\u003E\u003C/DeleteRetentionPolicy\u003E\u003CStaticWebsite\u003E\u003CEnabled\u003Etrue\u003C/Enabled\u003E\u003CErrorDocument404Path\u003Eerrors/error/404error.html\u003C/ErrorDocument404Path\u003E\u003CDefaultIndexDocumentPath\u003Eindex.html\u003C/DefaultIndexDocumentPath\u003E\u003C/StaticWebsite\u003E\u003CDefaultServiceVersion\u003E2014-02-14\u003C/DefaultServiceVersion\u003E\u003C/StorageServiceProperties\u003E" + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_request_callback_signed_header_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_request_callback_signed_header_async.yaml deleted file mode 100644 index dfa728db5f23..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_request_callback_signed_header_async.yaml +++ /dev/null @@ -1,105 +0,0 @@ -interactions: -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-meta-hello: - - world - x-ms-version: - - '2019-02-02' - method: PUT - uri: https://storagename.blob.core.windows.net/cont52bd1a1a?restype=container - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 25 Oct 2019 17:29:22 GMT - etag: '"0x8D75970E040E6F0"' - last-modified: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-version: '2019-02-02' - status: - code: 201 - message: Created - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - /cont52bd1a1a - - restype=container - - '' -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/cont52bd1a1a?restype=container - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 25 Oct 2019 17:29:22 GMT - etag: '"0x8D75970E040E6F0"' - last-modified: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-default-encryption-scope: $account-encryption-key - x-ms-deny-encryption-scope-override: 'false' - x-ms-has-immutability-policy: 'false' - x-ms-has-legal-hold: 'false' - x-ms-lease-state: available - x-ms-lease-status: unlocked - x-ms-meta-hello: world - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - /cont52bd1a1a - - restype=container - - '' -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: DELETE - uri: https://storagename.blob.core.windows.net/cont52bd1a1a?restype=container - response: - body: - string: '' - headers: - content-length: '0' - date: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-version: '2019-02-02' - status: - code: 202 - message: Accepted - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - /cont52bd1a1a - - restype=container - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_response_callback_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_response_callback_async.yaml deleted file mode 100644 index 9266935bfbe6..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_response_callback_async.yaml +++ /dev/null @@ -1,35 +0,0 @@ -interactions: -- request: - body: null - headers: - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/cont1fb014df?restype=container - response: - body: - string: "\uFEFFContainerNotFoundThe - specified container does not exist.\nRequestId:91515f9a-001e-004f-2759-8b2010000000\nTime:2019-10-25T17:29:23.2694987Z" - headers: - content-length: '225' - content-type: application/xml - date: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - x-ms-error-code: ContainerNotFound - x-ms-version: '2019-02-02' - status: - code: 404 - message: The specified container does not exist. - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - /cont1fb014df - - restype=container - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_append_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_append_async.yaml deleted file mode 100644 index 3da0bc01d488..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_append_async.yaml +++ /dev/null @@ -1,37 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - customer_user_agent - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: application/xml - date: Fri, 25 Oct 2019 17:29:23 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - / - - restype=service&comp=properties - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_custom_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_custom_async.yaml deleted file mode 100644 index 6eaf447ba06b..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_custom_async.yaml +++ /dev/null @@ -1,70 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - TestApp/v1.0 azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: application/xml - date: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - / - - restype=service&comp=properties - - '' -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - TestApp/v2.0 azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: application/xml - date: Fri, 25 Oct 2019 17:29:22 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - / - - restype=service&comp=properties - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_default_async.yaml b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_default_async.yaml deleted file mode 100644 index 5438daee85f4..000000000000 --- a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_client_async.test_user_agent_default_async.yaml +++ /dev/null @@ -1,36 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - application/xml - User-Agent: - - azsdk-python-storage-blob/12.0.0b5 Python/3.6.3 (Windows-10-10.0.18362-SP0) - x-ms-date: - - Fri, 25 Oct 2019 17:29:23 GMT - x-ms-version: - - '2019-02-02' - method: GET - uri: https://storagename.blob.core.windows.net/?restype=service&comp=properties - response: - body: - string: "\uFEFF1.0falsefalsefalsefalse1.0truetruetrue71.0falsefalsefalsefalse" - headers: - content-type: application/xml - date: Fri, 25 Oct 2019 17:29:23 GMT - server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0 - transfer-encoding: chunked - x-ms-version: '2019-02-02' - status: - code: 200 - message: OK - url: !!python/object/new:yarl.URL - state: !!python/tuple - - !!python/object/new:urllib.parse.SplitResult - - https - - pyacrstoragewyfgujwhjbod.blob.core.windows.net - - / - - restype=service&comp=properties - - '' -version: 1 diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_client.py b/sdk/storage/azure-storage-blob/tests/test_blob_client.py index 7cfeeec8ab9a..46cde4d0b680 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_client.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_client.py @@ -3,54 +3,66 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import unittest -import pytest + import platform +from datetime import datetime, timedelta +import pytest from azure.core.credentials import AzureSasCredential from azure.core.exceptions import AzureError from azure.storage.blob import ( - VERSION, + AccountSasPermissions, + BlobClient, BlobServiceClient, ContainerClient, - BlobClient, + generate_account_sas, + ResourceTypes, + VERSION, ) -from devtools_testutils import ResourceGroupPreparer, StorageAccountPreparer + +from devtools_testutils import recorded_by_proxy +from devtools_testutils.storage import StorageRecordedTestCase from settings.testcase import BlobPreparer -from devtools_testutils.storage import StorageTestCase -# ------------------------------------------------------------------------------ SERVICES = { BlobServiceClient: 'blob', ContainerClient: 'blob', BlobClient: 'blob', } - _CONNECTION_ENDPOINTS = {'blob': 'BlobEndpoint'} - _CONNECTION_ENDPOINTS_SECONDARY = {'blob': 'BlobSecondaryEndpoint'} -class StorageClientTest(StorageTestCase): - def setUp(self): - super(StorageClientTest, self).setUp() - self.sas_token = self.generate_sas_token() - self.token_credential = self.generate_oauth_token() +class TestStorageClient(StorageRecordedTestCase): # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, url_type, name, storage_account_key): - self.assertIsNotNone(service) - self.assertEqual(service.account_name, name) - self.assertEqual(service.credential.account_name, name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue('{}.{}.core.windows.net'.format(name, url_type) in service.url) - self.assertTrue('{}-secondary.{}.core.windows.net'.format(name, url_type) in service.secondary_endpoint) + assert service is not None + assert service.account_name == name + assert service.credential.account_name == name + assert service.credential.account_key == storage_account_key + assert '{}.{}.core.windows.net'.format(name, url_type) in service.url + assert '{}-secondary.{}.core.windows.net'.format(name, url_type) in service.secondary_endpoint + + def generate_fake_sas_token(self): + fake_key = "a" * 30 + "b" * 30 + + return "?" + generate_account_sas( + account_name="test", # name of the storage account + account_key=fake_key, # key for the storage account + resource_types=ResourceTypes(object=True), + permission=AccountSasPermissions(read=True, list=True), + start=datetime.now() - timedelta(hours=24), + expiry=datetime.now() + timedelta(days=8), + ) # --Direct Parameters Test Cases -------------------------------------------- @BlobPreparer() - def test_create_service_with_key(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_with_key(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items(): # Act service = client( @@ -58,23 +70,27 @@ def test_create_service_with_key(self, storage_account_name, storage_account_key # Assert self.validate_standard_account_endpoints(service, url, storage_account_name, storage_account_key) - - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_blob_client_with_complete_blob_url(self, storage_account_name, storage_account_key): + def test_create_blob_client_with_complete_blob_url(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange blob_url = self.account_url(storage_account_name, "blob") + "/foourl/barurl" service = BlobClient(blob_url, credential=storage_account_key, container_name='foo', blob_name='bar') - # Assert - self.assertEqual(service.scheme, 'https') - self.assertEqual(service.container_name, 'foo') - self.assertEqual(service.blob_name, 'bar') - self.assertEqual(service.account_name, storage_account_name) + # Assert + assert service.scheme == 'https' + assert service.container_name == 'foo' + assert service.blob_name == 'bar' + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_service_with_connection_string(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") for service_type in SERVICES.items(): # Act @@ -83,28 +99,33 @@ def test_create_service_with_connection_string(self, storage_account_name, stora # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_service_with_sas(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_with_sas(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange + sas_token = self.generate_fake_sas_token() for service_type in SERVICES: # Act service = service_type( - self.account_url(storage_account_name, "blob"), credential=self.sas_token, container_name='foo', blob_name='bar') + self.account_url(storage_account_name, "blob"), credential=sas_token, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertTrue(service.url.endswith(self.sas_token)) - self.assertIsNone(service.credential) + assert service is not None + assert service.account_name == storage_account_name + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.url.endswith(sas_token) + assert service.credential is None @BlobPreparer() - def test_create_service_with_sas_credential(self, storage_account_name, storage_account_key): + def test_create_service_with_sas_credential(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - sas_credential = AzureSasCredential(self.sas_token) + sas_token = self.generate_fake_sas_token() + sas_credential = AzureSasCredential(sas_token) for service_type in SERVICES: # Act @@ -112,48 +133,59 @@ def test_create_service_with_sas_credential(self, storage_account_name, storage_ self.account_url(storage_account_name, "blob"), credential=sas_credential, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertFalse(service.url.endswith(self.sas_token)) - self.assertEqual(service.credential, sas_credential) + assert service is not None + assert service.account_name == storage_account_name + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert not service.url.endswith(sas_token) + assert service.credential == sas_credential @BlobPreparer() - def test_create_service_with_sas_credential_url_raises_if_sas_is_in_uri(self, storage_account_name, storage_account_key): + def test_create_service_with_sas_credential_url_raises_if_sas_is_in_uri(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - sas_credential = AzureSasCredential(self.sas_token) + sas_token = self.generate_fake_sas_token() + sas_credential = AzureSasCredential(sas_token) for service_type in SERVICES: # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type( self.account_url(storage_account_name, "blob") + "?sig=foo", credential=sas_credential, container_name='foo', blob_name='bar') @BlobPreparer() - def test_create_service_with_token(self, storage_account_name, storage_account_key): + def test_create_service_with_token(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + + token_credential = self.generate_oauth_token() for service_type in SERVICES: # Act service = service_type( - self.account_url(storage_account_name, "blob"), credential=self.token_credential, container_name='foo', blob_name='bar') + self.account_url(storage_account_name, "blob"), credential=token_credential, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertEqual(service.credential, self.token_credential) - self.assertEqual(service.account_name, storage_account_name) + assert service is not None + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.credential == token_credential + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_service_with_token_and_http(self, storage_account_name, storage_account_key): + def test_create_service_with_token_and_http(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + + token_credential = self.generate_oauth_token() for service_type in SERVICES: # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): url = self.account_url(storage_account_name, "blob").replace('https', 'http') - service_type(url, credential=self.token_credential, container_name='foo', blob_name='bar') + service_type(url, credential=token_credential, container_name='foo', blob_name='bar') @BlobPreparer() - def test_create_service_china(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_china(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): # Act url = self.account_url(storage_account_name, "blob").replace('core.windows.net', 'core.chinacloudapi.cn') @@ -161,19 +193,21 @@ def test_create_service_china(self, storage_account_name, storage_account_key): url, credential=storage_account_key, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith( - 'https://{}.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) - self.assertTrue(service.secondary_endpoint.startswith( - 'https://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith( + 'https://{}.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) + assert service.secondary_endpoint.startswith( + 'https://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) @BlobPreparer() - def test_create_service_protocol(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_protocol(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): # Act url = self.account_url(storage_account_name, "blob").replace('https', 'http') @@ -182,10 +216,12 @@ def test_create_service_protocol(self, storage_account_name, storage_account_key # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'http') + assert service.scheme == 'http' @BlobPreparer() - def test_create_blob_service_anonymous(self, storage_account_name, storage_account_key): + def test_create_blob_service_anonymous(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange BLOB_SERVICES = [BlobServiceClient, ContainerClient, BlobClient] @@ -194,13 +230,16 @@ def test_create_blob_service_anonymous(self, storage_account_name, storage_accou service = service_type(self.account_url(storage_account_name, "blob"), container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertIsNone(service.credential) + assert service is not None + assert service.account_name == storage_account_name + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.credential is None @BlobPreparer() - def test_create_blob_service_custom_domain(self, storage_account_name, storage_account_key): + def test_create_blob_service_custom_domain(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange BLOB_SERVICES = [BlobServiceClient, ContainerClient, BlobClient] @@ -213,15 +252,18 @@ def test_create_blob_service_custom_domain(self, storage_account_name, storage_a blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_create_service_with_socket_timeout(self, storage_account_name, storage_account_key): + def test_create_service_with_socket_timeout(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): @@ -241,7 +283,10 @@ def test_create_service_with_socket_timeout(self, storage_account_name, storage_ # --Connection String Test Cases -------------------------------------------- @BlobPreparer() - def test_create_service_with_connection_string_key(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_key(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange conn_string = 'AccountName={};AccountKey={};'.format(storage_account_name, storage_account_key) @@ -252,12 +297,15 @@ def test_create_service_with_connection_string_key(self, storage_account_name, s # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_service_with_connection_string_sas(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_sas(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - conn_string = 'AccountName={};SharedAccessSignature={};'.format(storage_account_name, self.sas_token) + sas_token = self.generate_fake_sas_token() + conn_string = 'AccountName={};SharedAccessSignature={};'.format(storage_account_name, sas_token) for service_type in SERVICES: # Act @@ -265,14 +313,17 @@ def test_create_service_with_connection_string_sas(self, storage_account_name, s conn_string, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertTrue(service.url.endswith(self.sas_token)) - self.assertIsNone(service.credential) - self.assertEqual(service.account_name, storage_account_name) + assert service is not None + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.url.endswith(sas_token) + assert service.credential is None + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_service_with_connection_string_endpoint_protocol(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_endpoint_protocol(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( storage_account_name, storage_account_key) @@ -282,30 +333,31 @@ def test_create_service_with_connection_string_endpoint_protocol(self, storage_a service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue( - service.primary_endpoint.startswith( - 'http://{}.{}.core.chinacloudapi.cn/'.format(storage_account_name, service_type[1]))) - self.assertTrue( - service.secondary_endpoint.startswith( - 'http://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) - self.assertEqual(service.scheme, 'http') + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith( + 'http://{}.{}.core.chinacloudapi.cn/'.format(storage_account_name, service_type[1])) + assert service.secondary_endpoint.startswith( + 'http://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) + assert service.scheme == 'http' @BlobPreparer() - def test_create_service_with_connection_string_emulated(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_emulated(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'UseDevelopmentStorage=true;'.format(storage_account_name, storage_account_key) # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") @BlobPreparer() - def test_create_service_with_cstr_anonymous(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_anonymous(self): # Arrange for service_type in SERVICES.items(): conn_string = 'BlobEndpoint=www.mydomain.com;' @@ -314,15 +366,18 @@ def test_create_service_with_cstr_anonymous(self, storage_account_name, storage_ service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, None) - self.assertIsNone(service.credential) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - with self.assertRaises(ValueError): + assert service is not None + assert service.account_name == None + assert service.credential is None + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + with pytest.raises(ValueError): service.secondary_endpoint @BlobPreparer() - def test_create_service_with_cstr_custom_domain(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_custom_domain(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com;'.format( @@ -332,15 +387,18 @@ def test_create_service_with_cstr_custom_domain(self, storage_account_name, stor service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_create_service_with_cstr_cust_dmn_trailing_slash(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_cust_dmn_trailing_slash(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com/;'.format( @@ -350,15 +408,18 @@ def test_create_service_with_cstr_cust_dmn_trailing_slash(self, storage_account_ service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_create_service_with_cstr_custom_domain_sec_override(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_custom_domain_sec_override(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com/;'.format( @@ -369,15 +430,18 @@ def test_create_service_with_cstr_custom_domain_sec_override(self, storage_accou conn_string, secondary_hostname="www-sec.mydomain.com", container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://www-sec.mydomain.com/')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://www-sec.mydomain.com/') @BlobPreparer() - def test_create_service_with_cstr_fails_if_sec_without_prim(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_fails_if_sec_without_prim(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( @@ -387,11 +451,14 @@ def test_create_service_with_cstr_fails_if_sec_without_prim(self, storage_accoun # Act # Fails if primary excluded - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") @BlobPreparer() - def test_create_service_with_cstr_succeeds_if_sec_with_prim(self, storage_account_name, storage_account_key): + def test_create_service_with_cstr_succeeds_if_sec_with_prim(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( @@ -404,18 +471,18 @@ def test_create_service_with_cstr_succeeds_if_sec_with_prim(self, storage_accoun service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://www-sec.mydomain.com/')) - + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://www-sec.mydomain.com/') def test_create_service_with_custom_account_endpoint_path(self): account_name = "blobstorage" account_key = "blobkey" - custom_account_url = "http://local-machine:11002/custom/account/path/" + self.sas_token + sas_token = self.generate_fake_sas_token() + custom_account_url = "http://local-machine:11002/custom/account/path/" + sas_token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};BlobEndpoint={};'.format( account_name, account_key, custom_account_url) @@ -425,60 +492,60 @@ def test_create_service_with_custom_account_endpoint_path(self): conn_string, container_name="foo", blob_name="bar") # Assert - self.assertEqual(service.account_name, account_name) - self.assertEqual(service.credential.account_name, account_name) - self.assertEqual(service.credential.account_key, account_key) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') + assert service.account_name == account_name + assert service.credential.account_name == account_name + assert service.credential.account_key == account_key + assert service.primary_hostname == 'local-machine:11002/custom/account/path' service = BlobServiceClient(account_url=custom_account_url) - self.assertEqual(service.account_name, None) - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/?')) + assert service.account_name == None + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/?') service = ContainerClient(account_url=custom_account_url, container_name="foo") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/foo?')) + assert service.account_name == None + assert service.container_name == "foo" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/foo?') service = ContainerClient.from_container_url("http://local-machine:11002/custom/account/path/foo?query=value") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertEqual(service.url, 'http://local-machine:11002/custom/account/path/foo') + assert service.account_name == None + assert service.container_name == "foo" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url == 'http://local-machine:11002/custom/account/path/foo' service = BlobClient(account_url=custom_account_url, container_name="foo", blob_name="bar", snapshot="baz") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.blob_name, "bar") - self.assertEqual(service.snapshot, "baz") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&')) + assert service.account_name == None + assert service.container_name == "foo" + assert service.blob_name == "bar" + assert service.snapshot == "baz" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&') service = BlobClient.from_blob_url("http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&query=value") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.blob_name, "bar") - self.assertEqual(service.snapshot, "baz") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertEqual(service.url, 'http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz') + assert service.account_name == None + assert service.container_name == "foo" + assert service.blob_name == "bar" + assert service.snapshot == "baz" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url == 'http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz' def test_create_blob_client_with_sub_directory_path_in_blob_name(self): blob_url = "https://testaccount.blob.core.windows.net/containername/dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" blob_client = BlobClient.from_blob_url(blob_url) - self.assertEqual(blob_client.container_name, "containername") - self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg") + assert blob_client.container_name == "containername" + assert blob_client.blob_name == "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" blob_emulator_url = 'http://127.0.0.1:1000/devstoreaccount1/containername/dir1/sub000/2010_Unit150_Ivan097_img0003.jpg' blob_client = BlobClient.from_blob_url(blob_emulator_url) - self.assertEqual(blob_client.container_name, "containername") - self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg") - self.assertEqual(blob_client.url, blob_emulator_url) + assert blob_client.container_name == "containername" + assert blob_client.blob_name == "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" + assert blob_client.url == blob_emulator_url def test_from_blob_url_too_short_url(self): """Test that a useful error message is obtained if user gives incorrect URL""" @@ -492,16 +559,20 @@ def test_create_client_for_emulator(self): container_name='newcontainer', credential='Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==') - self.assertEqual(container_client.container_name, "newcontainer") - self.assertEqual(container_client.account_name, "devstoreaccount1") + assert container_client.container_name == "newcontainer" + assert container_client.account_name == "devstoreaccount1" ContainerClient.from_container_url('http://127.0.0.1:1000/devstoreaccount1/newcontainer') - self.assertEqual(container_client.container_name, "newcontainer") - self.assertEqual(container_client.account_name, "devstoreaccount1") + assert container_client.container_name == "newcontainer" + assert container_client.account_name == "devstoreaccount1" @BlobPreparer() - def test_request_callback_signed_header(self, storage_account_name, storage_account_key): + @recorded_by_proxy + def test_request_callback_signed_header(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) name = self.get_resource_name('cont') @@ -515,12 +586,16 @@ def callback(request): try: container = service.create_container(name, raw_request_hook=callback) metadata = container.get_container_properties().metadata - self.assertEqual(metadata, {'hello': 'world'}) + assert metadata == {'hello': 'world'} finally: service.delete_container(name) @BlobPreparer() - def test_response_callback(self, storage_account_name, storage_account_key): + @recorded_by_proxy + def test_response_callback(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) name = self.get_resource_name('cont') @@ -533,53 +608,34 @@ def callback(response): # Assert exists = container.get_container_properties(raw_response_hook=callback) - self.assertTrue(exists) + assert exists - @pytest.mark.live_test_only @BlobPreparer() - def test_client_request_id_echo(self, storage_account_name, storage_account_key): - # client request id is different for every request, so it will never match the recorded one - pytest.skip("Issue tracked here: https://github.com/Azure/azure-sdk-for-python/issues/8098") + @recorded_by_proxy + def test_user_agent_default(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") - # Arrange - request_id_header_name = 'x-ms-client-request-id' service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) - # Act make the client request ID slightly different def callback(response): - response.http_response.status_code = 200 - response.http_response.headers[request_id_header_name] += '1' - - # Assert the client request ID validation is working - with self.assertRaises(AzureError): - service.get_service_properties(raw_response_hook=callback) - - # Act remove the echoed client request ID - def callback(response): - response.status_code = 200 - del response.http_response.headers[request_id_header_name] - - # Assert the client request ID validation is not throwing when the ID is not echoed - service.get_service_properties(raw_response_hook=callback) - - @BlobPreparer() - def test_user_agent_default(self, storage_account_name, storage_account_key): - service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) - - def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert "azsdk-python-storage-blob/{}".format(VERSION) in response.http_request.headers['User-Agent'] service.get_service_properties(raw_response_hook=callback) @BlobPreparer() - def test_user_agent_custom(self, storage_account_name, storage_account_key): + @recorded_by_proxy + def test_user_agent_custom(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + custom_app = "TestApp/v1.0" service = BlobServiceClient( self.account_url(storage_account_name, "blob"), credential=storage_account_key, user_agent=custom_app) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -588,7 +644,7 @@ def callback(response): service.get_service_properties(raw_response_hook=callback) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -597,11 +653,15 @@ def callback(response): service.get_service_properties(raw_response_hook=callback, user_agent="TestApp/v2.0") @BlobPreparer() - def test_user_agent_append(self, storage_account_name, storage_account_key): + @recorded_by_proxy + def test_user_agent_append(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("customer_user_agent azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -609,23 +669,25 @@ def callback(response): service.get_service_properties(raw_response_hook=callback, user_agent='customer_user_agent') + @BlobPreparer() def test_error_with_malformed_conn_str(self): # Arrange for conn_str in ["", "foobar", "foo;bar;baz", ";", "foobar=baz=foo" , "foo=;bar=;", "=", "=;=="]: for service_type in SERVICES.items(): # Act - with self.assertRaises(ValueError) as e: + with pytest.raises(ValueError) as e: service = service_type[0].from_connection_string(conn_str, blob_name="test", container_name="foo/bar") if conn_str in("", "foobar", "foo;bar;baz", ";"): - self.assertEqual( - str(e.exception), "Connection string is either blank or malformed.") + assert str(e.value) == "Connection string is either blank or malformed." elif conn_str in ("foobar=baz=foo" , "foo=;bar=;", "=", "=;=="): - self.assertEqual( - str(e.exception), "Connection string missing required connection details.") + assert str(e.value) == "Connection string missing required connection details." @BlobPreparer() - def test_closing_pipeline_client(self, storage_account_name, storage_account_key): + def test_closing_pipeline_client(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items(): # Act @@ -638,7 +700,10 @@ def test_closing_pipeline_client(self, storage_account_name, storage_account_key service.close() @BlobPreparer() - def test_closing_pipeline_client_simple(self, storage_account_name, storage_account_key): + def test_closing_pipeline_client_simple(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items(): # Act diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_client_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_client_async.py index 28bdda1e4f3d..8a55f1bb9673 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_client_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_client_async.py @@ -3,53 +3,67 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -import unittest -import pytest + import platform -import asyncio +from datetime import datetime, timedelta +import pytest from azure.core.credentials import AzureSasCredential -from azure.storage.blob import VERSION +from azure.storage.blob import ( + AccountSasPermissions, + generate_account_sas, + ResourceTypes, + VERSION, +) from azure.storage.blob.aio import ( - BlobServiceClient, - ContainerClient, BlobClient, + ContainerClient, + BlobServiceClient ) + +from devtools_testutils.aio import recorded_by_proxy_async +from devtools_testutils.storage.aio import AsyncStorageRecordedTestCase from settings.testcase import BlobPreparer -from devtools_testutils.storage.aio import AsyncStorageTestCase -# ------------------------------------------------------------------------------ SERVICES = { BlobServiceClient: 'blob', ContainerClient: 'blob', BlobClient: 'blob', } - _CONNECTION_ENDPOINTS = {'blob': 'BlobEndpoint'} - _CONNECTION_ENDPOINTS_SECONDARY = {'blob': 'BlobSecondaryEndpoint'} -class StorageClientTestAsync(AsyncStorageTestCase): - def setUp(self): - super(StorageClientTestAsync, self).setUp() - self.sas_token = self.generate_sas_token() - self.token_credential = self.generate_oauth_token() +class TestStorageClientAsync(AsyncStorageRecordedTestCase): # --Helpers----------------------------------------------------------------- def validate_standard_account_endpoints(self, service, url_type, account_name, account_key): - self.assertIsNotNone(service) - self.assertEqual(service.account_name, account_name) - self.assertEqual(service.credential.account_name, account_name) - self.assertEqual(service.credential.account_key, account_key) - self.assertTrue('{}.{}.core.windows.net'.format(account_name, url_type) in service.url) - self.assertTrue('{}-secondary.{}.core.windows.net'.format(account_name, url_type) in service.secondary_endpoint) + assert service is not None + assert service.account_name == account_name + assert service.credential.account_name == account_name + assert service.credential.account_key == account_key + assert '{}.{}.core.windows.net'.format(account_name, url_type) in service.url + assert '{}-secondary.{}.core.windows.net'.format(account_name, url_type) in service.secondary_endpoint + + def generate_fake_sas_token(self): + fake_key = "a" * 30 + "b" * 30 + + return "?" + generate_account_sas( + account_name="test", # name of the storage account + account_key=fake_key, # key for the storage account + resource_types=ResourceTypes(object=True), + permission=AccountSasPermissions(read=True, list=True), + start=datetime.now() - timedelta(hours=24), + expiry=datetime.now() + timedelta(days=8), + ) # --Direct Parameters Test Cases -------------------------------------------- @BlobPreparer() - def test_create_service_with_key_async(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_with_key(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items(): # Act service = client( @@ -57,10 +71,13 @@ def test_create_service_with_key_async(self, storage_account_name, storage_accou # Assert self.validate_standard_account_endpoints(service, url, storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_service_with_connection_string_async(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + for service_type in SERVICES.items(): # Act @@ -69,28 +86,33 @@ def test_create_service_with_connection_string_async(self, storage_account_name, # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_service_with_sas_async(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_with_sas(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange + sas_token = self.generate_fake_sas_token() for service_type in SERVICES: # Act service = service_type( - self.account_url(storage_account_name, "blob"), credential=self.sas_token, container_name='foo', blob_name='bar') + self.account_url(storage_account_name, "blob"), credential=sas_token, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertTrue(service.url.endswith(self.sas_token)) - self.assertIsNone(service.credential) + assert service is not None + assert service.account_name == storage_account_name + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.url.endswith(sas_token) + assert service.credential is None @BlobPreparer() - def test_create_service_with_sas_credential_async(self, storage_account_name, storage_account_key): + def test_create_service_with_sas_credential(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - sas_credential = AzureSasCredential(self.sas_token) + sas_token = self.generate_fake_sas_token() + sas_credential = AzureSasCredential(sas_token) for service_type in SERVICES: # Act @@ -98,48 +120,59 @@ def test_create_service_with_sas_credential_async(self, storage_account_name, st self.account_url(storage_account_name, "blob"), credential=sas_credential, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertFalse(service.url.endswith(self.sas_token)) - self.assertEqual(service.credential, sas_credential) + assert service is not None + assert service.account_name == storage_account_name + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert not service.url.endswith(sas_token) + assert service.credential == sas_credential @BlobPreparer() - def test_create_service_with_sas_credential_url_raises_if_sas_is_in_uri_async(self, storage_account_name, storage_account_key): + def test_create_service_with_sas_credential_url_raises_if_sas_is_in_uri(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - sas_credential = AzureSasCredential(self.sas_token) + sas_token = self.generate_fake_sas_token() + sas_credential = AzureSasCredential(sas_token) for service_type in SERVICES: # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type( self.account_url(storage_account_name, "blob") + "?sig=foo", credential=sas_credential, container_name='foo', blob_name='bar') @BlobPreparer() - def test_create_service_with_token_async(self, storage_account_name, storage_account_key): + def test_create_service_with_token(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + + token_credential = self.generate_oauth_token() for service_type in SERVICES: # Act service = service_type( - self.account_url(storage_account_name, "blob"), credential=self.token_credential, container_name='foo', blob_name='bar') + self.account_url(storage_account_name, "blob"), credential=token_credential, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertEqual(service.credential, self.token_credential) - self.assertEqual(service.account_name, storage_account_name) + assert service is not None + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.credential == token_credential + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_service_with_token_and_http_async(self, storage_account_name, storage_account_key): + def test_create_service_with_token_and_http(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + + token_credential = self.generate_oauth_token() for service_type in SERVICES: # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): url = self.account_url(storage_account_name, "blob").replace('https', 'http') - service_type(url, credential=self.token_credential, container_name='foo', blob_name='bar') + service_type(url, credential=token_credential, container_name='foo', blob_name='bar') @BlobPreparer() - def test_create_service_china_async(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_china(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): # Act url = self.account_url(storage_account_name, "blob").replace('core.windows.net', 'core.chinacloudapi.cn') @@ -147,19 +180,21 @@ def test_create_service_china_async(self, storage_account_name, storage_account_ url, credential=storage_account_key, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith( - 'https://{}.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) - self.assertTrue(service.secondary_endpoint.startswith( - 'https://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith( + 'https://{}.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) + assert service.secondary_endpoint.startswith( + 'https://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) @BlobPreparer() - def test_create_service_protocol_async(self, storage_account_name, storage_account_key): - # Arrange + def test_create_service_protocol(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): # Act url = self.account_url(storage_account_name, "blob").replace('https', 'http') @@ -168,10 +203,12 @@ def test_create_service_protocol_async(self, storage_account_name, storage_accou # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'http') + assert service.scheme == 'http' @BlobPreparer() - def test_create_blob_service_anonymous_async(self, storage_account_name, storage_account_key): + def test_create_blob_service_anonymous(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange BLOB_SERVICES = [BlobServiceClient, ContainerClient, BlobClient] @@ -180,13 +217,16 @@ def test_create_blob_service_anonymous_async(self, storage_account_name, storage service = service_type(self.account_url(storage_account_name, "blob"), container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertIsNone(service.credential) - self.assertEqual(service.account_name, storage_account_name) + assert service is not None + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.credential is None + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_blob_service_custom_domain_async(self, storage_account_name, storage_account_key): + def test_create_blob_service_custom_domain(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange BLOB_SERVICES = [BlobServiceClient, ContainerClient, BlobClient] @@ -199,15 +239,18 @@ def test_create_blob_service_custom_domain_async(self, storage_account_name, sto blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_create_service_with_socket_timeout_async(self, storage_account_name, storage_account_key): + def test_create_service_with_socket_timeout(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): @@ -226,7 +269,10 @@ def test_create_service_with_socket_timeout_async(self, storage_account_name, st # --Connection String Test Cases -------------------------------------------- @BlobPreparer() - def test_create_service_with_connection_string_key_async(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_key(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange conn_string = 'AccountName={};AccountKey={};'.format(storage_account_name, storage_account_key) @@ -237,12 +283,15 @@ def test_create_service_with_connection_string_key_async(self, storage_account_n # Assert self.validate_standard_account_endpoints(service, service_type[1], storage_account_name, storage_account_key) - self.assertEqual(service.scheme, 'https') + assert service.scheme == 'https' @BlobPreparer() - def test_create_service_with_connection_string_sas_async(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_sas(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + # Arrange - conn_string = 'AccountName={};SharedAccessSignature={};'.format(storage_account_name, self.sas_token) + sas_token = self.generate_fake_sas_token() + conn_string = 'AccountName={};SharedAccessSignature={};'.format(storage_account_name, sas_token) for service_type in SERVICES: # Act @@ -250,26 +299,32 @@ def test_create_service_with_connection_string_sas_async(self, storage_account_n conn_string, container_name='foo', blob_name='bar') # Assert - self.assertIsNotNone(service) - self.assertTrue(service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net')) - self.assertTrue(service.url.endswith(self.sas_token)) - self.assertIsNone(service.credential) - self.assertEqual(service.account_name, storage_account_name) + assert service is not None + assert service.url.startswith('https://' + storage_account_name + '.blob.core.windows.net') + assert service.url.endswith(sas_token) + assert service.credential is None + assert service.account_name == storage_account_name @BlobPreparer() - def test_create_blob_client_with_complete_blob_url_async(self, storage_account_name, storage_account_key): + def test_create_blob_client_with_complete_blob_url(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange blob_url = self.account_url(storage_account_name, "blob") + "/foourl/barurl" service = BlobClient(blob_url, credential=storage_account_key, container_name='foo', blob_name='bar') - # Assert - self.assertEqual(service.scheme, 'https') - self.assertEqual(service.container_name, 'foo') - self.assertEqual(service.blob_name, 'bar') - self.assertEqual(service.account_name, storage_account_name) + # Assert + assert service.scheme == 'https' + assert service.container_name == 'foo' + assert service.blob_name == 'bar' + assert service.account_name == storage_account_name @BlobPreparer() - def test_creat_serv_w_connstr_endpoint_protocol_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_endpoint_protocol(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange conn_string = 'AccountName={};AccountKey={};DefaultEndpointsProtocol=http;EndpointSuffix=core.chinacloudapi.cn;'.format( storage_account_name, storage_account_key) @@ -279,30 +334,31 @@ def test_creat_serv_w_connstr_endpoint_protocol_async(self, storage_account_name service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue( - service.primary_endpoint.startswith( - 'http://{}.{}.core.chinacloudapi.cn/'.format(storage_account_name, service_type[1]))) - self.assertTrue( - service.secondary_endpoint.startswith( - 'http://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1]))) - self.assertEqual(service.scheme, 'http') + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith( + 'http://{}.{}.core.chinacloudapi.cn/'.format(storage_account_name, service_type[1])) + assert service.secondary_endpoint.startswith( + 'http://{}-secondary.{}.core.chinacloudapi.cn'.format(storage_account_name, service_type[1])) + assert service.scheme == 'http' @BlobPreparer() - def test_create_service_with_connection_string_emulated_async(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_emulated(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'UseDevelopmentStorage=true;'.format(storage_account_name, storage_account_key) # Act - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") @BlobPreparer() - def test_create_service_with_connection_string_anonymous_async(self, storage_account_name, storage_account_key): + def test_create_service_with_connection_string_anonymous(self): # Arrange for service_type in SERVICES.items(): conn_string = 'BlobEndpoint=www.mydomain.com;' @@ -311,15 +367,18 @@ def test_create_service_with_connection_string_anonymous_async(self, storage_acc service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, None) - self.assertIsNone(service.credential) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - with self.assertRaises(ValueError): + assert service is not None + assert service.account_name == None + assert service.credential is None + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + with pytest.raises(ValueError): service.secondary_endpoint @BlobPreparer() - def test_creat_serv_w_connstr_custm_domain_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_custm_domain(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com;'.format( @@ -329,15 +388,18 @@ def test_creat_serv_w_connstr_custm_domain_async(self, storage_account_name, sto service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_creat_serv_w_connstr_custm_dom_trailing_slash_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_custm_dom_trailing_slash(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com/;'.format( @@ -347,15 +409,18 @@ def test_creat_serv_w_connstr_custm_dom_trailing_slash_async(self, storage_accou service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://' + storage_account_name + '-secondary.blob.core.windows.net') @BlobPreparer() - def test_creat_serv_w_connstr_custm_dom_2ndry_override_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_custm_dom_2ndry_override(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for service_type in SERVICES.items(): conn_string = 'AccountName={};AccountKey={};BlobEndpoint=www.mydomain.com/;'.format( @@ -366,15 +431,18 @@ def test_creat_serv_w_connstr_custm_dom_2ndry_override_async(self, storage_accou conn_string, secondary_hostname="www-sec.mydomain.com", container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://www-sec.mydomain.com/')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://www-sec.mydomain.com/') @BlobPreparer() - def test_creat_serv_w_connstr_fail_if_2ndry_wo_primary_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_fail_if_2ndry_wo_primary(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;'.format( @@ -384,11 +452,14 @@ def test_creat_serv_w_connstr_fail_if_2ndry_wo_primary_async(self, storage_accou # Act # Fails if primary excluded - with self.assertRaises(ValueError): + with pytest.raises(ValueError): service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") @BlobPreparer() - def test_creat_serv_w_connstr_pass_if_2ndry_w_primary_async(self, storage_account_name, storage_account_key): + def test_creat_serv_w_connstr_pass_if_2ndry_w_primary(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + for service_type in SERVICES.items(): # Arrange conn_string = 'AccountName={};AccountKey={};{}=www.mydomain.com;{}=www-sec.mydomain.com;'.format( @@ -401,17 +472,18 @@ def test_creat_serv_w_connstr_pass_if_2ndry_w_primary_async(self, storage_accoun service = service_type[0].from_connection_string(conn_string, container_name="foo", blob_name="bar") # Assert - self.assertIsNotNone(service) - self.assertEqual(service.account_name, storage_account_name) - self.assertEqual(service.credential.account_name, storage_account_name) - self.assertEqual(service.credential.account_key, storage_account_key) - self.assertTrue(service.primary_endpoint.startswith('https://www.mydomain.com/')) - self.assertTrue(service.secondary_endpoint.startswith('https://www-sec.mydomain.com/')) + assert service is not None + assert service.account_name == storage_account_name + assert service.credential.account_name == storage_account_name + assert service.credential.account_key == storage_account_key + assert service.primary_endpoint.startswith('https://www.mydomain.com/') + assert service.secondary_endpoint.startswith('https://www-sec.mydomain.com/') def test_create_service_with_custom_account_endpoint_path(self): account_name = "blobstorage" account_key = "blobkey" - custom_account_url = "http://local-machine:11002/custom/account/path/" + self.sas_token + sas_token = self.generate_fake_sas_token() + custom_account_url = "http://local-machine:11002/custom/account/path/" + sas_token for service_type in SERVICES.items(): conn_string = 'DefaultEndpointsProtocol=http;AccountName={};AccountKey={};BlobEndpoint={};'.format( account_name, account_key, custom_account_url) @@ -421,64 +493,67 @@ def test_create_service_with_custom_account_endpoint_path(self): conn_string, container_name="foo", blob_name="bar") # Assert - self.assertEqual(service.account_name, account_name) - self.assertEqual(service.credential.account_name, account_name) - self.assertEqual(service.credential.account_key, account_key) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') + assert service.account_name == account_name + assert service.credential.account_name == account_name + assert service.credential.account_key == account_key + assert service.primary_hostname == 'local-machine:11002/custom/account/path' service = BlobServiceClient(account_url=custom_account_url) - self.assertEqual(service.account_name, None) - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/?')) + assert service.account_name == None + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/?') service = ContainerClient(account_url=custom_account_url, container_name="foo") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/foo?')) + assert service.account_name == None + assert service.container_name == "foo" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/foo?') service = ContainerClient.from_container_url("http://local-machine:11002/custom/account/path/foo?query=value") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertEqual(service.url, 'http://local-machine:11002/custom/account/path/foo') + assert service.account_name == None + assert service.container_name == "foo" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url == 'http://local-machine:11002/custom/account/path/foo' service = BlobClient(account_url=custom_account_url, container_name="foo", blob_name="bar", snapshot="baz") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.blob_name, "bar") - self.assertEqual(service.snapshot, "baz") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertTrue(service.url.startswith('http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&')) + assert service.account_name == None + assert service.container_name == "foo" + assert service.blob_name == "bar" + assert service.snapshot == "baz" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url.startswith('http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&') service = BlobClient.from_blob_url("http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz&query=value") - self.assertEqual(service.account_name, None) - self.assertEqual(service.container_name, "foo") - self.assertEqual(service.blob_name, "bar") - self.assertEqual(service.snapshot, "baz") - self.assertEqual(service.credential, None) - self.assertEqual(service.primary_hostname, 'local-machine:11002/custom/account/path') - self.assertEqual(service.url, 'http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz') + assert service.account_name == None + assert service.container_name == "foo" + assert service.blob_name == "bar" + assert service.snapshot == "baz" + assert service.credential == None + assert service.primary_hostname == 'local-machine:11002/custom/account/path' + assert service.url == 'http://local-machine:11002/custom/account/path/foo/bar?snapshot=baz' def test_create_blob_client_with_sub_directory_path_in_blob_name(self): blob_url = "https://testaccount.blob.core.windows.net/containername/dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" blob_client = BlobClient.from_blob_url(blob_url) - self.assertEqual(blob_client.container_name, "containername") - self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg") + assert blob_client.container_name == "containername" + assert blob_client.blob_name == "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" blob_emulator_url = 'http://127.0.0.1:1000/devstoreaccount1/containername/dir1/sub000/2010_Unit150_Ivan097_img0003.jpg' blob_client = BlobClient.from_blob_url(blob_emulator_url) - self.assertEqual(blob_client.container_name, "containername") - self.assertEqual(blob_client.blob_name, "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg") - self.assertEqual(blob_client.url, blob_emulator_url) + assert blob_client.container_name == "containername" + assert blob_client.blob_name == "dir1/sub000/2010_Unit150_Ivan097_img0003.jpg" + assert blob_client.url == blob_emulator_url @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_request_callback_signed_header_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_request_callback_signed_header(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) name = self.get_resource_name('cont') @@ -492,13 +567,16 @@ def callback(request): try: container = await service.create_container(name, raw_request_hook=callback) metadata = (await container.get_container_properties()).metadata - self.assertEqual(metadata, {'hello': 'world'}) + assert metadata == {'hello': 'world'} finally: await service.delete_container(name) @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_response_callback_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_response_callback(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) name = self.get_resource_name('cont') @@ -511,28 +589,34 @@ def callback(response): # Assert exists = await container.get_container_properties(raw_response_hook=callback) - self.assertTrue(exists) + assert exists @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_user_agent_default_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_user_agent_default(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert "azsdk-python-storage-blob/{}".format(VERSION) in response.http_request.headers['User-Agent'] await service.get_service_properties(raw_response_hook=callback) @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_user_agent_custom_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_user_agent_custom(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + custom_app = "TestApp/v1.0" service = BlobServiceClient( self.account_url(storage_account_name, "blob"), credential=storage_account_key, user_agent=custom_app) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -541,7 +625,7 @@ def callback(response): await service.get_service_properties(raw_response_hook=callback) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -550,12 +634,15 @@ def callback(response): await service.get_service_properties(raw_response_hook=callback, user_agent="TestApp/v2.0") @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_user_agent_append_async(self, storage_account_name, storage_account_key): + @recorded_by_proxy_async + async def test_user_agent_append(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + service = BlobServiceClient(self.account_url(storage_account_name, "blob"), credential=storage_account_key) def callback(response): - self.assertTrue('User-Agent' in response.http_request.headers) + assert 'User-Agent' in response.http_request.headers assert ("customer_user_agent azsdk-python-storage-blob/{} Python/{} ({})".format( VERSION, platform.python_version(), @@ -564,8 +651,10 @@ def callback(response): await service.get_service_properties(raw_response_hook=callback, user_agent='customer_user_agent') @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_closing_pipeline_client(self, storage_account_name, storage_account_key): + async def test_closing_pipeline_client(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items(): @@ -579,8 +668,10 @@ async def test_closing_pipeline_client(self, storage_account_name, storage_accou await service.close() @BlobPreparer() - @AsyncStorageTestCase.await_prepared_test - async def test_closing_pipeline_client_simple(self, storage_account_name, storage_account_key): + async def test_closing_pipeline_client_simple(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + # Arrange for client, url in SERVICES.items():