Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
512d5a4
[File][RestParity]Rest Parity Sync
xiafu-msft Aug 29, 2019
8bed721
[File][RestParity]Rest Parity Async
xiafu-msft Aug 29, 2019
22b801a
[File][RestParity]Add Rest Parity Async Recording Files
xiafu-msft Aug 29, 2019
bfd3fbd
[File][RestParity]Fix CI
xiafu-msft Sep 6, 2019
7707acf
[File][RestParity]Recording again to fix CI
xiafu-msft Sep 6, 2019
e945a70
Add Generated Code
xiafu-msft Sep 6, 2019
8c821a6
Stylistic Things and Record
xiafu-msft Sep 6, 2019
8c5c22c
[Swagger][BugFix]workaround to fix swagger generated code
xiafu-msft Sep 9, 2019
d46e3dc
[File][RestParity]Add Create_Permission API and Test
xiafu-msft Sep 9, 2019
fcf0ec6
Fix Test
xiafu-msft Sep 9, 2019
3c6b3e0
Fix Pylint
xiafu-msft Sep 9, 2019
62dc377
Revert the workaround
xiafu-msft Sep 9, 2019
3d00c52
[File][RestParity]Tweak Documentation and Tests
xiafu-msft Sep 9, 2019
9afed1d
delete .dat file
xiafu-msft Sep 9, 2019
bd9f32e
[File][RestParity]Rest Parity Async
xiafu-msft Aug 29, 2019
99a07ad
[Blob][IdentitySAS]Add Identity SAS
xiafu-msft Aug 30, 2019
e7811c1
[Blob][IdentitySAS]Stylistic Things
xiafu-msft Sep 9, 2019
a565b90
[Blob][IdentitySAS]Stylistic Things
xiafu-msft Sep 9, 2019
aed02d4
[Blob][IdentitySAS]Add account_name parameter
xiafu-msft Sep 9, 2019
17540b4
Fix Pylint
xiafu-msft Sep 9, 2019
9c327cc
Merge branch 'feature/storage-preview3' into identity-sas
xiafu-msft Sep 9, 2019
450a66e
Merge branch 'feature/storage-preview3' into identity-sas
xiafu-msft Sep 9, 2019
969816b
Fix Pylint
xiafu-msft Sep 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Blob][IdentitySAS]Stylistic Things
  • Loading branch information
xiafu-msft committed Sep 9, 2019
commit e7811c1d17354fb2e79a94d3e504613d0717d7b9
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
from .._shared.policies_async import ExponentialRetry
from .._shared.base_client_async import AsyncStorageAccountHostsMixin
from .._shared.response_handlers import return_response_headers, process_storage_error
from .._shared.parser import _parse_to_internal_user_delegation_key, _to_utc_datetime
from .._generated.aio import AzureBlobStorage
from .._generated.models import StorageErrorException, StorageServiceProperties
from .._generated.models import StorageErrorException, StorageServiceProperties, KeyInfo
from ..blob_service_client import BlobServiceClient as BlobServiceClientBase
from .container_client_async import ContainerClient
from .blob_client_async import BlobClient
Expand Down Expand Up @@ -110,6 +111,33 @@ def __init__(
self._client = AzureBlobStorage(url=self.url, pipeline=self._pipeline, loop=loop)
self._loop = loop

@distributed_trace_async
async def get_user_delegation_key(self, key_start_time, # type: datetime
key_expiry_time, # type: datetime
timeout=None # type: Optional[int]
):
# type: (datetime, datetime, Optional[int]) -> UserDelegationKey
"""
Obtain a user delegation key for the purpose of signing SAS tokens.
A token credential must be present on the service object for this request to succeed.

:param datetime key_start_time:
A DateTime value. Indicates when the key becomes valid.
:param datetime key_expiry_time:
A DateTime value. Indicates when the key stops being valid.
:param int timeout:
The timeout parameter is expressed in seconds.
:return: The user delegation key.
:rtype: ~azure.storage.blob._shared.models.UserDelegationKey
"""
key_info = KeyInfo(start=_to_utc_datetime(key_start_time), expiry=_to_utc_datetime(key_expiry_time))
try:
user_delegation_key = await self._client.service.get_user_delegation_key(key_info=key_info, timeout=timeout)
except StorageErrorException as error:
process_storage_error(error)

return _parse_to_internal_user_delegation_key(user_delegation_key) # type: ignore

@distributed_trace_async
async def get_account_information(self, **kwargs): # type: ignore
# type: (Optional[int]) -> Dict[str, str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
SourceModifiedAccessConditions,
ModifiedAccessConditions,
SequenceNumberAccessConditions,
StorageErrorException)
StorageErrorException,
UserDelegationKey)
from ._deserialize import deserialize_blob_properties, deserialize_blob_stream
from ._upload_helpers import (
upload_block_blob,
Expand Down Expand Up @@ -233,8 +234,8 @@ def generate_shared_access_signature(
content_encoding=None, # type: Optional[str]
content_language=None, # type: Optional[str]
content_type=None, # type: Optional[str]
user_delegation_key=None
):
user_delegation_key=None # type: Optional[UserDelegationKey]
):
# type: (...) -> Any
"""
Generates a shared access signature for the blob.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
interactions:
- request:
body: client_id=68390a19-a897-236b-b453-488abf67b4fc&client_secret=3Usxz7pzkOeE7flc6Z187ubs5%2FcJnszGPjAiXmcwhaY%3D&grant_type=client_credentials&scope=https%3A%2F%2Fstorage.azure.com%2F.default
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '188'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- python-requests/2.22.0
method: POST
uri: https://login.microsoftonline.com/32f988bf-54f1-15af-36ab-2d7cd364db47/oauth2/v2.0/token
response:
body:
string: '{"token_type":"Bearer","expires_in":3600,"ext_expires_in":3600,"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImllX3FXQ1hoWHh0MXpJRXN1NGM3YWNRVkduNCIsImtpZCI6ImllX3FXQ1hoWHh0MXpJRXN1NGM3YWNRVkduNCJ9.eyJhdWQiOiJodHRwczovL3N0b3JhZ2UuYXp1cmUuY29tIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3LyIsImlhdCI6MTU2ODAxMzI3MSwibmJmIjoxNTY4MDEzMjcxLCJleHAiOjE1NjgwMTcxNzEsImFpbyI6IjQyRmdZRWllNE9INFQ0YkZrR3RoaExHT2hma1pBQT09IiwiYXBwaWQiOiI2ODM5MGExOS1hNjQzLTQ1OGItYjcyNi00MDhhYmY2N2I0ZmMiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83MmY5ODhiZi04NmYxLTQxYWYtOTFhYi0yZDdjZDAxMWRiNDcvIiwib2lkIjoiYzRmNDgyODktYmI4NC00MDg2LWIyNTAtNmY5NGE4ZjY0Y2VlIiwic3ViIjoiYzRmNDgyODktYmI4NC00MDg2LWIyNTAtNmY5NGE4ZjY0Y2VlIiwidGlkIjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IiwidXRpIjoiRkpWQVQxM2NYVXFLeFhlc0tUMHNBQSIsInZlciI6IjEuMCJ9.tk74OnnuvrPtFFWZe_v1H6GpGK5hU4n76EoIybK2O_Za8ddlQbBtgeMqNzifX6qlh8bce4RYOSggFNapknf01h9Z53UkdJXusB8IcIoPXv9t3NH-zkrSabU0VpWLh24cas9u5HT-re0YZy4b2T9czKCheU2ltyU3y2VwsFh1OAmaUUJaDUw0OSdQGRcOu2rS5LQAgAQu0UcQZG2bT_IoAeIGCnIIyOG25gaO7mt4_oHqU61b6q9AH72i7shblF1JBQp6eMmTkZe_Y1GnScOACUTh3R82nSQ-AKC2JrXXGCELl9L_bUmbxOVBwJ9F-La4d26axn6NcmFnMzaiGO1tyw"}'
headers:
Cache-Control:
- no-cache, no-store
Content-Length:
- '1233'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 09 Sep 2019 07:19:30 GMT
Expires:
- '-1'
P3P:
- CP="DSP CUR OTPi IND OTRi ONL FIN"
Pragma:
- no-cache
Set-Cookie:
- fpc=Arv4rF3oXGJOuCYLHWg4UbzeSEc1AQAAAAL0B9UOAAAA; expires=Wed, 09-Oct-2019
07:19:31 GMT; path=/; secure; HttpOnly
- x-ms-gateway-slice=estsfd; path=/; secure; HttpOnly
- stsservicecookie=estsfd; path=/; secure; HttpOnly
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
x-ms-ests-server:
- 2.1.9368.5 - WUS ProdSlices
x-ms-request-id:
- 4f409514-dc5d-4a5d-8ac5-77ac293d2c00
status:
code: 200
message: OK
- request:
body: '<?xml version=''1.0'' encoding=''utf-8''?>

<KeyInfo><Start>2019-09-09T07:19:30Z</Start><Expiry>2019-09-09T08:19:30Z</Expiry></KeyInfo>'
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '130'
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- azsdk-python-storage-blob/12.0.0b2 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-client-request-id:
- 2a824312-d2d2-11e9-8739-001a7dda7113
x-ms-date:
- Mon, 09 Sep 2019 07:19:30 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://oauthstoragename.blob.core.windows.net/?restype=service&comp=userdelegationkey
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><UserDelegationKey><SignedOid>c4f48289-bb84-4086-b250-6f94a8f64cee</SignedOid><SignedTid>32f988bf-54f1-15af-36ab-2d7cd364db47</SignedTid><SignedStart>2019-09-09T07:19:30Z</SignedStart><SignedExpiry>2019-09-09T08:19:30Z</SignedExpiry><SignedService>b</SignedService><SignedVersion>2019-02-02</SignedVersion><Value>1CVF1CqD5X/XQy7xviJADxqwoA9X1Sh/pQWYA6//6Pc=</Value></UserDelegationKey>"
headers:
Content-Type:
- application/xml
Date:
- Mon, 09 Sep 2019 07:19:30 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
Transfer-Encoding:
- chunked
x-ms-client-request-id:
- 2a824312-d2d2-11e9-8739-001a7dda7113
x-ms-request-id:
- e2241bda-c01e-0028-5ade-66325c000000
x-ms-version:
- '2019-02-02'
status:
code: 200
message: OK
- request:
body: '<?xml version=''1.0'' encoding=''utf-8''?>

<KeyInfo><Start>2019-09-09T07:19:30Z</Start><Expiry>2019-09-09T08:19:30Z</Expiry></KeyInfo>'
headers:
Accept:
- application/xml
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '130'
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- azsdk-python-storage-blob/12.0.0b2 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-client-request-id:
- 2af3d72e-d2d2-11e9-8331-001a7dda7113
x-ms-date:
- Mon, 09 Sep 2019 07:19:31 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://oauthstoragename.blob.core.windows.net/?restype=service&comp=userdelegationkey
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><UserDelegationKey><SignedOid>c4f48289-bb84-4086-b250-6f94a8f64cee</SignedOid><SignedTid>32f988bf-54f1-15af-36ab-2d7cd364db47</SignedTid><SignedStart>2019-09-09T07:19:30Z</SignedStart><SignedExpiry>2019-09-09T08:19:30Z</SignedExpiry><SignedService>b</SignedService><SignedVersion>2019-02-02</SignedVersion><Value>1CVF1CqD5X/XQy7xviJADxqwoA9X1Sh/pQWYA6//6Pc=</Value></UserDelegationKey>"
headers:
Content-Type:
- application/xml
Date:
- Mon, 09 Sep 2019 07:19:30 GMT
Server:
- Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
Transfer-Encoding:
- chunked
x-ms-client-request-id:
- 2af3d72e-d2d2-11e9-8331-001a7dda7113
x-ms-request-id:
- e2241c96-c01e-0028-01de-66325c000000
x-ms-version:
- '2019-02-02'
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
interactions:
- request:
body: client_id=68390a19-a897-236b-b453-488abf67b4fc&client_secret=3Usxz7pzkOeE7flc6Z187ubs5%2FcJnszGPjAiXmcwhaY%3D&grant_type=client_credentials&scope=https%3A%2F%2Fstorage.azure.com%2F.default
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '188'
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- python-requests/2.22.0
method: POST
uri: https://login.microsoftonline.com/32f988bf-54f1-15af-36ab-2d7cd364db47/oauth2/v2.0/token
response:
body:
string: '{"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImllX3FXQ1hoWHh0MXpJRXN1NGM3YWNRVkduNCIsImtpZCI6ImllX3FXQ1hoWHh0MXpJRXN1NGM3YWNRVkduNCJ9.eyJhdWQiOiJodHRwczovL3N0b3JhZ2UuYXp1cmUuY29tIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3LyIsImlhdCI6MTU2ODAxNDM5OSwibmJmIjoxNTY4MDE0Mzk5LCJleHAiOjE1NjgwMTgyOTksImFpbyI6IjQyRmdZQkE2SWkzVnYrL3dyUzMrMHcrMEZDMmVDQUE9IiwiYXBwaWQiOiI2ODM5MGExOS1hNjQzLTQ1OGItYjcyNi00MDhhYmY2N2I0ZmMiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83MmY5ODhiZi04NmYxLTQxYWYtOTFhYi0yZDdjZDAxMWRiNDcvIiwib2lkIjoiYzRmNDgyODktYmI4NC00MDg2LWIyNTAtNmY5NGE4ZjY0Y2VlIiwic3ViIjoiYzRmNDgyODktYmI4NC00MDg2LWIyNTAtNmY5NGE4ZjY0Y2VlIiwidGlkIjoiNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IiwidXRpIjoiUHMyLS1ZQjQ2MHluYUJ5S1ZDTXRBQSIsInZlciI6IjEuMCJ9.d3JgzJ664_Xmbbe7aWRDfUuw4g2W7MtKbCcOFAMko-gN5qXcmSNyAiOGHSUrvuORtEPOLye3CZuBmYw6hczqhl-9dF760mRxLyZjOjqE78YTJkudwU5iV69nr9VIAIMOk5Lh7N3sgUdWrSsz-ZUT8665da1pN3bpsl8zEHf9ZBM1qFia4J9OLtGQRb_Th2jJpm_LbMKdnMJ45cgoYxZeKcofo43we-BHSU5T-Jt4O8i6nalMSelp5ZuLI7KL308sm81iUyrrK3PCGGhGVdNIg5B4cOdMmq3B10m-Kk2gZfoPj2cJrsUkhY005mimBh7aa05B1BIwooRzxCE7t0ne_Q"}'
headers:
Cache-Control:
- no-cache, no-store
Content-Length:
- '1233'
Content-Type:
- application/json; charset=utf-8
Date:
- Mon, 09 Sep 2019 07:38:19 GMT
Expires:
- '-1'
P3P:
- CP="DSP CUR OTPi IND OTRi ONL FIN"
Pragma:
- no-cache
Set-Cookie:
- fpc=AiNGuczA96ZBt-KrKg4lYNneSEc1AQAAAGv4B9UOAAAA; expires=Wed, 09-Oct-2019
07:38:19 GMT; path=/; secure; HttpOnly
- x-ms-gateway-slice=estsfd; path=/; secure; HttpOnly
- stsservicecookie=estsfd; path=/; secure; HttpOnly
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Content-Type-Options:
- nosniff
x-ms-ests-server:
- 2.1.9368.5 - WUS ProdSlices
x-ms-request-id:
- f9becd3e-7880-4ceb-a768-1c8a54232d00
status:
code: 200
message: OK
- request:
body: '<?xml version=''1.0'' encoding=''utf-8''?>

<KeyInfo><Start>2019-09-09T07:38:19Z</Start><Expiry>2019-09-09T08:38:19Z</Expiry></KeyInfo>'
headers:
Accept:
- application/xml
Content-Length:
- '130'
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- azsdk-python-storage-blob/12.0.0b2 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-client-request-id:
- cb271d62-d2d4-11e9-bda0-001a7dda7113
x-ms-date:
- Mon, 09 Sep 2019 07:38:19 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://oauthstoragename.blob.core.windows.net/?restype=service&comp=userdelegationkey
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><UserDelegationKey><SignedOid>c4f48289-bb84-4086-b250-6f94a8f64cee</SignedOid><SignedTid>32f988bf-54f1-15af-36ab-2d7cd364db47</SignedTid><SignedStart>2019-09-09T07:38:19Z</SignedStart><SignedExpiry>2019-09-09T08:38:19Z</SignedExpiry><SignedService>b</SignedService><SignedVersion>2019-02-02</SignedVersion><Value>kFFrkuiikpAqQywiYShReWmx/tyTvEh8yl8fhjZoH7Q=</Value></UserDelegationKey>"
headers:
? !!python/object/new:multidict._istr.istr
- Content-Type
: application/xml
? !!python/object/new:multidict._istr.istr
- Date
: Mon, 09 Sep 2019 07:38:19 GMT
? !!python/object/new:multidict._istr.istr
- Server
: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
? !!python/object/new:multidict._istr.istr
- Transfer-Encoding
: chunked
x-ms-client-request-id: cb271d62-d2d4-11e9-bda0-001a7dda7113
x-ms-request-id: f99f7a82-d01e-00b2-4be1-66ac85000000
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
- emilydevtest.blob.core.windows.net
- /
- restype=service&comp=userdelegationkey
- ''
- request:
body: '<?xml version=''1.0'' encoding=''utf-8''?>

<KeyInfo><Start>2019-09-09T07:38:19Z</Start><Expiry>2019-09-09T08:38:19Z</Expiry></KeyInfo>'
headers:
Accept:
- application/xml
Content-Length:
- '130'
Content-Type:
- application/xml; charset=utf-8
User-Agent:
- azsdk-python-storage-blob/12.0.0b2 Python/3.7.3 (Windows-10-10.0.18362-SP0)
x-ms-client-request-id:
- cb88c8d2-d2d4-11e9-b99d-001a7dda7113
x-ms-date:
- Mon, 09 Sep 2019 07:38:20 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://oauthstoragename.blob.core.windows.net/?restype=service&comp=userdelegationkey
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><UserDelegationKey><SignedOid>c4f48289-bb84-4086-b250-6f94a8f64cee</SignedOid><SignedTid>32f988bf-54f1-15af-36ab-2d7cd364db47</SignedTid><SignedStart>2019-09-09T07:38:19Z</SignedStart><SignedExpiry>2019-09-09T08:38:19Z</SignedExpiry><SignedService>b</SignedService><SignedVersion>2019-02-02</SignedVersion><Value>kFFrkuiikpAqQywiYShReWmx/tyTvEh8yl8fhjZoH7Q=</Value></UserDelegationKey>"
headers:
? !!python/object/new:multidict._istr.istr
- Content-Type
: application/xml
? !!python/object/new:multidict._istr.istr
- Date
: Mon, 09 Sep 2019 07:38:19 GMT
? !!python/object/new:multidict._istr.istr
- Server
: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
? !!python/object/new:multidict._istr.istr
- Transfer-Encoding
: chunked
x-ms-client-request-id: cb88c8d2-d2d4-11e9-b99d-001a7dda7113
x-ms-request-id: f99f7af3-d01e-00b2-36e1-66ac85000000
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
- emilydevtest.blob.core.windows.net
- /
- restype=service&comp=userdelegationkey
- ''
version: 1
3 changes: 1 addition & 2 deletions sdk/storage/azure-storage-blob/tests/test_common_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,9 +1264,8 @@ def test_account_sas(self):
self.assertEqual(self.byte_data, blob_response.content)
self.assertTrue(container_response.ok)

@record
def test_get_user_delegation_key(self):
if TestMode.need_recording_file(self.test_mode):
return
# Act
token_credential = self.generate_oauth_token()

Expand Down
Loading