Upload via GUI (335 Dateien)

This commit is contained in:
2026-10-24 20:14:43 +00:00
parent 793fe6162e
commit c270c0b6cf
21 changed files with 2955 additions and 1 deletions
+38
View File
@@ -75,6 +75,8 @@ $check(site_publish('theme', $themeZip('1.1.0'), ['slug' => 'nordlicht', 'name'
$bad = site_publish('plugin', $makeZip(['plugin.json' => '{"slug":"x1","name":"X","version":"1.0.0","permissions":["alles"]}', 'plugin.php' => '<?php']));
$check(!$bad['ok'] && str_contains($bad['error'], 'unbekannte Berechtigung'), 'unbekannte Berechtigung wird abgelehnt');
$future = site_inspect_package('plugin', $makeZip(['plugin.json' => '{"slug":"x2","name":"X","version":"1.0.0","permissions":["api.public","neu.spaeter"]}', 'plugin.php' => '<?php']));
$check($future['ok'], 'Berechtigungen in der Form "bereich.name" blockieren die Webseite nicht: ' . json_encode($future));
$check(!site_publish('plugin', $makeZip(['plugin.json' => '{"slug":"core","name":"X","version":"1.0.0"}', 'plugin.php' => '<?php']))['ok'], 'reservierter Name wird abgelehnt');
$check(!site_publish('plugin', $makeZip(['plugin.json' => '{"slug":"evil","name":"X","version":"1.0.0"}', '../evil.php' => '<?php']))['ok'], 'Zip-Slip wird abgelehnt');
$check(!site_publish('plugin', $makeZip(['plugin.json' => '{"slug":"exe1","name":"X","version":"1.0.0"}', 'a.exe' => 'MZ']))['ok'], 'unzulässiger Dateityp im Plugin wird abgelehnt');
@@ -90,6 +92,13 @@ $themeCatalog = site_catalog('theme');
$check(count($pluginCatalog['plugins']) === 1 && str_starts_with($pluginCatalog['plugins'][0]['downloadUrl'], 'https://plugins.example.test/download.php'), 'Plugin-Katalog enthält https-Download-Adresse');
$check(count($themeCatalog['themes']) === 1 && $themeCatalog['themes'][0]['version'] === '1.1.0', 'Theme-Katalog enthält nur die neueste Version');
// Empfehlung: im Katalog markiert, in DeskHub zuerst
$check(!isset($pluginCatalog['plugins'][0]['featured']), 'ohne Markierung kein Feld „featured“');
$firstId = (int) site_item('plugin', $pluginCatalog['plugins'][0]['slug'])['id'];
$check(site_set_featured($firstId, true) && site_catalog('plugin')['plugins'][0]['featured'] === true, 'Empfehlung steht im Katalog');
$check(!site_set_featured(99999, true), 'unbekannter Eintrag');
$pluginCatalog = site_catalog('plugin');
$files = [];
foreach (['plugin' => $pluginCatalog['plugins'], 'theme' => $themeCatalog['themes']] as $t => $list) {
foreach ($list as $e) {
@@ -110,6 +119,7 @@ set_setting('plugin_require_signature', '1');
$cat = plugin_catalog_fetch();
$check($cat['ok'] && count($cat['plugins']) === 1 && $cat['plugins'][0]['permissions'] === ['hooks.cron', 'ui.menu'], 'DeskHub liest den Plugin-Katalog der Webseite');
$check($cat['plugins'][0]['featured'] === true, 'DeskHub übernimmt die Empfehlung aus dem Katalog');
$r = plugin_catalog_install($pdo, 'tagesbericht');
$check($r['ok'] && $r['signed'] === true, 'DeskHub installiert das Plugin mit geprüfter Signatur („Signatur erforderlich“ an): ' . json_encode($r));
$check(is_file($tmp . '/plugins/tagesbericht/plugin.php'), 'Plugin-Dateien liegen im Plugin-Ordner');
@@ -230,6 +240,34 @@ clearstatcache();
$check(isset($deletedPackage) && !is_file($deletedPackage), 'die Paketdatei ist nach dem Löschen entfernt');
// Aufräumen
// ── Sprachpakete im Katalog ─────────────────────────────────────────────────
$langPkg = fn(array $lang) => $makeZip([
'plugin.json' => json_encode(['slug' => 'lang-xx', 'name' => 'Testsprache', 'version' => '1.0.0', 'entry' => 'plugin.php', 'permissions' => [], 'language' => $lang]),
'plugin.php' => "<?php\n",
'flag.svg' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3 2"><rect width="3" height="2"/></svg>',
'strings.json' => '{"Neues Ticket":"New ticket"}',
]);
$bad = site_publish('plugin', $langPkg(['code' => 'Englisch!', 'name' => 'X']));
$check(!$bad['ok'] && str_contains($bad['error'], 'language.code'), 'Sprachpaket mit ungültigem Sprachcode wird abgelehnt');
$okl = site_publish('plugin', $langPkg(['code' => 'xx', 'name' => 'Testsprache']));
$check($okl['ok'] && $okl['signed'] === true, 'Sprachpaket lässt sich veröffentlichen (Flagge, Texte, keine Berechtigungen)');
$entry = null;
foreach (site_catalog('plugin')['plugins'] as $e) if ($e['slug'] === 'lang-xx') $entry = $e;
$check($entry && $entry['language'] === ['code' => 'xx', 'name' => 'Testsprache'] && $entry['permissions'] === [], 'Katalog nennt Sprachcode und Namen');
$others = array_filter(site_catalog('plugin')['plugins'], fn($e) => $e['slug'] !== 'lang-xx');
$check(count($others) >= 1 && !array_filter($others, fn($e) => isset($e['language'])), 'normale Plugins haben kein Feld „language“');
$GLOBALS['deskhub_http_get'] = function (string $url, int $max) use ($pluginCatalog, $entry): array {
$c = site_catalog('plugin');
return str_contains($url, 'type=plugins') ? [200, json_encode($c), null] : [404, null, 'HTTP 404'];
};
$cat2 = plugin_catalog_fetch();
$lx = null;
foreach ($cat2['plugins'] ?? [] as $e) if ($e['slug'] === 'lang-xx') $lx = $e;
$check($lx && $lx['language'] === ['code' => 'xx', 'name' => 'Testsprache'], 'DeskHub übernimmt die Sprachangabe aus dem Katalog');
$nl = null;
foreach ($cat2['plugins'] ?? [] as $e) if ($e['slug'] !== 'lang-xx') $nl = $e;
$check($nl && $nl['language'] === null, 'DeskHub: normale Plugins ohne Sprachangabe');
$rm = function (string $d) use (&$rm) {
foreach (scandir($d) ?: [] as $e) { if ($e === '.' || $e === '..') continue; is_dir("$d/$e") ? $rm("$d/$e") : @unlink("$d/$e"); }
@rmdir($d);