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/VirtualizationAssetsTest.php

36 lines
2.0 KiB
PHP

<?php
// Static source graph only: no application boot, database or browser network.
$root = dirname(__DIR__);
$public = $root . '/public/cloud';
$assert = static function ($condition, $message) {
if (!$condition) throw new RuntimeException($message);
};
$entry = $public . '/vendor/novnc/core/rfb.js';
$queue = [$entry];
$seen = [];
while ($queue !== []) {
$file = array_pop($queue);
$resolved = realpath($file);
$assert($resolved !== false && str_starts_with($resolved, realpath($public) . DIRECTORY_SEPARATOR), 'Missing or external noVNC module: ' . $file);
if (isset($seen[$resolved])) continue;
$seen[$resolved] = true;
$source = file_get_contents($resolved);
preg_match_all('/(?:import|export)\s+(?:[^;]*?\s+from\s+)?[\'"]([^\'"]+)[\'"]\s*;/', $source, $imports);
foreach ($imports[1] as $path) {
if (str_starts_with($path, './') || str_starts_with($path, '../')) $queue[] = dirname($resolved) . '/' . $path;
}
}
$assert(count($seen) > 20, 'noVNC dependency graph was not validated');
$assert(is_file($public . '/vendor/novnc/LICENSE.txt'), 'Vendored noVNC license missing');
foreach (['almalinux', 'ubuntu', 'debian', 'centos'] as $system) {
$assert(is_file($public . '/' . $system . '-icon.svg'), 'Local OS icon missing: ' . $system);
}
foreach (['user/layout_header.tpl', 'user/layout_plain_header.tpl', 'auth/layout_header.tpl'] as $template) {
$source = file_get_contents($root . '/resources/views/venix/' . $template);
$assert(str_contains($source, '/cloud/styles.css') && str_contains($source, '/cloud/account.css'), 'Unified user styles missing: ' . $template);
$assert(!str_contains($source, 'user-home.css') && !str_contains($source, '/css/auth.css'), 'Retired user stylesheet still active: ' . $template);
}
$assert(!str_contains(file_get_contents($root . '/.gitignore'), "\nvendor/"), 'Nested noVNC vendor directory would be omitted from Git');
echo 'Unified user styles, local icons and noVNC source modules passed: ' . count($seen) . " modules.\n";