更新
This commit is contained in:
@@ -4,7 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use app\adminapi\logic\setting\DesktopWorkstationLogic;
|
||||
use app\adminapi\logic\setting\DesktopWorkstationLogic;
|
||||
use app\common\service\DirectUploadService;
|
||||
|
||||
function desktopUpdateExpect(bool $condition, string $message): void
|
||||
{
|
||||
@@ -92,14 +93,69 @@ desktopUpdateExpect(
|
||||
|
||||
$adminView = file_get_contents(dirname(__DIR__, 2) . '/admin/src/views/setting/desktop_workstation/index.vue');
|
||||
desktopUpdateExpect(is_string($adminView), 'admin view source is readable');
|
||||
desktopUpdateExpect(
|
||||
desktopUpdateExpect(
|
||||
str_contains($adminView, 'setting.desktop_workstation/setConfig')
|
||||
&& str_contains($adminView, 'force_update')
|
||||
&& str_contains($adminView, 'inno_setup'),
|
||||
'admin page can save force-update and Inno Setup configuration'
|
||||
&& str_contains($adminView, 'inno_setup')
|
||||
&& str_contains($adminView, 'type="desktop_package"')
|
||||
&& str_contains($adminView, 'direct'),
|
||||
'admin page saves update settings and sends installers through direct upload'
|
||||
);
|
||||
|
||||
$migration = file_get_contents(
|
||||
|
||||
$directUploadReflection = new ReflectionClass(DirectUploadService::class);
|
||||
$validateExtension = $directUploadReflection->getMethod('validateFileExtension');
|
||||
$validateExtension->invoke(
|
||||
null,
|
||||
DirectUploadService::TYPE_DESKTOP_PACKAGE,
|
||||
'uploads/desktop_package/7/' . date('Ymd') . '/package.exe',
|
||||
'DoctorWorkstation.EXE'
|
||||
);
|
||||
$invalidExtensionRejected = false;
|
||||
try {
|
||||
$validateExtension->invoke(
|
||||
null,
|
||||
DirectUploadService::TYPE_DESKTOP_PACKAGE,
|
||||
'uploads/desktop_package/7/' . date('Ymd') . '/package.php',
|
||||
'package.php'
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
$invalidExtensionRejected = true;
|
||||
}
|
||||
desktopUpdateExpect($invalidExtensionRejected, 'desktop direct upload rejects non-EXE/ZIP files');
|
||||
|
||||
$validateObjectKey = $directUploadReflection->getMethod('isAllowedObjectKey');
|
||||
$ownedKey = 'uploads/desktop_package/7/' . date('Ymd') . '/package.exe';
|
||||
desktopUpdateExpect(
|
||||
$validateObjectKey->invoke(null, DirectUploadService::TYPE_DESKTOP_PACKAGE, $ownedKey, 7) === true
|
||||
&& $validateObjectKey->invoke(null, DirectUploadService::TYPE_DESKTOP_PACKAGE, $ownedKey, 8) === false,
|
||||
'desktop package keys are bound to the issuing admin'
|
||||
);
|
||||
|
||||
$uploadController = file_get_contents(dirname(__DIR__) . '/app/adminapi/controller/UploadController.php');
|
||||
$qcloudEngine = file_get_contents(dirname(__DIR__) . '/app/common/service/storage/engine/Qcloud.php');
|
||||
$directUploadService = file_get_contents(
|
||||
dirname(__DIR__) . '/app/common/service/DirectUploadService.php'
|
||||
);
|
||||
desktopUpdateExpect(
|
||||
is_string($uploadController)
|
||||
&& str_contains($uploadController, 'assertDirectUploadPermission')
|
||||
&& str_contains($uploadController, 'setting.desktop_workstation/setconfig'),
|
||||
'desktop package credentials and confirmation require publish permission'
|
||||
);
|
||||
desktopUpdateExpect(
|
||||
is_string($qcloudEngine)
|
||||
&& str_contains($qcloudEngine, 'bool $exactObject = false')
|
||||
&& str_contains($qcloudEngine, '$exactObject ? $scope : $scope .'),
|
||||
'COS credentials can be restricted to one server-issued object key'
|
||||
);
|
||||
desktopUpdateExpect(
|
||||
is_string($directUploadService)
|
||||
&& str_contains($directUploadService, "trim(\$name) !== ''")
|
||||
&& str_contains($directUploadService, '$objectKey !== \'\''),
|
||||
'desktop credentials remain compatible with uploaders that do not send a filename'
|
||||
);
|
||||
|
||||
$migration = file_get_contents(
|
||||
dirname(__DIR__) . '/sql/1.9.20260821/add_desktop_workstation_update_menu.sql'
|
||||
);
|
||||
desktopUpdateExpect(is_string($migration), 'menu migration is readable');
|
||||
|
||||
Reference in New Issue
Block a user