Пример #1
0
    def test_post_failed(self, client):
        """
        Test that POST request succeeds when OPR00058 is not a success code.

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/trade/order'
        params = {
            'parentMerchantNo': '10000470992',
            'merchantNo': '10000470992',
            'orderId': '123',
            'orderAmount': '0.01',
            'notifyUrl': 'https://test.com',
        }
        res = client.post(api, params)
        # assert 'OPR00058' == res['result']['code']
        if 'prod' == client.env:
            if 'sm' == client.cert_type:
                assertion.failure(res, '40029')
            else:
                assert 'OPR10008' == res['result']['code']
        else:
            assertion.failure(res, '40042')
Пример #2
0
    def test_download_failed(self, client):
        """
        Test that downloading a file fails.

        Args:
            self: write your description
            client: write your description
        """
        if 'sm' == client.cert_type:
            return

        api = '/yos/v1.0/balance/yop-simple-remit/download-electronic-receipt'
        params = {
            'batchNo': '000000005499580',
            'orderId': 'YB654db6376fd04045a6abd82f055f6e042',
        }
        credentials = YopCredentials(
            appKey='OPR:10012413438',
            cert_type='RSA2048',
            priKey=
            'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcKXb/SKitY30pWKON9ra84xcgiRu8kN4z+jvxqyyKpIx6gnNLQE4+6wp5C9LviF3o7rqPFXDSifHLz94AVVKCT7a2mvx7lGk+y56p3GJzrvahjyxbaBMRyDI76tdOvl1T1qFRWFv4OXagDawUcUCKSrxlRej7uALSdeyKaoKnqC0eR2fpuFNbz6NxIqRREIUZiSqmehjUPgBidJuOPJ1/HGkzZhmWBB46QxvermojqoxHEsLi0NakfX/rW3GQC1I1KY58e9ukTnZ2lo8j8gZrbPuY/1WM2Q3pzPGd5OPdtcZGtaHKIrzHupf+Et6EDU8IbZFIDJ/1qQ0JXYpBODVNAgMBAAECggEAOY40zBkhBirNdiAzw76DEnIWU4kFHoY8R2b6kfM3avAD0KFk0f7k996UERIRD/SwPApE2ziZSRfLdQVreq73xoyPuJS96uRDt/+/Pja6WI3LW7dTr2rX4G1rSlcfPOf/qMdJ1Jve5cl0FcCERFKLaYzrC95s5N2ouJ367PcdqaHIHsOUetqHoOH6Z9VCmpHPpX/+RfdXkFS1XfenAPW1x90e1u9e7jWbPfYVhwzjegYyp1KzJsPavs3BwQvu2J4tFq7THKtjA31BelX133kuv3oFeq2J5dFnFfpe3s/p9HtHRGLSKt9Sf/Zy13uFw4kjZCwGnVFZr68LaifPsyJMpwKBgQC6D1yjPNfb7QMLBQZlWEx0ATqYLXbUes6ZdM88Qd/nd1HrweLtAdptofHVXdE4FKIQ75yt7pKKYj0sURhzhM13wchwjXUhBzZYUjOQ9YcUd1f9eaMheZoE149P+pwKB3Yck/hBIJk6W20fMr6vucroA4vbvnvaAmwrR3nNdRKX8wKBgQDW3QBoXnALNTC0iAe5B8z49CYcFqyGFDwtflXulSvRYlxpl4mRAOA+P2oQtaaElZre8LSlC6e93J4VxfvLDeVzFer+g8JuQNJDhvPsoYmT29s+A1kqicE6SU+KAFoMoubuHAClM0elle202IJqdWt/pt/Yl+Z44MBvFzsrvLiNvwKBgQCJIql053Nydc64YIvGRr6TAhTd9SSQl7OPB7l3AFa3lAqdadqINcV46NQGH5AFda++K92flSgNNzs/XsZW3ptSmVHTI3AhV9+GWZAIV++n9g60lOLX2Xjb+MV4fY5lFfrINYfU+OH3UUusowpJGvei6no7DLrchMyVWak89f0uYQKBgHNXTfm5AHKzygKPp32nd1wJTE/1yAVt5WQSlrSttUkAgVVZuMpzau1fg2OW793qpamaE48p85ETVnWfw2wceJjQIkcgmgYvm/AOCPF1QfJyqn3etEYGjwjoA9+0EqMH6+nUdHA6V/LGykUzmMbnY56yCSYvXNR06jh4gxYWiAfnAoGAXh30ObSnOrf3befSF6qAHtEWBAf3oAXnpVKdqNaAy+Py/myJ6fvjENY3ZfzROkZqu5BSyuqiUw+V50WFM6hDgbEXJoRXdm41M9S8JwFBl5qAe1e3BZdbxbUK7G/qM4PQuTaArkvuz0wbJiZ2soFzi6S2ktDraafk+ErRgJx+q1k='
        )
        file_path = os.environ['HOME']
        res = client.download(api, params, credentials, file_path=file_path)
        assertion.failure(res, '40044')
        assertion.failure(res, 'isp.code.data-not-fund', 'subCode')
Пример #3
0
    def test_post(self, client):
        """
        Test POST request.

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/trade/order'
        params = {
            'orderId': '140676',
            'orderType': 'REALTIME',
            'salesProductCode': 'DSBZB',
            'bizSystemNo': 'DS',
            'assureType': 'REALTIME',
            'assurePeriod': '30',
            'productVersion': 'DSBZB',
            'goodsParamExt':
            '{\"goodsDesc\":\"微商平台H5订单:2020112719083965\", \"goodsName\":\"kk\"}',
            'orderAmount': '898.00',
            'notifyUrl': 'http://apitest.gouwu.cn/pay/yop/notify',
            'timeoutExpressType': 'MINUTE',
            'timeoutExpress': '30',
            'parentMerchantNo': '10000466938',
            'merchantNo': '10000466938'
        }
        res = client.post(api, params)
        if 'prod' == client.env:
            if 'sm' == client.cert_type:
                assertion.failure(res, '40029')
            else:
                assert 'OPR10008' == res['result']['code']
            # assertion.success(res)
        else:
            assertion.failure(res, '40042')
Пример #4
0
    def test_post_404(self, client):
        """
        Test POSTing a 404 http resource

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/bank/xxx'
        params = {
            'name': '张三',
            'bankCardNo': '6214830128005989',
            'goods': ['苹果', '香蕉', '草莓']
        }
        res = client.post(api, params)
        assertion.failure(res, '40042')
Пример #5
0
    def test_post_json_failed(self, client):
        """
        Test that POST request succeeds when JSON is not successful.

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/std/eaccount/topupquery1'
        params = {
            'parentMerchantNo': '10000470992',
            'merchantNo': '10000470992',
            'orderId': ['苹果', '香蕉', '草莓']
        }
        res = client.post_json(api, params)
        assertion.failure(res, '40042')
Пример #6
0
    def test_get_failed(self, client):
        """
        Test that getting a resource fails on an untrusted endpoint

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/bank/xxx'
        params = {
            'name': '张三',
            'bankCardNo': '6214830128005989',
            'goods': ['苹果', '香蕉', '草莓']
        }
        res = client.get(api, params)
        assertion.failure(res, '40042')
Пример #7
0
    def test_upload_failed(self, client):
        """
        Test that uploading a file fails.

        Args:
            self: write your description
            client: write your description
        """
        file_path = './LICENSE'
        api = '/yos/v1.0/mer/merchant/qual/upload2'
        params = {
            'merQual': ('file_name', open(file_path,
                                          mode='rb'), 'multipart/form-data'),
            'remark':
            '演示普通参数传递,该api没有remark参数'
        }
        res = client.upload(api, params)
        assertion.failure(res, '40042')
Пример #8
0
    def test_get(self, client):
        """
        Run the get test.

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/cnppay/bank-limit/query'
        params = {'merchantNo': '10000470992'}
        res = client.get(api, params)
        if 'prod' == client.env:
            if 'sm' == client.cert_type:
                assertion.failure(res, '40029')
            else:
                assertion.success(res)
                assert '00000' == res['result']['code']
        else:
            assert '40042' == res['code']
Пример #9
0
    def test_post_json_failed(self, client):
        """
        Test that POST request with json fails.

        Args:
            self: write your description
            client: write your description
        """
        api = '/rest/v1.0/std/eaccount/topupquery'
        params = {
            'parentMerchantNo':
            '10000470992',
            'merchantNo':
            '10000470992',
            'orderId': ['苹果', '香蕉', '草莓'],
            'productInfo':
            '[{\"productCode\":\"MERCHANT_SCAN_ALIPAY_OFFLINE\",\"rateType\":\"SINGLE_PERCENT\",\"percentRate\":\"0.1\"},{\"productCode\":\"MERCHANT_SCAN_UNIONPAY_CREDIT\",\"rateType\":\"SINGLE_FIXED\",\"fixedRate\":\"1\"}]'
        }
        res = client.post_json(api, params)
        assertion.failure(res, '40020')
Пример #10
0
    def test_post_with_credentials(self, client):
        """
        Test POST request with credentials.

        Args:
            self: write your description
            client: write your description
        """
        if 'sm' == client.cert_type:
            return

        api = '/rest/v1.0/trade/order'
        params = {
            'orderId': '140676',
            'orderType': 'REALTIME',
            'salesProductCode': 'DSBZB',
            'bizSystemNo': 'DS',
            'assureType': 'REALTIME',
            'assurePeriod': '30',
            'productVersion': 'DSBZB',
            'goodsParamExt':
            '{\"goodsDesc\":\"微商平台H5订单:2020112719083965\", \"goodsName\":\"kk\"}',
            'orderAmount': '898.00',
            'notifyUrl': 'http://apitest.gouwu.cn/pay/yop/notify',
            'timeoutExpressType': 'MINUTE',
            'timeoutExpress': '30',
            'parentMerchantNo': '10000466938',
            'merchantNo': '10000466938'
        }
        credentials = YopCredentials(
            appKey='OPR:10000470992',
            priKey=
            'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCMTXz1XQeTx+Eq/Zom7RQeam15IZ23CNCgxl/lG93JFQlGNszQn9yaXlrD4BH99tN6816Ven0pi3+NN0oiunwqfAAiRrxBPXmZKRCjQRKqzAiBYcGZsW9kmzDoCfBLGmmHSWxs58Z3+iAU6RrHLJ5BPhSxpEzed8h5d0pNe8ltDlS9fTr9IvWpVkLKKAPdAmUbRZlbUm/sabdkB9fXGK+dSee+tTJ8lzW2UeSLHeZKKeCbkNckmlD8K+Fgk3N3uEoS0pixycg92VQZrIaH3fKTO/cV1HkubyNEwCF6EwSyOvmyXUr4WqOHzeg+ikPufH1nQvdsudjAv1DN7be65oz7AgMBAAECggEAakL19U+0QXUNUOYqLnk416B7sVaIgOwoNtyIHJnybC2GjKtMjGXHSxNTYy798X9TxLc2V7ghu6lvvaC2gX8EM5ke8NbqFe9dfWbgtwS+AqXtezBy1NjSKTxw2g1M9VTXwCMX/5O7eXrzeWLjaR6d7YP7YF+z6HqIV5bFq9GpSPKGjaiYlZ5rRf0nwen0+BI2wvIRxglvpHvB0zUK3r330Z2gNQvnM2R7YW6Y0zIb3O7ASu+Qh2nGyI4J+OayP1bBohSyZ8KVHc+rDZ3lZRF9Tsj9p9A+JcDS2cLosVRfnVefhRn1356noEB8uR3zNhLHAgEJ3ddZM6DB0u3aKMmIYQKBgQDByH0e8mR3yoFnf6XG2qzflIxwvRPZx7EUhfGby3FlpbN1d3a3yTIt5vyrXRxbFwhdhGOFHJuqhK8+oR/DBTGB+tMNuQh5pdj4D4DW5kfyeOmeNRVQCJ0s5KqmB9GpGD2h49R6k0np3qWp3rtpamPXF8sT22Gp3dP5dYS39KE1dQKBgQC5WU8MuRMHkyhhFSZ12v8blZKeJdSEnlbbmxtB8mXWNpr/C3+bhurn97dz4kx6Od0OBrG6TS0uPhwtM9gPO4q3i0SHF0MWRXS63r08tKyztTOF/fMD0UMoOaQLduQ/uKZnJuLJnrQO7lRjIQQ+KOFFzGJE6CEgSRcsQCFNuOy6rwKBgGXqsAOqsDRgiRaKCAJB2FHuqr5QczRC1ltY5u1tXkJ7l5rcLdATPRTvO0xVOCigQIIOsti7ZxOTnSdvTmkfPh6CcKXy/wYbt7UfUj+z9XsNJLFUcdUZ8rA9w5J24knwudl/Ha0p8eHSe4aP4jla/w+NL/1NkFvqkyXMLPUi7/ZRAoGAbwzlYfgZQLaYwOINMxvNMVfCiuKbnAHKhLU/9ZkoDtqUry7Se/qwD9/JmLMDo0+79EVqgvbulQA9nY+saiQAjsvweQgk99kRgU0nEJInz1xHzIZE7gqZNCak9QF86/jUKoWP58EgnLmK8gG8KwoPPuSgFC0Ie/GO4sJhsdGUdJ0CgYEApuMUHLIuO/ABwfs/r0KsiJzbgvd7QLGhgjjmIW2x7U3um0JMz7zYJRSKENK9ACOGWoTtRjO5e/7ox1LeGvEzgJ7nSXn+ALW3HvknpvgQrXeCnyQ5UPRYjMP1mnILEgs/LL5vXjofyQWJNULU6q+FkVVjvkKyFUQQ3HI0KUyVlfk=',
            cert_type='RSA2048')
        res = client.post(api, params, credentials)
        if 'prod' == client.env:
            assert 'OPR10008' == res['result']['code']
            assertion.success(res)
        else:
            assertion.failure(res, '40042')