pay/tests/FunctionTest.php
yansongda 1ad9a4c09a
fix: 提前读取响应数据造成验签错误的问题 (#633)
* fix: 提前读取响应数据造成验签错误的问题
2022-07-21 22:18:15 +08:00

299 lines
18 KiB
PHP

<?php
namespace Yansongda\Pay\Tests;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\ServerRequest;
use Mockery;
use Yansongda\Pay\Contract\ConfigInterface;
use Yansongda\Pay\Contract\HttpClientInterface;
use Yansongda\Pay\Exception\InvalidConfigException;
use Yansongda\Pay\Parser\CollectionParser;
use Yansongda\Pay\Parser\NoHttpRequestParser;
use Yansongda\Pay\Parser\ResponseParser;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Provider\Wechat;
use Yansongda\Pay\Rocket;
use Yansongda\Supports\Str;
class FunctionTest extends TestCase
{
public function testShouldDoHttpRequest()
{
$rocket = new Rocket();
self::assertTrue(should_do_http_request($rocket->getDirection()));
$rocket->setDirection(CollectionParser::class);
self::assertTrue(should_do_http_request($rocket->getDirection()));
$rocket->setDirection(ResponseParser::class);
self::assertFalse(should_do_http_request($rocket->getDirection()));
$rocket->setDirection(NoHttpRequestParser::class);
self::assertFalse(should_do_http_request($rocket->getDirection()));
}
public function testGetAlipayConfig()
{
self::assertArrayHasKey('app_id', get_alipay_config([])->all());
Pay::clear();
$config2 = [
'alipay' => [
'default' => ['name' => 'yansongda'],
'c1' => ['age' => 28]
]
];
Pay::config($config2);
self::assertEquals(['name' => 'yansongda'], get_alipay_config([])->all());
self::assertEquals(['age' => 28], get_alipay_config(['_config' => 'c1'])->all());
}
public function testGetPublicCert()
{
$alipayPublicCertPath = __DIR__ . '/Cert/alipayCertPublicKey_RSA2.crt';
$alipayPublicCertCerPath = __DIR__ . '/Cert/alipayCertPublicKey_RSA2.cer';
self::assertEquals(file_get_contents($alipayPublicCertCerPath), get_public_cert($alipayPublicCertCerPath));
self::assertEquals(file_get_contents($alipayPublicCertPath), get_public_cert($alipayPublicCertPath));
}
public function testGetPrivateCert()
{
$appSecretCert = file_get_contents(__DIR__ . '/Cert/alipayAppSecretKey_RSA2_PKCS1.txt');
self::assertTrue(Str::contains(get_private_cert($appSecretCert), 'PRIVATE KEY'));
}
public function testVerifyAlipaySign()
{
verify_alipay_sign([], json_encode([
"code" => "10000",
"msg" => "Success",
"buyer_logon_id" => "ghd***@sandbox.com",
"buyer_pay_amount" => "0.00",
"buyer_user_id" => "2088102174698127",
"buyer_user_type" => "PRIVATE",
"invoice_amount" => "0.00",
"out_trade_no" => "yansongda-1622986519",
"point_amount" => "0.00",
"receipt_amount" => "0.00",
"send_pay_date" => "2021-06-06 21:35:40",
"total_amount" => "0.01",
"trade_no" => "2021060622001498120501382075",
"trade_status" => "TRADE_SUCCESS",
], JSON_UNESCAPED_UNICODE), base64_decode('Ipp1M3pwUFJ19Tx/D+40RZstXr3VSZzGxPB1Qfj1e837UkGxOJxFFK6EZ288SeEh06dPFd4qJ7BHfP/7mvkRqF1/mezBGvhBz03XTXfDn/O6IkoA+cVwpfm+i8MFvzC/ZQB0dgtZppu5qfzVyFaaNu8ct3L/NSQCMR1RXg2lH3HiwfxmIF35+LmCoL7ZPvTxB/epm7A/XNhAjLpK5GlJffPA0qwhhtQwaIZ7DHMXo06z03fbgxlBu2eEclQUm6Fobgj3JEERWLA0MDQiV1EYNWuHSSlHCMrIxWHba+Euu0jVkKKe0IFKsU8xJQbc7GTJXx/o0NfHqGwwq8hMvtgBkg=='));
self::assertTrue(true);
// test config error
$config1 = [
'alipay' => [
'default' => [
'alipay_public_cert_path' => ''
],
]
];
Pay::config(array_merge($config1, ['_force' => true]));
self::expectException(InvalidConfigException::class);
self::expectExceptionCode(InvalidConfigException::ALIPAY_CONFIG_ERROR);
verify_alipay_sign([], '', '');
}
public function testGetWechatConfig()
{
self::assertArrayHasKey('mp_app_id', get_wechat_config([])->all());
$config2 = [
'wechat' => [
'default' => ['name' => 'yansongda'],
'c1' => ['age' => 28]
]
];
Pay::config(array_merge($config2, ['_force' => true]));
self::assertEquals(['name' => 'yansongda'], get_wechat_config([])->all());
self::assertEquals(['age' => 28], get_wechat_config(['_config' => 'c1'])->all());
}
public function testGetWechatBaseUri()
{
self::assertEquals(Wechat::URL[Pay::MODE_NORMAL], get_wechat_base_uri([]));
$config2 = ['_force' => true, 'wechat' => [
'yansongda' => ['mode' => Pay::MODE_SANDBOX]
]];
Pay::config($config2);
self::assertEquals(Wechat::URL[Pay::MODE_SANDBOX], get_wechat_base_uri(['_config' => 'yansongda']));
}
public function testGetWechatAuthorization()
{
$params = [
'out_trade_no' => 1626493236,
'description' => 'yansongda 测试 - 1626493236',
'amount' => [
'total' => 1,
],
'scene_info' => [
'payer_client_ip' => '127.0.0.1',
'h5_info' => [
'type' => 'Wap',
]
]];
$timestamp = 1626493236;
$random = 'QqtzdVzxavZeXag9G5mtfzbfzFMf89p6';
$contents = "POST\n/v3/pay/transactions/h5\n1626493236\nQqtzdVzxavZeXag9G5mtfzbfzFMf89p6\n{\"out_trade_no\":1626493236,\"description\":\"yansongda 测试 - 1626493236\",\"amount\":{\"total\":1},\"scene_info\":{\"payer_client_ip\":\"127.0.0.1\",\"h5_info\":{\"type\":\"Wap\"}},\"appid\":\"wx55955316af4ef13\",\"mchid\":\"1600314069\",\"notify_url\":\"http:\/\/127.0.0.1:8000\/wechat\/notify\"}\n";
self::assertEquals(
'WECHATPAY2-SHA256-RSA2048 mchid="1600314069",nonce_str="QqtzdVzxavZeXag9G5mtfzbfzFMf89p6",timestamp="1626493236",serial_no="25F8AA5452D55497C24BA57DC81B1E5915DC2E77",signature="KzIgMgiop3nQJNdBVR2Xah/JUwVBLDFFajyXPiSN8b8YAYEA4FuWfaCgFJ52+WFed+PhOYWx/ZPih4RaEuuSdYB8eZwYUx7RZGMQZk0bKCctAjjPuf4pJN+f/WsXKjPIy3diqF5x7gyxwSCaKWP4/KjsHNqgQpiC8q1uC5xmElzuhzSwj88LIoLtkAuSmtUVvdAt0Nz41ECHZgHWSGR32TfBo902r8afdaVKkFde8IoqcEJJcp6sMxdDO5l9R5KEWxrJ1SjsXVrb0IPH8Nj7e6hfhq7pucxojPpzsC+ZWAYvufZkAQx3kTiFmY87T+QhkP9FesOfWvkIRL4E6MP6ug=="',
get_wechat_authorization($params, $timestamp, $random, $contents)
);
}
public function testGetWechatSign()
{
$params = [
'out_trade_no' => 1626493236,
'description' => 'yansongda 测试 - 1626493236',
'amount' => [
'total' => 1,
],
'scene_info' => [
'payer_client_ip' => '127.0.0.1',
'h5_info' => [
'type' => 'Wap',
]
]];
$contents = "POST\n/v3/pay/transactions/h5\n1626493236\nQqtzdVzxavZeXag9G5mtfzbfzFMf89p6\n{\"out_trade_no\":1626493236,\"description\":\"yansongda 测试 - 1626493236\",\"amount\":{\"total\":1},\"scene_info\":{\"payer_client_ip\":\"127.0.0.1\",\"h5_info\":{\"type\":\"Wap\"}},\"appid\":\"wx55955316af4ef13\",\"mchid\":\"1600314069\",\"notify_url\":\"http:\/\/127.0.0.1:8000\/wechat\/notify\"}\n";
self::assertEquals(
'KzIgMgiop3nQJNdBVR2Xah/JUwVBLDFFajyXPiSN8b8YAYEA4FuWfaCgFJ52+WFed+PhOYWx/ZPih4RaEuuSdYB8eZwYUx7RZGMQZk0bKCctAjjPuf4pJN+f/WsXKjPIy3diqF5x7gyxwSCaKWP4/KjsHNqgQpiC8q1uC5xmElzuhzSwj88LIoLtkAuSmtUVvdAt0Nz41ECHZgHWSGR32TfBo902r8afdaVKkFde8IoqcEJJcp6sMxdDO5l9R5KEWxrJ1SjsXVrb0IPH8Nj7e6hfhq7pucxojPpzsC+ZWAYvufZkAQx3kTiFmY87T+QhkP9FesOfWvkIRL4E6MP6ug==',
get_wechat_sign($params, $contents)
);
// test config error
$config1 = [
'wechat' => [
'default' => [
'mch_secret_cert' => ''
],
]
];
Pay::config(array_merge($config1, ['_force' => true]));
self::expectException(InvalidConfigException::class);
self::expectExceptionCode(InvalidConfigException::WECHAT_CONFIG_ERROR);
get_wechat_sign([], '', '');
}
public function testVerifyWechatSign()
{
$response = new Response(
200,
[
'Wechatpay-Nonce' => 'e59e78a6c3f7dfd7e84aabee71be0452',
'Wechatpay-Signature' => 'Bb10ZUsON47E/qLjecjk6ESLt7obZCvCCAXAEoD1Q+K548fz9h6YBgR3PZzviTmjsA3/r22qEC3r/yelFAn4pl4rJBGqrjo4ODJkOPlaDnHZwYotDvf6RcASpKB9ExCb33hAijHCiMzr9V9skNrj5F9eXc96lNZN3R5MVLsTF97nV922JIzyCrZ668khYPrn1jl5pCBpYDQ3rskgmZ+nnjg7M9vRAfTowEydSEGtsKjXUSaaKui2RDUuX8ZwxVcBTRng978Gh9s4mdRxs+mlv3gP1xQHdpa0mYMG0yGzLcWOTgrkt27sAwFnuXj9WtlEAgz/1DYntujKPxilMVGRow==',
'Wechatpay-Timestamp' => '1626444144',
'Wechatpay-Serial' => '45F59D4DABF31918AFCEC556D5D2C6E376675D57',
],
json_encode(['h5_url' => 'https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx16220223998099f898c5b24eed5c320000&package=4049184564'], JSON_UNESCAPED_SLASHES),
);
verify_wechat_sign($response, []);
self::assertTrue(true);
$serverRequest = new ServerRequest('POST', 'http://localhost');
verify_wechat_sign($serverRequest, []);
self::assertTrue(true);
$response = new Response(
200,
[
'Wechatpay-Nonce' => 'e59e78a6c3f7dfd7e84aabee71be0452',
'Wechatpay-Signature' => 'Bb10ZUsON47E/qLjecjk6ESLt7obZCvCCAXAEoD1Q+K548fz9h6YBgR3PZzviTmjsA3/r22qEC3r/yelFAn4pl4rJBGqrjo4ODJkOPlaDnHZwYotDvf6RcASpKB9ExCb33hAijHCiMzr9V9skNrj5F9eXc96lNZN3R5MVLsTF97nV922JIzyCrZ668khYPrn1jl5pCBpYDQ3rskgmZ+nnjg7M9vRAfTowEydSEGtsKjXUSaaKui2RDUuX8ZwxVcBTRng978Gh9s4mdRxs+mlv3gP1xQHdpa0mYMG0yGzLcWOTgrkt27sAwFnuXj9WtlEAgz/1DYntujKPxilMVGRow==',
'Wechatpay-Timestamp' => '1626444144',
'Wechatpay-Serial' => '45F59D4DABF31918AFCEC556D5D2C6E376675D57',
],
json_encode(['h5_url' => 'https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx16220223998099f898c5b24eed5c320000&package=4049184564'], JSON_UNESCAPED_SLASHES),
);
$response->getBody()->read(10);
verify_wechat_sign($response, []);
self::assertTrue(true);
}
public function testEncryptWechatContents()
{
$serialNo = '45F59D4DABF31918AFCEC556D5D2C6E376675D57';
$contents = 'yansongda';
$result = encrypt_wechat_contents($contents, get_wechat_config([])['wechat_public_cert_path.'.$serialNo]);
self::assertIsString($result);
}
public function testReloadWechatPublicCerts()
{
$response = new Response(
200,
[],
json_encode([
'data' => [
[
'effective_time' => '2021-07-16T17:51:10+08:00',
'encrypt_certificate' => [
'algorithm' => 'AEAD_AES_256_GCM',
'associated_data' => 'certificate',
'ciphertext' => 'kbbHAUhBwdjYZkHPW149MW/8WNpxQo1Gyp4kVNVjd+zrXnyOFhgZic2U2+tobFAgfdr93zr0JZF3FdbxgkaOAV2NAeCfU8jsUYXSfn7fM8487jXMVXKKEneGiiv1/bDLkz7KFsTfu2y5Rv+igWQ+bvCUQAwoNzjupTXnnDR5hBiofZcFLHL45govyYE2o0qD5SLiJHcFS4pg/IOx8SIqUFNepr3piKXUxKowU8/kNxXyRzL8yp7XnhrzAzclupvjveNwZyiw3TqlLZdR5TbEFLCogWaRHZRqz3vKEfgRaUYUtXCtQVrm+adbSDBFIq34v+XfeIHMz9pKhH/m80N5Hx69hPzbvIdBhzwaEDyN3h8gaeYKFyW9xIAs5jCrzzUEkKyMzOKzx7XA+1HRakSyvs6RlkRTa/ztBy6aZL0nxK6XMZ9tA7zdf2VnBX/7WPQYRzoky0cVyH1KRZxI7In2hfvpjSvl6P7Adzp+EZXYM/dINTrrg+RQRe60tPy7vgE8PZZf+SAWzSZPWIm7Lx6GksJX0vnT4gOeTAPw6EeFsYU/Z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VK1sQkjc5JFss1Std8FdDrHeM6agAB+MWncK1LloXZmiwz/6WmlwSDepnGHqLEciXThAZq6FwunJZTcHY9LamJgIY81c9t/KHlSFqlc/9mW4OZHM4BOZQ5sTj5PWE+OP2Aq9CKdJqoK3OmphBg2ewjrZt5/tSn9jpk6NlVrHD7MsJcKi5a0he4qvNPh1cHqUqWcF4rBFmfPptdHIBV77LXnizJZMUAwf16KsmJpwJg==',
'nonce' => '4196a5b75276',
],
'expire_time' => '2026-07-15T17:51:10+08:00',
'serial_no' => 'test-45F59D4DABF31918AFCEC556D5D2C6E376675D57',
]
]
])
);
$http = Mockery::mock(Client::class);
$http->shouldReceive('sendRequest')->andReturn($response);
Pay::set(HttpClientInterface::class, $http);
$result = reload_wechat_public_certs([], 'test-45F59D4DABF31918AFCEC556D5D2C6E376675D57');
self::assertTrue(false !== strpos($result, '-----BEGIN CERTIFICATE-----'));
self::assertTrue(Pay::get(ConfigInterface::class)->has('wechat.default.wechat_public_cert_path.test-45F59D4DABF31918AFCEC556D5D2C6E376675D57'));
self::assertIsArray(Pay::get(ConfigInterface::class)->get('wechat.default'));
}
public function testDecryptWechatResource()
{
$resource = [
'algorithm' => 'AEAD_AES_256_GCM',
'associated_data' => 'certificate',
'ciphertext' => 'kbbHAUhBwdjYZkHPW149MW/8WNpxQo1Gyp4kVNVjd+zrXnyOFhgZic2U2+tobFAgfdr93zr0JZF3FdbxgkaOAV2NAeCfU8jsUYXSfn7fM8487jXMVXKKEneGiiv1/bDLkz7KFsTfu2y5Rv+igWQ+bvCUQAwoNzjupTXnnDR5hBiofZcFLHL45govyYE2o0qD5SLiJHcFS4pg/IOx8SIqUFNepr3piKXUxKowU8/kNxXyRzL8yp7XnhrzAzclupvjveNwZyiw3TqlLZdR5TbEFLCogWaRHZRqz3vKEfgRaUYUtXCtQVrm+adbSDBFIq34v+XfeIHMz9pKhH/m80N5Hx69hPzbvIdBhzwaEDyN3h8gaeYKFyW9xIAs5jCrzzUEkKyMzOKzx7XA+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X39JdYayWl2HX0n8AsIRmevXzD4N9iDh2HGwie4gh92Qdcogwua++uhkhSsLFuWBpJiaPdxVtzz3E3jHfy+yryfh6msaXc/jmhwqBm/ii3j76lDP5YaRv4+JWZmom72+pmZuKD8qPKrPRxI2/aGiKEqgs25knpLLnbAhWAEYeIzVK1sQkjc5JFss1Std8FdDrHeM6agAB+MWncK1LloXZmiwz/6WmlwSDepnGHqLEciXThAZq6FwunJZTcHY9LamJgIY81c9t/KHlSFqlc/9mW4OZHM4BOZQ5sTj5PWE+OP2Aq9CKdJqoK3OmphBg2ewjrZt5/tSn9jpk6NlVrHD7MsJcKi5a0he4qvNPh1cHqUqWcF4rBFmfPptdHIBV77LXnizJZMUAwf16KsmJpwJg==',
'nonce' => '4196a5b75276',
];
$result = decrypt_wechat_resource($resource, []);
self::assertTrue(false !== strpos($result['ciphertext'], '-----BEGIN CERTIFICATE-----'));
}
public function testDecryptWechatResourceAes256Gcm()
{
$resource = [
'algorithm' => 'AEAD_AES_256_GCM',
'associated_data' => 'certificate',
'ciphertext' => 'kbbHAUhBwdjYZkHPW149MW/8WNpxQo1Gyp4kVNVjd+zrXnyOFhgZic2U2+tobFAgfdr93zr0JZF3FdbxgkaOAV2NAeCfU8jsUYXSfn7fM8487jXMVXKKEneGiiv1/bDLkz7KFsTfu2y5Rv+igWQ+bvCUQAwoNzjupTXnnDR5hBiofZcFLHL45govyYE2o0qD5SLiJHcFS4pg/IOx8SIqUFNepr3piKXUxKowU8/kNxXyRzL8yp7XnhrzAzclupvjveNwZyiw3TqlLZdR5TbEFLCogWaRHZRqz3vKEfgRaUYUtXCtQVrm+adbSDBFIq34v+XfeIHMz9pKhH/m80N5Hx69hPzbvIdBhzwaEDyN3h8gaeYKFyW9xIAs5jCrzzUEkKyMzOKzx7XA+1HRakSyvs6RlkRTa/ztBy6aZL0nxK6XMZ9tA7zdf2VnBX/7WPQYRzoky0cVyH1KRZxI7In2hfvpjSvl6P7Adzp+EZXYM/dINTrrg+RQRe60tP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Rv4+JWZmom72+pmZuKD8qPKrPRxI2/aGiKEqgs25knpLLnbAhWAEYeIzVK1sQkjc5JFss1Std8FdDrHeM6agAB+MWncK1LloXZmiwz/6WmlwSDepnGHqLEciXThAZq6FwunJZTcHY9LamJgIY81c9t/KHlSFqlc/9mW4OZHM4BOZQ5sTj5PWE+OP2Aq9CKdJqoK3OmphBg2ewjrZt5/tSn9jpk6NlVrHD7MsJcKi5a0he4qvNPh1cHqUqWcF4rBFmfPptdHIBV77LXnizJZMUAwf16KsmJpwJg==',
'nonce' => '4196a5b75276',
];
$result = decrypt_wechat_resource_aes_256_gcm(base64_decode($resource['ciphertext']), '53D67FCB97E68F9998CBD17ED7A8D1E2', $resource['nonce'] ?? '', $resource['associated_data'] ?? '');
self::assertTrue(false !== strpos($result, '-----BEGIN CERTIFICATE-----'));
}
}