Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Storage] [STG 98] OAuth Tests for Access Control Policies APIs #39446

Open
wants to merge 4 commits into
base: feature/storage-stg98
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-blob/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/storage/azure-storage-blob",
"Tag": "python/storage/azure-storage-blob_b11831f46e"
"Tag": "python/storage/azure-storage-blob_880ac66fab"
}
31 changes: 30 additions & 1 deletion sdk/storage/azure-storage-blob/tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,4 +2721,33 @@ def test_storage_account_audience_container_client(self, **kwargs):

# Assert
response = cc.exists()
assert response is not None
assert response is not None

@BlobPreparer()
@recorded_by_proxy
def test_get_and_set_access_policy_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")

token_credential = self.get_credential(BlobServiceClient)
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), token_credential)
container = self._create_container(bsc)

# Act
container.set_container_access_policy(signed_identifiers=dict())
weirongw23-msft marked this conversation as resolved.
Show resolved Hide resolved

# Assert
acl = container.get_container_access_policy()
assert acl is not None

@BlobPreparer()
@recorded_by_proxy
def test_get_account_information_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")

token_credential = self.get_credential(BlobServiceClient)
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), token_credential)
container = self._create_container(bsc)

# Act / Assert
cc_info = container.get_account_information()
assert cc_info is not None
31 changes: 30 additions & 1 deletion sdk/storage/azure-storage-blob/tests/test_container_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -2591,4 +2591,33 @@ async def test_storage_account_audience_container_client(self, **kwargs):

# Assert
response = await cc.exists()
assert response is not None
assert response is not None

@BlobPreparer()
@recorded_by_proxy_async
async def test_get_and_set_access_policy_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")

token_credential = self.get_credential(BlobServiceClient, is_async=True)
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), token_credential)
container: ContainerClient = await self._create_container(bsc)

# Act
await container.set_container_access_policy(signed_identifiers=dict())
weirongw23-msft marked this conversation as resolved.
Show resolved Hide resolved

# Assert
acl = await container.get_container_access_policy()
assert acl is not None

@BlobPreparer()
@recorded_by_proxy_async
async def test_get_account_information_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")

token_credential = self.get_credential(BlobServiceClient, is_async=True)
bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), token_credential)
container: ContainerClient = await self._create_container(bsc)

# Act / Assert
cc_info = await container.get_account_information()
assert cc_info is not None
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-datalake/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/storage/azure-storage-file-datalake",
"Tag": "python/storage/azure-storage-file-datalake_202e9f5227"
"Tag": "python/storage/azure-storage-file-datalake_8dda24ac6e"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,28 @@ def test_bad_audience_service_client(self, **kwargs):
fsc.exists()
fsc.create_directory('testdir22')

@DataLakePreparer()
@recorded_by_proxy
def test_get_and_set_access_control_oauth(self, **kwargs):
datalake_storage_account_name = kwargs.pop("datalake_storage_account_name")

# Arrange
token_credential = self.get_credential(DataLakeServiceClient)
dsc = DataLakeServiceClient(
self.account_url(datalake_storage_account_name, 'dfs'),
token_credential
)
file_system = dsc.create_file_system(self.get_resource_name(TEST_FILE_SYSTEM_PREFIX))
directory_client = file_system._get_root_directory_client()

# Act
acl = 'user::rwx,group::r-x,other::rwx'
directory_client.set_access_control(acl=acl)
access_control = directory_client.get_access_control()

# Assert
assert acl == access_control['acl']

# ------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,28 @@ async def test_bad_audience_service_client(self, **kwargs):
await fsc.exists()
await fsc.create_directory('testdir22')

@DataLakePreparer()
@recorded_by_proxy_async
async def test_get_and_set_access_control_oauth(self, **kwargs):
datalake_storage_account_name = kwargs.pop("datalake_storage_account_name")

# Arrange
token_credential = self.get_credential(DataLakeServiceClient, is_async=True)
dsc = DataLakeServiceClient(
self.account_url(datalake_storage_account_name, 'dfs'),
token_credential
)
file_system = await dsc.create_file_system(self.get_resource_name(TEST_FILE_SYSTEM_PREFIX))
directory_client = file_system._get_root_directory_client()

# Act
acl = 'user::rwx,group::r-x,other::rwx'
await directory_client.set_access_control(acl=acl)
access_control = await directory_client.get_access_control()

# Assert
assert acl == access_control['acl']

# ------------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-queue/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "python",
"TagPrefix": "python/storage/azure-storage-queue",
"Tag": "python/storage/azure-storage-queue_8161cc758c"
"Tag": "python/storage/azure-storage-queue_e30eb0be6d"
}
15 changes: 15 additions & 0 deletions sdk/storage/azure-storage-queue/tests/test_queue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,21 @@ def test_closing_pipeline_client_simple(self, **kwargs):
self.account_url(storage_account_name, "queue"), credential=storage_account_key, queue_name='queue')
service.close()

@QueuePreparer()
@recorded_by_proxy
def test_get_and_set_queue_access_policy_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")
self.setUp()

# Arrange
service_client = QueueServiceClient(self.account_url(storage_account_name, "queue"), self.token_credential)
queue_client = service_client.get_queue_client(self.get_resource_name("pyqueuesync"))
queue_client.create_queue()

# Act / Assert
queue_client.set_queue_access_policy(signed_identifiers=dict())
acl = queue_client.get_queue_access_policy()
assert acl is not None

# ------------------------------------------------------------------------------
if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,21 @@ async def test_closing_pipeline_client_simple(self, **kwargs):
self.account_url(storage_account_name, "queue"), credential=storage_account_key, queue_name='queue')
await service.close()

@QueuePreparer()
@recorded_by_proxy_async
async def test_get_and_set_queue_access_policy_oauth(self, **kwargs):
storage_account_name = kwargs.pop("storage_account_name")
self.setUp()

# Arrange
service_client = QueueServiceClient(self.account_url(storage_account_name, "queue"), self.token_credential)
queue_client = service_client.get_queue_client(self.get_resource_name("pyqueueasync"))
await queue_client.create_queue()

# Act / Assert
await queue_client.set_queue_access_policy(signed_identifiers=dict())
acl = await queue_client.get_queue_access_policy()
assert acl is not None

# ------------------------------------------------------------------------------
if __name__ == '__main__':
Expand Down