文件
yjyf/tests/enterprise_ocr_cos.php
MiAn b71980dd6b feat: 新增账号安全模块及资质校验功能
- 新增账号安全页面及支付密码验证组件
- 新增用户类型选择流程及商家资质管理
- 新增订单资质校验逻辑,师傅需满足订单证书要求
- 新增企业资质认证相关数据库表及接口
- 优化用户列表展示,区分个人与商家用户类型
2026-11-21 15:37:01 +08:00

19 行
1.2 KiB
PHP

<?php
// Integration test: one synthetic image in a unique COS key, removed in finally.
define('APP_PATH', __DIR__ . '/../server/application/');
require __DIR__ . '/../server/thinkphp/base.php';
\think\App::initCommon();
\think\Loader::addNamespace('Qcloud\\Cos', ROOT_PATH . 'addons/cos/library/Qcloud/Cos/');
$config = get_addon_config('cos');
$client = new \Qcloud\Cos\Client(['region'=>$config['region'], 'schema'=>'https', 'credentials'=>['secretId'=>$config['secretId'], 'secretKey'=>$config['secretKey']]]);
$key = 'cert/u999999999/codex-test-' . bin2hex(random_bytes(12)) . '.png';
$bytes = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+cZ7kAAAAASUVORK5CYII=');
try {
$client->putObject(['Bucket'=>$config['bucket'], 'Key'=>$key, 'Body'=>$bytes]);
$result = \app\common\library\EnterpriseLicenseImage::read(['storage'=>'cos', 'url'=>'/' . $key, 'filesize'=>strlen($bytes)]);
if (!hash_equals(hash('sha256', $bytes), hash('sha256', $result))) throw new \RuntimeException('COS image content mismatch');
echo "COS enterprise image integration passed\n";
} finally {
$client->deleteObject(['Bucket'=>$config['bucket'], 'Key'=>$key]);
}