提交
This commit is contained in:
33
tests/customer_center_proxy_self_check.php
Normal file
33
tests/customer_center_proxy_self_check.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use app\miniapi\service\CustomerCenter\CustomerCenterService;
|
||||
|
||||
function customerCenterProxyAssertSame(mixed $expected, mixed $actual, string $message): void
|
||||
{
|
||||
if ($expected !== $actual) {
|
||||
throw new RuntimeException($message . PHP_EOL
|
||||
. 'Expected: ' . var_export($expected, true) . PHP_EOL
|
||||
. 'Actual: ' . var_export($actual, true));
|
||||
}
|
||||
}
|
||||
|
||||
$service = new CustomerCenterService();
|
||||
customerCenterProxyAssertSame([
|
||||
'user_id' => 42,
|
||||
'page' => 2,
|
||||
], $service->payload(42, ['page' => 2]), 'The proxy request must use the original unsigned parameter style');
|
||||
customerCenterProxyAssertSame(
|
||||
'https://uniuser.jzvisa.com/home/customer_center/applications',
|
||||
$service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin', 'applications'),
|
||||
'The proxy endpoint must stay on the configured unified API host'
|
||||
);
|
||||
customerCenterProxyAssertSame(
|
||||
'',
|
||||
$service->endpoint('https://example.com/unexpected', 'applications'),
|
||||
'Unexpected user API URLs must fail closed'
|
||||
);
|
||||
|
||||
echo "Customer center proxy self-check passed\n";
|
||||
Reference in New Issue
Block a user