Skip to content

Commit 8c114a6

Browse files
[Storage] Fix Public Access Tests (w/ recordings) (#36593)
1 parent 2206169 commit 8c114a6

File tree

7 files changed

+17
-139
lines changed

7 files changed

+17
-139
lines changed

sdk/storage/azure-storage-blob/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/storage/azure-storage-blob",
5-
"Tag": "python/storage/azure-storage-blob_4bb162f320"
5+
"Tag": "python/storage/azure-storage-blob_adfb24f3d6"
66
}

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

Lines changed: 1 addition & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,72 +1881,6 @@ def test_create_blob_blob_unicode_data(self, **kwargs):
18811881
# Assert
18821882
assert resp.get('etag') is not None
18831883

1884-
@pytest.mark.live_test_only
1885-
@BlobPreparer()
1886-
def test_no_sas_private_blob(self, **kwargs):
1887-
# Test Proxy playback does not currently work with requests outside SDK clients
1888-
storage_account_name = kwargs.pop("storage_account_name")
1889-
storage_account_key = kwargs.pop("storage_account_key")
1890-
1891-
self._setup(storage_account_name, storage_account_key)
1892-
blob_name = self._create_block_blob()
1893-
blob = self.bsc.get_blob_client(self.container_name, blob_name)
1894-
1895-
# Act
1896-
response = requests.get(blob.url)
1897-
1898-
# Assert
1899-
assert not response.ok
1900-
assert -1 != response.text.find('ResourceNotFound')
1901-
1902-
@pytest.mark.live_test_only
1903-
@BlobPreparer()
1904-
def test_no_sas_public_blob(self, **kwargs):
1905-
# Test Proxy playback does not currently work with requests outside SDK clients
1906-
storage_account_name = kwargs.pop("storage_account_name")
1907-
storage_account_key = kwargs.pop("storage_account_key")
1908-
1909-
self._setup(storage_account_name, storage_account_key)
1910-
data = b'a public blob can be read without a shared access signature'
1911-
blob_name = 'blob1.txt'
1912-
container_name = self._get_container_reference()
1913-
try:
1914-
container = self.bsc.create_container(container_name, public_access='blob')
1915-
except ResourceExistsError:
1916-
container = self.bsc.get_container_client(container_name)
1917-
blob = container.upload_blob(blob_name, data, overwrite=True)
1918-
1919-
# Act
1920-
response = requests.get(blob.url)
1921-
1922-
# Assert
1923-
assert response.ok
1924-
assert data == response.content
1925-
1926-
@BlobPreparer()
1927-
@recorded_by_proxy
1928-
def test_public_access_blob(self, **kwargs):
1929-
storage_account_name = kwargs.pop("storage_account_name")
1930-
storage_account_key = kwargs.pop("storage_account_key")
1931-
1932-
self._setup(storage_account_name, storage_account_key)
1933-
data = b'public access blob'
1934-
blob_name = 'blob1.txt'
1935-
container_name = self._get_container_reference()
1936-
try:
1937-
container = self.bsc.create_container(container_name, public_access='blob')
1938-
except ResourceExistsError:
1939-
container = self.bsc.get_container_client(container_name)
1940-
blob = container.upload_blob(blob_name, data, overwrite=True)
1941-
1942-
# Act
1943-
service = BlobClient.from_blob_url(blob.url)
1944-
#self._set_test_proxy(service, self.settings)
1945-
content = service.download_blob().readall()
1946-
1947-
# Assert
1948-
assert data == content
1949-
19501884
@pytest.mark.live_test_only
19511885
@BlobPreparer()
19521886
def test_sas_access_blob(self, **kwargs):
@@ -3494,4 +3428,4 @@ def test_upload_blob_partial_stream_chunked(self, **kwargs):
34943428
result = blob.download_blob().readall()
34953429
assert result == data[:length]
34963430

3497-
# ------------------------------------------------------------------------------
3431+
# ------------------------------------------------------------------------------

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

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,74 +2107,6 @@ async def test_create_blob_blob_unicode_data(self, **kwargs):
21072107
# Assert
21082108
assert resp.get('etag') is not None
21092109

2110-
@pytest.mark.live_test_only
2111-
@BlobPreparer()
2112-
async def test_no_sas_private_blob(self, **kwargs):
2113-
# Test Proxy playback does not currently work with requests outside SDK clients
2114-
storage_account_name = kwargs.pop("storage_account_name")
2115-
storage_account_key = kwargs.pop("storage_account_key")
2116-
2117-
# Arrange
2118-
await self._setup(storage_account_name, storage_account_key)
2119-
blob_name = await self._create_block_blob()
2120-
blob = self.bsc.get_blob_client(self.container_name, blob_name)
2121-
2122-
# Act
2123-
response = requests.get(blob.url)
2124-
2125-
# Assert
2126-
assert not response.ok
2127-
assert -1 != response.text.find('ResourceNotFound')
2128-
2129-
@pytest.mark.live_test_only
2130-
@BlobPreparer()
2131-
async def test_no_sas_public_blob(self, **kwargs):
2132-
# Test Proxy playback does not currently work with requests outside SDK clients
2133-
storage_account_name = kwargs.pop("storage_account_name")
2134-
storage_account_key = kwargs.pop("storage_account_key")
2135-
2136-
# Arrange
2137-
await self._setup(storage_account_name, storage_account_key)
2138-
data = b'a public blob can be read without a shared access signature'
2139-
blob_name = 'blob1.txt'
2140-
container_name = self._get_container_reference()
2141-
try:
2142-
container = await self.bsc.create_container(container_name, public_access='blob')
2143-
except ResourceExistsError:
2144-
container = self.bsc.get_container_client(container_name)
2145-
blob = await container.upload_blob(blob_name, data)
2146-
2147-
# Act
2148-
response = requests.get(blob.url)
2149-
2150-
# Assert
2151-
assert response.ok
2152-
assert data == response.content
2153-
2154-
@BlobPreparer()
2155-
@recorded_by_proxy_async
2156-
async def test_public_access_blob(self, **kwargs):
2157-
storage_account_name = kwargs.pop("storage_account_name")
2158-
storage_account_key = kwargs.pop("storage_account_key")
2159-
2160-
# Arrange
2161-
await self._setup(storage_account_name, storage_account_key)
2162-
data = b'public access blob'
2163-
blob_name = 'blob1.txt'
2164-
container_name = self._get_container_reference()
2165-
try:
2166-
container = await self.bsc.create_container(container_name, public_access='blob')
2167-
except ResourceExistsError:
2168-
container = self.bsc.get_container_client(container_name)
2169-
blob = await container.upload_blob(blob_name, data)
2170-
2171-
# Act
2172-
service = BlobClient.from_blob_url(blob.url)
2173-
content = await (await service.download_blob()).readall()
2174-
2175-
# Assert
2176-
assert data == content
2177-
21782110
@pytest.mark.live_test_only
21792111
@BlobPreparer()
21802112
async def test_sas_access_blob(self, **kwargs):
@@ -3418,4 +3350,4 @@ async def test_upload_blob_partial_stream_chunked(self, **kwargs):
34183350
# Assert
34193351
result = await (await blob.download_blob()).readall()
34203352
assert result == data[:length]
3421-
# ------------------------------------------------------------------------------
3353+
# ------------------------------------------------------------------------------

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def test_create_container_with_already_existing_container_fail_on_exist(self, **
8888
# Assert
8989
assert created
9090

91+
@pytest.mark.playback_test_only
9192
@BlobPreparer()
9293
@recorded_by_proxy
9394
def test_create_container_with_public_access_container(self, **kwargs):
@@ -104,6 +105,7 @@ def test_create_container_with_public_access_container(self, **kwargs):
104105
# Assert
105106
assert created
106107

108+
@pytest.mark.playback_test_only
107109
@BlobPreparer()
108110
@recorded_by_proxy
109111
def test_create_container_with_public_access_blob(self, **kwargs):
@@ -329,6 +331,7 @@ def test_list_containers_with_include_metadata(self, **kwargs):
329331
self.assertNamedItemInContainer(containers, container.container_name)
330332
assert containers[0].metadata == metadata
331333

334+
@pytest.mark.playback_test_only
332335
@BlobPreparer()
333336
@recorded_by_proxy
334337
def test_list_containers_with_public_access(self, **kwargs):
@@ -681,6 +684,7 @@ def test_set_container_acl_with_lease_id(self, **kwargs):
681684

682685
return variables
683686

687+
@pytest.mark.playback_test_only
684688
@BlobPreparer()
685689
@recorded_by_proxy
686690
def test_set_container_acl_with_public_access(self, **kwargs):
@@ -2717,4 +2721,4 @@ def test_storage_account_audience_container_client(self, **kwargs):
27172721

27182722
# Assert
27192723
response = cc.exists()
2720-
assert response is not None
2724+
assert response is not None

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ async def test_create_cntnr_w_existing_cntnr_fail_on_exist(self, **kwargs):
101101
# Assert
102102
assert created
103103

104+
@pytest.mark.playback_test_only
104105
@BlobPreparer()
105106
@recorded_by_proxy_async
106107
async def test_create_container_with_public_access_container(self, **kwargs):
@@ -117,6 +118,7 @@ async def test_create_container_with_public_access_container(self, **kwargs):
117118
# Assert
118119
assert created
119120

121+
@pytest.mark.playback_test_only
120122
@BlobPreparer()
121123
@recorded_by_proxy_async
122124
async def test_create_container_with_public_access_blob(self, **kwargs):
@@ -382,6 +384,7 @@ async def test_list_containers_with_include_metadata(self, **kwargs):
382384
self.assertNamedItemInContainer(containers, container.container_name)
383385
assert containers[0].metadata == metadata
384386

387+
@pytest.mark.playback_test_only
385388
@BlobPreparer()
386389
@recorded_by_proxy_async
387390
async def test_list_containers_with_public_access(self, **kwargs):
@@ -748,6 +751,7 @@ async def test_set_container_acl_with_lease_id(self, **kwargs):
748751

749752
return variables
750753

754+
@pytest.mark.playback_test_only
751755
@BlobPreparer()
752756
@recorded_by_proxy_async
753757
async def test_set_container_acl_with_public_access(self, **kwargs):
@@ -2587,4 +2591,4 @@ async def test_storage_account_audience_container_client(self, **kwargs):
25872591

25882592
# Assert
25892593
response = await cc.exists()
2590-
assert response is not None
2594+
assert response is not None

sdk/storage/azure-storage-file-datalake/tests/test_file_system.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def test_create_file_system_with_metadata(self, **kwargs):
315315
assert created
316316
assert meta == metadata
317317

318+
@pytest.mark.playback_test_only
318319
@DataLakePreparer()
319320
@recorded_by_proxy
320321
def test_set_file_system_acl(self, **kwargs):
@@ -653,6 +654,7 @@ def test_list_file_systems_by_page(self, **kwargs):
653654
assert file_systems is not None
654655
assert len(file_systems) >= 3
655656

657+
@pytest.mark.playback_test_only
656658
@DataLakePreparer()
657659
@recorded_by_proxy
658660
def test_list_file_systems_with_public_access(self, **kwargs):

sdk/storage/azure-storage-file-datalake/tests/test_file_system_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ async def test_list_file_systems_with_include_metadata_async(self, **kwargs):
595595
self.assertNamedItemInContainer(file_systems, file_system.file_system_name)
596596
assert file_systems[0].metadata == metadata
597597

598+
@pytest.mark.playback_test_only
598599
@DataLakePreparer()
599600
@recorded_by_proxy_async
600601
async def test_set_file_system_acl(self, **kwargs):
@@ -653,6 +654,7 @@ async def test_list_file_systems_by_page(self, **kwargs):
653654
assert file_systems is not None
654655
assert len(file_systems) >= 3
655656

657+
@pytest.mark.playback_test_only
656658
@DataLakePreparer()
657659
@recorded_by_proxy_async
658660
async def test_list_file_systems_with_public_access_async(self, **kwargs):

0 commit comments

Comments
 (0)