|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$root = dirname(__DIR__);
|
|
|
|
|
$read = static function (string $path) use ($root): string {
|
|
|
|
|
$contents = file_get_contents($root . '/' . $path);
|
|
|
|
|
if (!is_string($contents)) {
|
|
|
|
|
throw new RuntimeException('Unable to read ' . $path);
|
|
|
|
|
}
|
|
|
|
|
return $contents;
|
|
|
|
|
};
|
|
|
|
|
$assert = static function (bool $condition, string $message): void {
|
|
|
|
|
if (!$condition) {
|
|
|
|
|
throw new RuntimeException($message);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
$method = static function (string $source, string $name, string $next = '') use ($assert): string {
|
|
|
|
|
$end = $next !== ''
|
|
|
|
|
? '(?=\\n public static function ' . preg_quote($next, '/') . '\\b)'
|
|
|
|
|
: '(?=\\n private static function )';
|
|
|
|
|
$pattern = '/public static function ' . preg_quote($name, '/')
|
|
|
|
|
. '\\b[\\s\\S]*?' . $end . '/';
|
|
|
|
|
$assert(preg_match($pattern, $source, $match) === 1,
|
|
|
|
|
'Unable to isolate ' . $name . ' contract.');
|
|
|
|
|
return $match[0];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$routes = $read('config/routes.php');
|
|
|
|
|
$registry = $read('app/Services/Cloud/CloudObjectStorageBackendRegistry.php');
|
|
|
|
|
$backups = $read('app/Services/Cloud/CloudBackupService.php');
|
|
|
|
|
|
|
|
|
|
foreach ([
|
|
|
|
|
'createBackend', 'updateBackend', 'testBackend', 'activateBackend',
|
|
|
|
|
'drainBackend', 'resumeBackend', 'disableBackend',
|
|
|
|
|
] as $action) {
|
|
|
|
|
$assert(str_contains($routes,
|
|
|
|
|
'ObjectStorageController:' . $action . "')->add(new SuperAdmin())"),
|
|
|
|
|
'Object-storage action lost its SuperAdmin gate: ' . $action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$test = $method($registry, 'test', 'activate');
|
|
|
|
|
$activate = $method($registry, 'activate', 'drain');
|
|
|
|
|
$drain = $method($registry, 'drain', 'resume');
|
|
|
|
|
$runtime = $method($registry, 'runtime');
|
|
|
|
|
$assert(str_contains($test, 'headBucket(')
|
|
|
|
|
&& str_contains($test, "health_state = 'healthy'")
|
|
|
|
|
&& !str_contains($test, "admin_state = 'active'"),
|
|
|
|
|
'Connection testing must remain read-only and separate from activation.');
|
|
|
|
|
$assert(str_contains($activate, "['draft', 'disabled', 'read_only'], 'active', true")
|
|
|
|
|
&& str_contains($drain, "['active', 'read_only'], 'draining', false"),
|
|
|
|
|
'Activation and drain transitions lost their explicit state/health gates.');
|
|
|
|
|
$assert(str_contains($runtime, "admin_state === 'retired'")
|
|
|
|
|
&& !str_contains($runtime, "admin_state === 'draining'")
|
|
|
|
|
&& !str_contains($runtime, "admin_state === 'disabled'"),
|
|
|
|
|
'Draining/disabled backends must remain addressable for historical reads and cleanup.');
|
|
|
|
|
$assert(str_contains($registry, 'protected $hidden =') === false
|
|
|
|
|
&& !preg_match("/'sealed_credentials'\\s*=>/", $method($registry, 'listView', 'summary')),
|
|
|
|
|
'Browser-facing backend listing may expose encrypted credentials.');
|
|
|
|
|
|
|
|
|
|
$cleanupDebt = $method($backups, 'cleanupDebt', 'retryCleanup');
|
|
|
|
|
$retryCleanup = $method($backups, 'retryCleanup', 'create');
|
|
|
|
|
$assert(str_contains($cleanupDebt, "'next_check_at'")
|
|
|
|
|
&& str_contains($cleanupDebt, "'attention_at'")
|
|
|
|
|
&& !str_contains($cleanupDebt, "'object_key'")
|
|
|
|
|
&& !str_contains($cleanupDebt, "'object_version_id'"),
|
|
|
|
|
'Cleanup-debt DTO exposed provider object identity.');
|
|
|
|
|
$assert(str_contains($retryCleanup, 'inspectObject(')
|
|
|
|
|
&& str_contains($retryCleanup, "'delete_uncertain'")
|
|
|
|
|
&& !str_contains($retryCleanup, 'deleteObject('),
|
|
|
|
|
'Manual cleanup retry must inspect exact evidence without replaying DELETE.');
|
|
|
|
|
|
|
|
|
|
echo "Object-storage lifecycle and cleanup contracts passed.\n";
|