def test_user_openapi(self):
        """
        获取Iam认证-openapi
        """
        # 测试数据准备
        self.method = 'get'
        self.path = '/uos/oss'
        self.params = {
            'Action': 'iamAndValidatedUser',
            'UserAccessKeyId': readconfig.get_params('accessKey')
        }
        # 生成请求signature
        signature = Signature.sign(data=self.params,
                                   ak=readconfig.get_params('accessKey'),
                                   sk=readconfig.get_params('secretKey'),
                                   method='GET')
        # 添加ak 与 signature 参数
        self.params.setdefault('AccessKeyId',
                               readconfig.get_params('accessKey'))
        self.params.setdefault(
            'Signature',
            urllib.parse.unquote(signature))  # python 会对参数自动进行编码,所以先进行解码

        new_url = openapiUrl + self.path
        print(new_url)
        info = RunMain().run_main(self.method, url=new_url, data=self.params)
        ss = json.loads(info)  # 将响应转换为字典格式
        self.assertEqual(ss['code'], '0')
    def test_user_url_openapi(self):
        """
        获取Iam认证
        """
        # 测试数据准备
        # baseUrl生成
        original_url = 'http://' + bucketName + '.' + endpoint + '/' + objectName
        base_url = Signature.url_base64(original_url)
        # Authorization 生成
        key = 'UnicloudSmaug'
        time_stamp = time.time()
        params = {'timeStamp': int(round(time_stamp * 1000))}
        token = JWTUtils.jwt_token(params=params, key=key)

        self.method = 'get'
        self.path = '/uos/oss'
        self.params = {
            'Action': 'covertToPresignedUrl',
            'baseUrl': base_url,
            'expire': 2000
        }
        self.headers = {'Authorization': 'Bearer ' + token}
        # 生成请求signature
        signature = Signature.sign(data=self.params,
                                   ak=readconfig.get_params('accessKey'),
                                   sk=readconfig.get_params('secretKey'),
                                   method='GET')
        print('signature : ' + signature)
        # 添加ak 与 signature 参数
        self.params.setdefault('AccessKeyId',
                               readconfig.get_params('accessKey'))
        self.params.setdefault(
            'Signature',
            urllib.parse.unquote(signature))  # python 会对参数自动进行编码,所以先进行解码

        new_url = openapiUrl + self.path
        info = RunMain().run_main(self.method,
                                  url=new_url,
                                  data=self.params,
                                  headers=self.headers)
        ss = json.loads(info)  # 将响应转换为字典格式
        self.assertEqual(ss['code'], '0')
    def test_user_getIamAndValidatedChildUser(self):
        """
        获取子账号Iam认证
        """
        # 测试数据准备
        self.method = 'get'
        self.path = '/pco/v1/oss/iamValidation/access/info'
        self.params = {'UserAccessKeyId': readconfig.get_params('accessKey')}
        # 生成请求signature
        signature = Signature.sign(data=self.params,
                                   ak=readconfig.get_params('accessKey'),
                                   sk=readconfig.get_params('secretKey'),
                                   method='GET')
        # 添加ak 与 signature 参数
        self.params.setdefault('AccessKeyId',
                               readconfig.get_params('accessKey'))
        self.params.setdefault(
            'Signature',
            urllib.parse.unquote(signature))  # python 会对参数自动进行编码,所以先进行解码

        new_url = url + self.path
        info = RunMain().run_main(self.method, url=new_url, data=self.params)
        ss = json.loads(info)  # 将响应转换为字典格式
        self.assertEqual(ss['code'], '0')
    def test_region_endpoint(self):
        """
        获取某地域信息
        """
        # 测试数据准备
        self.method = 'get'
        self.path = '/pco/v1/oss/overview/getEndpoint'
        self.params = {
            'regionId': readconfig.get_params('regionId')
        }

        # 生成请求signature
        signature = Signature.sign(data=self.params,
                                   ak=readconfig.get_params('accessKey'),
                                   sk=readconfig.get_params('secretKey'),
                                   method='GET')
        # 添加ak 与 signature 参数
        self.params.setdefault('AccessKeyId', readconfig.get_params('accessKey'))
        self.params.setdefault('Signature', urllib.parse.unquote(signature))  # python 会对参数自动进行编码,所以先进行解码

        new_url = url + self.path
        info = RunMain().run_main(self.method, url=new_url, data=self.params)
        ss = json.loads(info)  # 将响应转换为字典格式
        self.assertEqual(ss['code'], '0')