本文整理汇总了Python中azure.storage.AccessPolicy.permission方法的典型用法代码示例。如果您正苦于以下问题:Python AccessPolicy.permission方法的具体用法?Python AccessPolicy.permission怎么用?Python AccessPolicy.permission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure.storage.AccessPolicy
的用法示例。
在下文中一共展示了AccessPolicy.permission方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_signed_query_dict_blob_with_access_policy_and_headers
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signed_query_dict_blob_with_access_policy_and_headers(
self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11T11:03:40Z'
accss_plcy.expiry = '2011-10-12T11:53:40Z'
accss_plcy.permission = 'r'
query = self.sas._generate_signed_query_dict(
'images/pic1.png',
ResourceType.RESOURCE_BLOB,
SharedAccessPolicy(accss_plcy),
content_disposition='file; attachment',
content_type='binary',
)
self.assertEqual(query[QueryStringConstants.SIGNED_START],
'2011-10-11T11:03:40Z')
self.assertEqual(query[QueryStringConstants.SIGNED_EXPIRY],
'2011-10-12T11:53:40Z')
self.assertEqual(query[QueryStringConstants.SIGNED_RESOURCE],
ResourceType.RESOURCE_BLOB)
self.assertEqual(query[QueryStringConstants.SIGNED_PERMISSION], 'r')
self.assertEqual(
query[QueryStringConstants.SIGNED_CONTENT_DISPOSITION],
'file; attachment')
self.assertEqual(query[QueryStringConstants.SIGNED_CONTENT_TYPE],
'binary')
self.assertEqual(query[QueryStringConstants.SIGNED_SIGNATURE],
'uHckUC6T+BwUsc+DgrreyIS1k6au7uUd7LSSs/z+/+w=')
示例2: test_sas_signed_identifier
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_sas_signed_identifier(self):
# SAS URL is calculated from storage key, so this test runs live only
if TestMode.need_recording_file(self.test_mode):
return
# Arrange
entity = self._insert_random_entity()
access_policy = AccessPolicy()
access_policy.start = '2011-10-11'
access_policy.expiry = '2018-10-12'
access_policy.permission = TablePermissions.QUERY
identifiers = {'testid': access_policy}
entities = self.ts.set_table_acl(self.table_name, identifiers)
token = self.ts.generate_table_shared_access_signature(
self.table_name,
id='testid',
)
# Act
service = TableService(
account_name=self.settings.STORAGE_ACCOUNT_NAME,
sas_token=token,
)
self._set_service_options(service, self.settings)
entities = list(self.ts.query_entities(self.table_name, filter="PartitionKey eq '{}'".format(entity.PartitionKey)))
# Assert
self.assertEqual(len(entities), 1)
self._assert_default_entity(entities[0])
示例3: test_sign_request
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_sign_request(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'r'
sap = SharedAccessPolicy(accss_plcy)
qry_str = self.sas.generate_signed_query_string('images/pic1.png',
RESOURCE_BLOB,
sap)
permission = Permission()
permission.path = '/images/pic1.png'
permission.query_string = qry_str
self.sas.permission_set = [permission]
web_rsrc = WebResource()
web_rsrc.properties[SIGNED_RESOURCE_TYPE] = RESOURCE_BLOB
web_rsrc.properties[SHARED_ACCESS_PERMISSION] = 'r'
web_rsrc.path = '/images/pic1.png?comp=metadata'
web_rsrc.request_url = '/images/pic1.png?comp=metadata'
web_rsrc = self.sas.sign_request(web_rsrc)
self.assertEqual(web_rsrc.request_url,
'/images/pic1.png?comp=metadata&' +
self.sas._convert_query_string(qry_str))
示例4: test_sas_signed_identifier
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_sas_signed_identifier(self):
# SAS URL is calculated from storage key, so this test runs live only
if TestMode.need_recordingfile(self.test_mode):
return
# Arrange
blob_name = self._create_block_blob()
access_policy = AccessPolicy()
access_policy.start = '2011-10-11'
access_policy.expiry = '2018-10-12'
access_policy.permission = BlobPermissions.READ
identifiers = {'testid': access_policy}
resp = self.bs.set_container_acl(self.container_name, identifiers)
token = self.bs.generate_blob_shared_access_signature(
self.container_name,
blob_name,
id='testid'
)
# Act
service = BlockBlobService(
self.settings.STORAGE_ACCOUNT_NAME,
sas_token=token,
request_session=requests.Session(),
)
self._set_service_options(service, self.settings)
result = service.get_blob_to_bytes(self.container_name, blob_name)
# Assert
self.assertEqual(self.byte_data, result.content)
示例5: test_generate_signature_container
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_container(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'r'
signed_identifier = 'YWJjZGVmZw=='
sap = SharedAccessPolicy(accss_plcy, signed_identifier)
signature = self.sas._generate_signature('images',
sap,
X_MS_VERSION)
self.assertEqual(signature,
'1AWckmWSNrNCjh9krPXoD4exAgZWQQr38gG6z/ymkhQ=')
示例6: test_generate_signature_blob
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_blob(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11T11:03:40Z'
accss_plcy.expiry = '2011-10-12T11:53:40Z'
accss_plcy.permission = 'r'
sap = SharedAccessPolicy(accss_plcy)
signature = self.sas._generate_signature('images/pic1.png',
RESOURCE_BLOB,
sap)
self.assertEqual(signature,
'7NIEip+VOrQ5ZV80pORPK1MOsJc62wwCNcbMvE+lQ0s=')
示例7: test_generate_signature_blob
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_blob(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11T11:03:40Z'
accss_plcy.expiry = '2011-10-12T11:53:40Z'
accss_plcy.permission = 'r'
sap = SharedAccessPolicy(accss_plcy)
signature = self.sas._generate_signature('images/pic1.png',
sap,
X_MS_VERSION)
self.assertEqual(signature,
'ju4tX0G79vPxMOkBb7UfNVEgrj9+ZnSMutpUemVYHLY=')
示例8: test_generate_signature_container
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_container(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'r'
signed_identifier = 'YWJjZGVmZw=='
sap = SharedAccessPolicy(accss_plcy, signed_identifier)
signature = self.sas._generate_signature('images',
RESOURCE_CONTAINER,
sap)
self.assertEqual(signature,
'VdlALM4TYEYYNf94Bvt3dn48TsA01wk45ltwP3zeKp4=')
示例9: test_generate_signature_container
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_container(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'r'
signed_identifier = 'YWJjZGVmZw=='
sap = SharedAccessPolicy(accss_plcy, signed_identifier)
signature = self.sas._generate_signature('images',
sap,
X_MS_VERSION,
None, None, None, None, None)
self.assertEqual(signature,
'Md+SHy9BQNucdHnmDOEwlAkIWU5YxwlTq6gA9yJKE6w=')
示例10: test_blob_signed_query_string
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_blob_signed_query_string(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'w'
sap = SharedAccessPolicy(accss_plcy)
qry_str = self.sas.generate_signed_query_string('images/pic1.png',
RESOURCE_BLOB,
sap)
self.assertEqual(qry_str[SIGNED_START], '2011-10-11')
self.assertEqual(qry_str[SIGNED_EXPIRY], '2011-10-12')
self.assertEqual(qry_str[SIGNED_RESOURCE], RESOURCE_BLOB)
self.assertEqual(qry_str[SIGNED_PERMISSION], 'w')
self.assertEqual(qry_str[SIGNED_SIGNATURE],
'Fqt8tNcyUOp30qYRtSFNcImrRMcxlk6IF17O4l96KT8=')
示例11: test_blob_signed_query_string
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_blob_signed_query_string(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'w'
sap = SharedAccessPolicy(accss_plcy)
qry_str = self.sas.generate_signed_query_string('images/pic1.png',
RESOURCE_BLOB,
sap)
self.assertEqual(qry_str[SIGNED_START], '2011-10-11')
self.assertEqual(qry_str[SIGNED_EXPIRY], '2011-10-12')
self.assertEqual(qry_str[SIGNED_RESOURCE], RESOURCE_BLOB)
self.assertEqual(qry_str[SIGNED_PERMISSION], 'w')
self.assertEqual(qry_str[SIGNED_SIGNATURE],
'k8uyTrn3pgLXuhwgZhxeAH6mZ/es9k2vqHPJEuIH4CE=')
示例12: test_generate_signed_query_dict_container_with_access_policy
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signed_query_dict_container_with_access_policy(self):
accss_plcy = AccessPolicy()
accss_plcy.start = "2011-10-11"
accss_plcy.expiry = "2011-10-12"
accss_plcy.permission = "r"
query = self.sas._generate_signed_query_dict(
"images", ResourceType.RESOURCE_CONTAINER, SharedAccessPolicy(accss_plcy)
)
self.assertEqual(query[QueryStringConstants.SIGNED_START], "2011-10-11")
self.assertEqual(query[QueryStringConstants.SIGNED_EXPIRY], "2011-10-12")
self.assertEqual(query[QueryStringConstants.SIGNED_RESOURCE], ResourceType.RESOURCE_CONTAINER)
self.assertEqual(query[QueryStringConstants.SIGNED_PERMISSION], "r")
self.assertEqual(query[QueryStringConstants.SIGNED_SIGNATURE], "CxLWN56cjXidpI9em7RDgSN2QIgLggTqrnzudH2XsOY=")
示例13: test_generate_signed_query_dict_blob_with_access_policy
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signed_query_dict_blob_with_access_policy(self):
accss_plcy = AccessPolicy()
accss_plcy.start = "2011-10-11"
accss_plcy.expiry = "2011-10-12"
accss_plcy.permission = "w"
query = self.sas._generate_signed_query_dict(
"images/pic1.png", ResourceType.RESOURCE_BLOB, SharedAccessPolicy(accss_plcy)
)
self.assertEqual(query[QueryStringConstants.SIGNED_START], "2011-10-11")
self.assertEqual(query[QueryStringConstants.SIGNED_EXPIRY], "2011-10-12")
self.assertEqual(query[QueryStringConstants.SIGNED_RESOURCE], ResourceType.RESOURCE_BLOB)
self.assertEqual(query[QueryStringConstants.SIGNED_PERMISSION], "w")
self.assertEqual(query[QueryStringConstants.SIGNED_SIGNATURE], "Fqt8tNcyUOp30qYRtSFNcImrRMcxlk6IF17O4l96KT8=")
示例14: test_generate_signature_blob
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_generate_signature_blob(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11T11:03:40Z'
accss_plcy.expiry = '2011-10-12T11:53:40Z'
accss_plcy.permission = 'r'
sap = SharedAccessPolicy(accss_plcy)
signature = self.sas._generate_signature('images/pic1.png',
sap,
X_MS_VERSION,
None,
'file; attachment',
None,
None,
'binary')
self.assertEqual(signature,
'uHckUC6T+BwUsc+DgrreyIS1k6au7uUd7LSSs/z+/+w=')
示例15: test_container_signed_query_string
# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import permission [as 别名]
def test_container_signed_query_string(self):
accss_plcy = AccessPolicy()
accss_plcy.start = '2011-10-11'
accss_plcy.expiry = '2011-10-12'
accss_plcy.permission = 'r'
signed_identifier = 'YWJjZGVmZw=='
sap = SharedAccessPolicy(accss_plcy, signed_identifier)
qry_str = self.sas.generate_signed_query_string('images',
RESOURCE_CONTAINER,
sap)
self.assertEqual(qry_str[SIGNED_START], '2011-10-11')
self.assertEqual(qry_str[SIGNED_EXPIRY], '2011-10-12')
self.assertEqual(qry_str[SIGNED_RESOURCE], RESOURCE_CONTAINER)
self.assertEqual(qry_str[SIGNED_PERMISSION], 'r')
self.assertEqual(qry_str[SIGNED_IDENTIFIER], 'YWJjZGVmZw==')
self.assertEqual(qry_str[SIGNED_SIGNATURE],
'Md+SHy9BQNucdHnmDOEwlAkIWU5YxwlTq6gA9yJKE6w=')