当前位置: 首页>>代码示例>>Python>>正文


Python AccessPolicy.start方法代码示例

本文整理汇总了Python中azure.storage.AccessPolicy.start方法的典型用法代码示例。如果您正苦于以下问题:Python AccessPolicy.start方法的具体用法?Python AccessPolicy.start怎么用?Python AccessPolicy.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure.storage.AccessPolicy的用法示例。


在下文中一共展示了AccessPolicy.start方法的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 start [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=')
开发者ID:huguesv,项目名称:azure-storage-python,代码行数:31,代码来源:test_storage_sas.py

示例2: test_sas_signed_identifier

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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])
开发者ID:afshinm,项目名称:azure-storage-python,代码行数:34,代码来源:test_table_entity.py

示例3: test_sign_request

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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))
开发者ID:algaruda,项目名称:azure-sdk-for-python,代码行数:28,代码来源:test_sharedaccesssignature.py

示例4: test_sas_signed_identifier

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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)
开发者ID:Siriuszyq,项目名称:azure-storage-python,代码行数:35,代码来源:test_common_blob.py

示例5: test_generate_signature_container

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:Albert-B-P,项目名称:azure-sdk-for-python,代码行数:14,代码来源:test_sharedaccesssignature.py

示例6: test_generate_signature_blob

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:0xc0decafe,项目名称:azure-sdk-for-python,代码行数:14,代码来源:test_sharedaccesssignature.py

示例7: test_generate_signature_blob

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:Albert-B-P,项目名称:azure-sdk-for-python,代码行数:14,代码来源:test_sharedaccesssignature.py

示例8: test_generate_signature_container

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:0xc0decafe,项目名称:azure-sdk-for-python,代码行数:14,代码来源:test_sharedaccesssignature.py

示例9: test_generate_signature_container

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:algaruda,项目名称:azure-sdk-for-python,代码行数:15,代码来源:test_sharedaccesssignature.py

示例10: test_blob_signed_query_string

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:algaruda,项目名称:azure-sdk-for-python,代码行数:17,代码来源:test_sharedaccesssignature.py

示例11: test_blob_signed_query_string

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:0xc0decafe,项目名称:azure-sdk-for-python,代码行数:17,代码来源:test_sharedaccesssignature.py

示例12: test_generate_signed_query_dict_container_with_access_policy

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=")
开发者ID:bbayles,项目名称:azure-storage-python,代码行数:17,代码来源:test_storage_sas.py

示例13: test_generate_signed_query_dict_blob_with_access_policy

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=")
开发者ID:bbayles,项目名称:azure-storage-python,代码行数:17,代码来源:test_storage_sas.py

示例14: test_generate_signature_blob

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:algaruda,项目名称:azure-sdk-for-python,代码行数:19,代码来源:test_sharedaccesssignature.py

示例15: test_container_signed_query_string

# 需要导入模块: from azure.storage import AccessPolicy [as 别名]
# 或者: from azure.storage.AccessPolicy import start [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=')
开发者ID:algaruda,项目名称:azure-sdk-for-python,代码行数:19,代码来源:test_sharedaccesssignature.py


注:本文中的azure.storage.AccessPolicy.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。