Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def _get_download_size(start_range, end_range, resource_size):
'content-range': (None, 'content_range', _to_str),
'x-ms-blob-sequence-number': (None, 'page_blob_sequence_number', _to_int),
'x-ms-blob-committed-block-count': (None, 'append_blob_committed_block_count', _to_int),
'x-ms-blob-public-access': (None, 'public_access', _to_str),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, are you making this change because you wanted the public access info when calling get_container_properties?

Btw there's a separate API specifically for getting this property. And the deserialization was done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it doesn't make sense for the container property model to have "public_access" but not be able to deserialize it from the response.
https://github.com/Azure/azure-storage-python/blob/master/azure-storage-blob/azure/storage/blob/models.py#L48
This results in the property always having the value None

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@williexu That's a good point. Could you please add a test+recording for this change? Thanks!

'x-ms-access-tier': (None, 'blob_tier', _to_str),
'x-ms-access-tier-change-time': (None, 'blob_tier_change_time', parser.parse),
'x-ms-access-tier-inferred': (None, 'blob_tier_inferred', _bool),
Expand Down
29 changes: 9 additions & 20 deletions tests/blob/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,13 @@
# --------------------------------------------------------------------------
import requests
from datetime import datetime, timedelta
from azure.common import (
AzureHttpError,
AzureConflictHttpError,
AzureMissingResourceHttpError,
AzureException,
)
from azure.storage.common import (
AccessPolicy,
)
from azure.storage.blob import (
BlockBlobService,
ContainerPermissions,
Include,
PublicAccess,
)
from tests.testcase import (
StorageTestCase,
TestMode,
record,
)
from azure.common import (AzureConflictHttpError, AzureException,
AzureHttpError, AzureMissingResourceHttpError)
from azure.storage.blob import (BlockBlobService, ContainerPermissions,
Include, PublicAccess)
from azure.storage.common import AccessPolicy

from tests.testcase import StorageTestCase, TestMode, record

#------------------------------------------------------------------------------
TEST_CONTAINER_PREFIX = 'container'
Expand Down Expand Up @@ -368,6 +355,7 @@ def test_get_container_properties(self):
container_name = self._create_container()
self.bs.set_container_metadata(container_name, metadata)
self.bs.acquire_container_lease(container_name)
self.bs.set_container_acl(container_name, None, 'container')

# Act
props = self.bs.get_container_properties(container_name)
Expand All @@ -378,6 +366,7 @@ def test_get_container_properties(self):
self.assertEqual(props.properties.lease.duration, 'infinite')
self.assertEqual(props.properties.lease.state, 'leased')
self.assertEqual(props.properties.lease.status, 'locked')
self.assertEqual(props.properties.public_access, 'container')

@record
def test_get_container_properties_with_lease_id(self):
Expand Down
83 changes: 53 additions & 30 deletions tests/recordings/test_container.test_get_container_properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ interactions:
headers:
Connection: [keep-alive]
Content-Length: ['0']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.3; Darwin 17.3.0)]
x-ms-client-request-id: [7bcf33ee-0acb-11e8-89b0-b8e8564491f6]
x-ms-date: ['Mon, 05 Feb 2018 23:22:50 GMT']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.2; Windows 10)]
x-ms-client-request-id: [38906c82-226a-11e8-8f5a-c8d3ffb16a1d]
x-ms-date: ['Thu, 08 Mar 2018 00:47:04 GMT']
x-ms-version: ['2017-07-29']
method: PUT
uri: https://storagename.blob.core.windows.net/container9840123e?restype=container
response:
body: {string: ''}
headers:
Date: ['Mon, 05 Feb 2018 23:22:49 GMT']
ETag: ['"0x8D56CEF5FF9FB6E"']
Last-Modified: ['Mon, 05 Feb 2018 23:22:50 GMT']
Date: ['Thu, 08 Mar 2018 00:47:04 GMT']
ETag: ['"0x8D5848E1CDBF6B8"']
Last-Modified: ['Thu, 08 Mar 2018 00:47:04 GMT']
Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
Transfer-Encoding: [chunked]
x-ms-request-id: [b553f7ed-001e-0102-42d8-9e107b000000]
x-ms-request-id: [cbf4af7b-501e-00cf-0e76-b66480000000]
x-ms-version: ['2017-07-29']
status: {code: 201, message: Created}
- request:
body: null
headers:
Connection: [keep-alive]
Content-Length: ['0']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.3; Darwin 17.3.0)]
x-ms-client-request-id: [7be44b8a-0acb-11e8-bd7d-b8e8564491f6]
x-ms-date: ['Mon, 05 Feb 2018 23:22:50 GMT']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.2; Windows 10)]
x-ms-client-request-id: [38ad133a-226a-11e8-b87b-c8d3ffb16a1d]
x-ms-date: ['Thu, 08 Mar 2018 00:47:04 GMT']
x-ms-meta-hello: [world]
x-ms-meta-number: ['42']
x-ms-version: ['2017-07-29']
Expand All @@ -37,22 +37,22 @@ interactions:
response:
body: {string: ''}
headers:
Date: ['Mon, 05 Feb 2018 23:22:49 GMT']
ETag: ['"0x8D56CEF600197C2"']
Last-Modified: ['Mon, 05 Feb 2018 23:22:50 GMT']
Date: ['Thu, 08 Mar 2018 00:47:04 GMT']
ETag: ['"0x8D5848E1CE7E872"']
Last-Modified: ['Thu, 08 Mar 2018 00:47:04 GMT']
Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
Transfer-Encoding: [chunked]
x-ms-request-id: [b553f80d-001e-0102-5dd8-9e107b000000]
x-ms-request-id: [cbf4af86-501e-00cf-1476-b66480000000]
x-ms-version: ['2017-07-29']
status: {code: 200, message: OK}
- request:
body: null
headers:
Connection: [keep-alive]
Content-Length: ['0']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.3; Darwin 17.3.0)]
x-ms-client-request-id: [7bea8374-0acb-11e8-bf35-b8e8564491f6]
x-ms-date: ['Mon, 05 Feb 2018 23:22:50 GMT']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.2; Windows 10)]
x-ms-client-request-id: [38b6fe70-226a-11e8-8339-c8d3ffb16a1d]
x-ms-date: ['Thu, 08 Mar 2018 00:47:04 GMT']
x-ms-lease-action: [acquire]
x-ms-lease-duration: ['-1']
x-ms-version: ['2017-07-29']
Expand All @@ -61,40 +61,63 @@ interactions:
response:
body: {string: ''}
headers:
Date: ['Mon, 05 Feb 2018 23:22:49 GMT']
ETag: ['"0x8D56CEF600197C2"']
Last-Modified: ['Mon, 05 Feb 2018 23:22:50 GMT']
Date: ['Thu, 08 Mar 2018 00:47:04 GMT']
ETag: ['"0x8D5848E1CE7E872"']
Last-Modified: ['Thu, 08 Mar 2018 00:47:04 GMT']
Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
Transfer-Encoding: [chunked]
x-ms-lease-id: [927b2bcf-266a-4059-9833-23b53801599f]
x-ms-request-id: [b553f81c-001e-0102-68d8-9e107b000000]
x-ms-lease-id: [b8fd1570-c475-419a-8cac-08d299cfc232]
x-ms-request-id: [cbf4af8e-501e-00cf-1c76-b66480000000]
x-ms-version: ['2017-07-29']
status: {code: 201, message: Created}
- request:
body: null
headers:
Connection: [keep-alive]
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.3; Darwin 17.3.0)]
x-ms-client-request-id: [7bf04bcc-0acb-11e8-b8f2-b8e8564491f6]
x-ms-date: ['Mon, 05 Feb 2018 23:22:50 GMT']
Content-Length: ['0']
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.2; Windows 10)]
x-ms-blob-public-access: [container]
x-ms-client-request-id: [38bf6d06-226a-11e8-8e8a-c8d3ffb16a1d]
x-ms-date: ['Thu, 08 Mar 2018 00:47:04 GMT']
x-ms-version: ['2017-07-29']
method: PUT
uri: https://storagename.blob.core.windows.net/container9840123e?restype=container&comp=acl
response:
body: {string: ''}
headers:
Date: ['Thu, 08 Mar 2018 00:47:04 GMT']
ETag: ['"0x8D5848E1CF90289"']
Last-Modified: ['Thu, 08 Mar 2018 00:47:04 GMT']
Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
Transfer-Encoding: [chunked]
x-ms-request-id: [cbf4af9b-501e-00cf-2776-b66480000000]
x-ms-version: ['2017-07-29']
status: {code: 200, message: OK}
- request:
body: null
headers:
Connection: [keep-alive]
User-Agent: [Azure-Storage/1.1.0-1.1.0 (Python CPython 3.6.2; Windows 10)]
x-ms-client-request-id: [38c81fe2-226a-11e8-8926-c8d3ffb16a1d]
x-ms-date: ['Thu, 08 Mar 2018 00:47:04 GMT']
x-ms-version: ['2017-07-29']
method: GET
uri: https://storagename.blob.core.windows.net/container9840123e?restype=container
response:
body: {string: ''}
headers:
Date: ['Mon, 05 Feb 2018 23:22:49 GMT']
ETag: ['"0x8D56CEF600197C2"']
Last-Modified: ['Mon, 05 Feb 2018 23:22:50 GMT']
Date: ['Thu, 08 Mar 2018 00:47:04 GMT']
ETag: ['"0x8D5848E1CF90289"']
Last-Modified: ['Thu, 08 Mar 2018 00:47:04 GMT']
Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
Transfer-Encoding: [chunked]
Vary: [Origin]
x-ms-blob-public-access: [container]
x-ms-lease-duration: [infinite]
x-ms-lease-state: [leased]
x-ms-lease-status: [locked]
x-ms-meta-hello: [world]
x-ms-meta-number: ['42']
x-ms-request-id: [b553f836-001e-0102-80d8-9e107b000000]
x-ms-request-id: [cbf4af9f-501e-00cf-2b76-b66480000000]
x-ms-version: ['2017-07-29']
status: {code: 200, message: OK}
version: 1