Skip to content

Commit 3912ea6

Browse files
committed
edit all authentication files and add a test
1 parent 621a17a commit 3912ea6

File tree

6 files changed

+133
-4
lines changed

6 files changed

+133
-4
lines changed

sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def _get_canonicalized_resource(self, request):
8080
try:
8181
if isinstance(request.context.transport, AioHttpTransport) or \
8282
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport) or \
83-
isinstance(getattr(getattr(request.context.transport, "_transport", None), "_transport", None), AioHttpTransport):
83+
isinstance(getattr(getattr(request.context.transport, "_transport", None), "_transport", None),
84+
AioHttpTransport):
8485
uri_path = URL(uri_path)
8586
return '/' + self.account_name + str(uri_path)
8687
except TypeError:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
User-Agent:
6+
- azsdk-python-storage-blob/12.4.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
7+
x-ms-date:
8+
- Thu, 27 Aug 2020 01:48:41 GMT
9+
x-ms-version:
10+
- '2019-12-12'
11+
method: PUT
12+
uri: https://storagename.blob.core.windows.net/utcontainer775c1685?timeout=5&restype=container
13+
response:
14+
body:
15+
string: ''
16+
headers:
17+
content-length: '0'
18+
date: Thu, 27 Aug 2020 01:48:40 GMT
19+
etag: '"0x8D84A2B5357BF80"'
20+
last-modified: Thu, 27 Aug 2020 01:48:41 GMT
21+
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
22+
x-ms-version: '2019-12-12'
23+
status:
24+
code: 201
25+
message: Created
26+
url: https://emilyeuap.blob.core.windows.net/utcontainer775c1685?timeout=5&restype=container
27+
- request:
28+
body: ???
29+
headers:
30+
Content-Length:
31+
- '3'
32+
Content-Type:
33+
- application/octet-stream
34+
If-None-Match:
35+
- '*'
36+
User-Agent:
37+
- azsdk-python-storage-blob/12.4.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
38+
x-ms-blob-type:
39+
- BlockBlob
40+
x-ms-date:
41+
- Thu, 27 Aug 2020 01:48:41 GMT
42+
x-ms-version:
43+
- '2019-12-12'
44+
method: PUT
45+
uri: https://storagename.blob.core.windows.net/utcontainer775c1685/=ques=tion!
46+
response:
47+
body:
48+
string: ''
49+
headers:
50+
content-length: '0'
51+
content-md5: DRsIw0hYkhvHxmKyKKy3ug==
52+
date: Thu, 27 Aug 2020 01:48:40 GMT
53+
etag: '"0x8D84A2B536556A6"'
54+
last-modified: Thu, 27 Aug 2020 01:48:41 GMT
55+
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
56+
x-ms-content-crc64: VtoDJyOMw/A=
57+
x-ms-request-server-encrypted: 'true'
58+
x-ms-version: '2019-12-12'
59+
x-ms-version-id: '2020-08-27T01:48:41.6124582Z'
60+
status:
61+
code: 201
62+
message: Created
63+
url: https://emilyeuap.blob.core.windows.net/utcontainer775c1685/=ques=tion!
64+
- request:
65+
body: null
66+
headers:
67+
Accept:
68+
- application/xml
69+
User-Agent:
70+
- azsdk-python-storage-blob/12.4.0b1 Python/3.7.3 (Windows-10-10.0.19041-SP0)
71+
x-ms-date:
72+
- Thu, 27 Aug 2020 01:48:41 GMT
73+
x-ms-range:
74+
- bytes=0-33554431
75+
x-ms-version:
76+
- '2019-12-12'
77+
method: GET
78+
uri: https://storagename.blob.core.windows.net/utcontainer775c1685/=ques=tion!
79+
response:
80+
body:
81+
string: ???
82+
headers:
83+
accept-ranges: bytes
84+
content-length: '3'
85+
content-range: bytes 0-2/3
86+
content-type: application/octet-stream
87+
date: Thu, 27 Aug 2020 01:48:41 GMT
88+
etag: '"0x8D84A2B536556A6"'
89+
last-modified: Thu, 27 Aug 2020 01:48:41 GMT
90+
server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
91+
x-ms-blob-content-md5: DRsIw0hYkhvHxmKyKKy3ug==
92+
x-ms-blob-type: BlockBlob
93+
x-ms-creation-time: Thu, 27 Aug 2020 01:48:41 GMT
94+
x-ms-is-current-version: 'true'
95+
x-ms-lease-state: available
96+
x-ms-lease-status: unlocked
97+
x-ms-server-encrypted: 'true'
98+
x-ms-version: '2019-12-12'
99+
x-ms-version-id: '2020-08-27T01:48:41.6124582Z'
100+
status:
101+
code: 206
102+
message: Partial Content
103+
url: https://emilyeuap.blob.core.windows.net/utcontainer775c1685/=ques=tion!
104+
version: 1

sdk/storage/azure-storage-blob/tests/test_common_blob_async.py

+18
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,24 @@ async def test_create_blob_with_question_mark(self, resource_group, location, st
272272
content = data.decode('utf-8')
273273
self.assertEqual(content, blob_data)
274274

275+
@GlobalStorageAccountPreparer()
276+
@AsyncStorageTestCase.await_prepared_test
277+
async def test_create_blob_with_equal_sign(self, resource_group, location, storage_account, storage_account_key):
278+
# Arrange
279+
await self._setup(storage_account, storage_account_key)
280+
blob_name = '=ques=tion!'
281+
blob_data = u'???'
282+
283+
# Act
284+
blob = self.bsc.get_blob_client(self.container_name, blob_name)
285+
await blob.upload_blob(blob_data)
286+
287+
# Assert
288+
stream = await blob.download_blob()
289+
data = await stream.readall()
290+
self.assertIsNotNone(data)
291+
content = data.decode('utf-8')
292+
self.assertEqual(content, blob_data)
275293

276294
@GlobalStorageAccountPreparer()
277295
@AsyncStorageTestCase.await_prepared_test

sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _get_canonicalized_resource(self, request):
7979
uri_path = urlparse(request.http_request.url).path
8080
try:
8181
if isinstance(request.context.transport, AioHttpTransport) or \
82-
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport):
82+
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport) or \
83+
isinstance(getattr(getattr(request.context.transport, "_transport", None), "_transport", None),
84+
AioHttpTransport):
8385
uri_path = URL(uri_path)
8486
return '/' + self.account_name + str(uri_path)
8587
except TypeError:

sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _get_canonicalized_resource(self, request):
7979
uri_path = urlparse(request.http_request.url).path
8080
try:
8181
if isinstance(request.context.transport, AioHttpTransport) or \
82-
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport):
82+
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport) or \
83+
isinstance(getattr(getattr(request.context.transport, "_transport", None), "_transport", None),
84+
AioHttpTransport):
8385
uri_path = URL(uri_path)
8486
return '/' + self.account_name + str(uri_path)
8587
except TypeError:

sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ def _get_canonicalized_resource(self, request):
7979
uri_path = urlparse(request.http_request.url).path
8080
try:
8181
if isinstance(request.context.transport, AioHttpTransport) or \
82-
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport):
82+
isinstance(getattr(request.context.transport, "_transport", None), AioHttpTransport) or \
83+
isinstance(getattr(getattr(request.context.transport, "_transport", None), "_transport", None),
84+
AioHttpTransport):
8385
uri_path = URL(uri_path)
8486
return '/' + self.account_name + str(uri_path)
8587
except TypeError:

0 commit comments

Comments
 (0)