You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
5.0 KiB
PHP
113 lines
5.0 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$schema = file_get_contents($root . '/sql/cloud.sql');
|
|
$setup = file_get_contents($root . '/app/Command/CloudSetup.php');
|
|
$routes = file_get_contents($root . '/config/routes_cloud.php');
|
|
$controller = file_get_contents(
|
|
$root . '/app/Controllers/CloudAdminController.php'
|
|
);
|
|
$browser = file_get_contents(
|
|
$root . '/public/cloud/admin-template-upload.js'
|
|
);
|
|
$worker = file_get_contents(
|
|
$root . '/public/cloud/template-upload-hash-worker.js'
|
|
);
|
|
$workerService = file_get_contents(
|
|
$root . '/app/Services/Cloud/CloudWorkerService.php'
|
|
);
|
|
$template = file_get_contents(
|
|
$root . '/resources/views/venix/admin/cloud/templates.tpl'
|
|
);
|
|
$importModules = [
|
|
'CloudTemplateImportModule',
|
|
'CloudTemplateImportReservation',
|
|
'CloudTemplateRemoteAcquisition',
|
|
'CloudTemplateMultipartAcquisition',
|
|
'CloudTemplateImportPublication',
|
|
'CloudTemplateImportCancellation',
|
|
'CloudTemplateImportReadModel',
|
|
];
|
|
if (!is_string($schema) || !is_string($setup) || !is_string($routes)
|
|
|| !is_string($controller) || !is_string($browser)
|
|
|| !is_string($worker) || !is_string($workerService)
|
|
|| !is_string($template)) {
|
|
throw new RuntimeException('Template-import contract sources are unreadable.');
|
|
}
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
foreach (['cloud_template_import_intents',
|
|
'cloud_template_import_parts'] as $table) {
|
|
$assert(str_contains($schema, 'CREATE TABLE ' . $table . ' ('),
|
|
'Missing template-import table: ' . $table);
|
|
$assert(str_contains($setup, "'" . $table . "'"),
|
|
'CloudSetup does not require template-import table: ' . $table);
|
|
}
|
|
foreach ($importModules as $module) {
|
|
$assert(is_file($root . '/app/Services/Cloud/' . $module . '.php'),
|
|
'Missing template-import module: ' . $module);
|
|
}
|
|
$assert(!is_file(
|
|
$root . '/app/Services/Cloud/CloudTemplateImportWorkflow.php'
|
|
), 'Retired template-import workflow facade still exists.');
|
|
$assert(str_contains($schema,
|
|
'UNIQUE KEY cloud_template_import_request (user_id, request_idempotency_key)')
|
|
&& str_contains($schema,
|
|
'UNIQUE KEY cloud_template_import_template (template_id)')
|
|
&& str_contains($schema,
|
|
'UNIQUE KEY cloud_template_import_object (object_key)')
|
|
&& str_contains($schema,
|
|
'CONSTRAINT chk_cloud_template_import_completion CHECK (')
|
|
&& str_contains($setup,
|
|
"SCHEMA_VERSION = 'go-agent-wss-v23-traffic-admin'"),
|
|
'Template imports are missing durable identity or terminal-state constraints.');
|
|
$assert(str_contains($routes, "'/admin/cloud-template-imports'")
|
|
&& str_contains($routes, "'/admin/cloud-template-imports/{id}'")
|
|
&& str_contains($routes,
|
|
"'/admin/cloud-template-imports/{id}/upload'")
|
|
&& str_contains($routes,
|
|
"'/admin/cloud-template-imports/{id}/resume'")
|
|
&& str_contains($routes,
|
|
"'/admin/cloud-template-imports/{id}/parts/{part:[1-9][0-9]*}'")
|
|
&& str_contains($routes,
|
|
"'/admin/cloud-template-imports/{id}/complete'")
|
|
&& str_contains($routes,
|
|
"'/admin/cloud-template-imports/remote'")
|
|
&& str_contains($routes,
|
|
"delete('/admin/cloud-template-imports/{id}'")
|
|
&& str_contains($controller, 'CloudTemplateImportReadModel')
|
|
&& str_contains($controller, 'CloudTemplateMultipartAcquisition')
|
|
&& str_contains($controller, 'CloudTemplateRemoteAcquisition')
|
|
&& str_contains($controller, 'CloudTemplateImportCancellation')
|
|
&& str_contains($controller, 'beginUpload(')
|
|
&& str_contains($controller, 'cloudTemplateImportRemote(')
|
|
&& str_contains($controller, 'importRemote(')
|
|
&& str_contains($controller, 'cloudTemplateImportResume(')
|
|
&& str_contains($controller, 'resumeRemote(')
|
|
&& str_contains($controller, 'startUpload(')
|
|
&& str_contains($controller, 'recordPart(')
|
|
&& str_contains($controller, 'cloudTemplateImportCancel(')
|
|
&& str_contains($controller, '->cancel(')
|
|
&& str_contains($controller, 'completeUpload('),
|
|
'Administrator template-import intent routes are not wired.');
|
|
$assert(str_contains($browser,
|
|
"request.open('PUT', parsed.href, true)")
|
|
&& str_contains($browser, 'request.withCredentials = false')
|
|
&& str_contains($browser, "request.getResponseHeader('ETag')")
|
|
&& str_contains($browser, '/api/v1/admin/cloud-template-imports')
|
|
&& str_contains($browser, 'idempotencyKey: record.requestKey')
|
|
&& str_contains($browser, 'multipartPartSchedule(')
|
|
&& str_contains($browser, 'template-upload-active-list')
|
|
&& str_contains($worker, 'hashBlob(file')
|
|
&& str_contains($workerService,
|
|
'CloudTemplateRemoteFetcher::cleanupOneStaleFile()')
|
|
&& str_contains($template, 'id="template-upload-progress"')
|
|
&& str_contains($template, '文件内容不经过面板服务器'),
|
|
'Browser template upload lost direct multipart, hashing, or progress wiring.');
|
|
|
|
echo "Cloud-template import intent schema and route contract passed.\n";
|