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.
46 lines
2.0 KiB
PHP
46 lines
2.0 KiB
PHP
<?php
|
|
|
|
$root = dirname(__DIR__);
|
|
$controller = file_get_contents(
|
|
$root . '/app/Controllers/CloudAdminMaintenanceNoticeController.php'
|
|
);
|
|
$service = file_get_contents(
|
|
$root . '/app/Services/Cloud/CloudMaintenanceNoticeService.php'
|
|
);
|
|
$routes = file_get_contents($root . '/config/routes_cloud.php');
|
|
$middleware = file_get_contents($root . '/app/Middleware/CloudApi.php');
|
|
$assert = static function (bool $condition, string $message): void {
|
|
if (!$condition) {
|
|
throw new RuntimeException($message);
|
|
}
|
|
};
|
|
|
|
foreach ([':index', ':preview', ':create', ':detail', ':cancel'] as $action) {
|
|
$assert(str_contains($routes,
|
|
'CloudAdminMaintenanceNoticeController' . $action),
|
|
'Maintenance notice route is missing: ' . $action);
|
|
}
|
|
$assert(str_contains($middleware,
|
|
'#^/api/v1/admin/maintenance-notices(?:/|$)#D'),
|
|
'Database-only maintenance APIs create unnecessary cloud sessions.');
|
|
$assert(str_contains($controller, 'CloudAccess::manage($actor)')
|
|
&& str_contains($controller,
|
|
"preg_match('/^[A-Za-z0-9._:-]{16,128}\$/D', \$key)")
|
|
&& str_contains($controller,
|
|
"CloudInput::only(\$body, ['scope_type', 'scope_id'])")
|
|
&& !str_contains($controller, "'emails'")
|
|
&& !str_contains($controller, "'user_ids'")
|
|
&& !str_contains($controller, "'instance_ids'"),
|
|
'Admin API lost write authorization, idempotency or input ownership.');
|
|
$assert(str_contains($controller, 'private static function mask(')
|
|
&& str_contains($controller, "unset(\$instance['evidence']);"),
|
|
'Read-only administrators receive raw maintenance recipient evidence.');
|
|
$assert(str_contains($service, 'public function page(array $query = [])')
|
|
&& str_contains($service,
|
|
"selectRaw('notice_id, status, COUNT(*) AS aggregate')"),
|
|
'Maintenance list lacks bounded delivery-state aggregation.');
|
|
$assert(substr_count($controller, "'private, no-store'") === 1,
|
|
'Maintenance API responses do not share private no-store caching.');
|
|
|
|
echo "Maintenance notice administrator API contracts passed.\n";
|