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.
virt/web/tests/CloudDefaultNetworkNonAutho...

64 lines
2.6 KiB
PHP

<?php
$root = dirname(__DIR__);
$read = static fn (string $path): string => (string) file_get_contents(
$root . '/' . $path
);
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$agent = $read('app/Services/Cloud/CloudAgentSettingsService.php');
$health = $read('app/Services/Cloud/CloudRuntimeHealthService.php');
$storage = $read(
'app/Services/Cloud/CloudHostStorageConfigurationService.php'
);
$console = $read('app/Services/Cloud/CloudConsoleTicketService.php');
$hostController = $read('app/Controllers/CloudAdminController.php');
$placement = $read('app/Services/Cloud/CloudPlacementService.php');
$publicNetwork = $read(
'app/Services/Cloud/CloudPublicNetworkAllocationService.php'
);
$restore = $read('app/Services/Cloud/CloudBackupService.php');
$migration = $read(
'app/Services/Cloud/CloudInstanceMigrationService.php'
);
$networkChange = $read(
'app/Services/Cloud/CloudNetworkChangeOptionsService.php'
);
$assert(!str_contains($agent, 'default_network')
&& !str_contains($agent, 'required_network_selector')
&& !str_contains($agent, 'invalidateForNetworkSelectorChange'),
'Agent readiness still treats compatibility default_network as authority.');
foreach ([
'runtime health' => $health,
'storage readiness' => $storage,
'console readiness' => $console,
] as $surface => $source) {
$assert(!str_contains($source, 'default_network'),
$surface . ' still reads compatibility default_network.');
}
$assert(str_contains($hostController, "'default_network'")
&& str_contains($hostController, '$host->default_network = $network;')
&& !str_contains($hostController, 'invalidateForNetworkSelectorChange'),
'Compatibility host metadata is missing or still invalidates Agent state.');
$assert(str_contains($placement,
"\$payload['body']['public_network'] = \$publicNetwork->toArray();")
&& str_contains($publicNetwork,
"'network_selector' => (string) \$attachment->network_selector")
&& str_contains($restore,
"'network_selector' => (string) \$network['network_selector']")
&& str_contains($migration,
"'public_network' => \$publicNetwork->toArray()")
&& str_contains($networkChange,
"->where('verified_agent_revision', (int) \$agent->revision)")
&& str_contains($networkChange,
"->whereIn('network_selector', \$testedSelectors)"),
'A VM network path no longer derives its selector from verified attachment evidence.');
echo "Compatibility default network is not a runtime authority.\n";