'GET', 'REQUEST_URI' => $uri, 'QUERY_STRING' => parse_url($uri, PHP_URL_QUERY) ?: '', ]))->withAttribute('cloud_actor', $actor); }; $controller = new CloudAdminAbuseMonitoringController(); $response = $controller->alerts($request([ 'user_id' => 88, 'is_admin' => true, 'is_super_admin' => false, 'can_manage' => false, ], [ 'event_id' => '1', 'instance_id' => '41', 'user_id' => '10', 'host_id' => '3', ]), new Response()); $body = (string) $response->getBody(); $decoded = json_decode($body, true, flags: JSON_THROW_ON_ERROR); $assert($response->getStatusCode() === 200 && $response->getHeaderLine('Cache-Control') === 'private, no-store' && ($decoded['pagination']['total'] ?? 0) === 1 && ($decoded['items'][0]['event_id'] ?? '') === '1' && !str_contains($body, 'message_text') && !str_contains($body, 'chat_id') && !str_contains($body, 'binding_generation') && !str_contains($body, 'telegram_message_id') && !str_contains($body, 'content_hash') && !str_contains($body, 'evidence_json') && !str_contains($body, 'policy_hash') && !str_contains($body, 'sample_key') && !str_contains($body, 'finding_key') && !str_contains($body, 'item_key'), 'Read-only alert history API lost its cache, filter, or secrecy boundary.'); try { $controller->alerts($request([ 'user_id' => 89, 'is_admin' => false, ]), new Response()); throw new RuntimeException('Non-administrator alert history API succeeded.'); } catch (CloudError $error) { $assert($error->httpStatus === 403, 'Non-administrator alert history API returned the wrong status.'); } $routes = file_get_contents(dirname(__DIR__) . '/config/routes_cloud.php'); $controllerSource = file_get_contents(dirname(__DIR__) . '/app/Controllers/CloudAdminAbuseMonitoringController.php'); $assert(is_string($routes) && str_contains($routes, "\$this->get('/admin/abuse-monitoring/alerts'") && !str_contains($routes, "\$this->post('/admin/abuse-monitoring/alerts'") && !str_contains($routes, "\$this->put('/admin/abuse-monitoring/alerts'") && !str_contains($routes, "\$this->patch('/admin/abuse-monitoring/alerts'") && !str_contains($routes, "\$this->delete('/admin/abuse-monitoring/alerts'") && is_string($controllerSource) && str_contains($controllerSource, 'new CloudAdminAbuseAlertHistoryService()'), 'Alert history must expose exactly one administrator-only GET surface.'); echo "Administrator abuse-alert history API tests passed.\n";