CH-J Server Managerspráva serverů přes SSH
Menu
Vydané zdroje

CH-J Server Manager

Procházejte adresáře a soubory konkrétního vydání aplikace.

Stáhnout zdroje ZIP
CH-J Proprietary Software License 1.14

Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.

5,9 KB · 80 řádkůStáhnout soubor
1"use strict";
2// Exercises the actual production bootstrap in an isolated profile.
3const { app, BrowserWindow } = require("electron");
4const assert = require("node:assert/strict");
5const fs = require("node:fs"), os = require("node:os"), path = require("node:path");
6const { LicenseAcceptance } = require("../src/main/legal/licenseAcceptance");
7const root = fs.mkdtempSync(path.join(os.tmpdir(), "chj-license-ui-"));
8// Electron launched with a script otherwise treats scripts/ as the app root.
9app.setAppPath(path.join(__dirname, ".."));
10app.getVersion = () => require("../package.json").version;
11process.env.CHJ_BUILD_SMOKE_USER_DATA_DIR = root;
12const mode = process.env.CHJ_LICENSE_SMOKE_CASE || "accept";
13const acceptance = new LicenseAcceptance({ storageRoot: root, licensePath: path.join(__dirname, "..", "LICENSE"),
14 appVersion: require("../package.json").version, buildId: require("../src/shared/buildInfo.json").buildId });
15if (mode === "update") {
16 const previous = new LicenseAcceptance({ storageRoot: root, licensePath: path.join(__dirname, "..", "LICENSE"),
17 appVersion: require("../package.json").version, buildId: "core-previous-release-same-version" });
18 previous.accept({ accepted: true, sha256: previous.identity.sha256, guidanceShown: true, guidanceSha256: previous.identity.guidanceSha256 });
20let sawLicense = false, checked = false, sawMain = false, failure = null;
21let createdWindows = 0;
22const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
23app.on("browser-window-created", (_event, window) => {
24 if (++createdWindows > 1) sawMain = true;
25 window.webContents.once("did-finish-load", () => { void inspect(window).catch(error => { failure = error; console.error(error); app.exit(1); }); });
26});
27async function inspect(window) {
28 if (!window.webContents.getURL().endsWith("/license.html")) { sawMain = true; return; }
29 sawLicense = true;
30 for (let n = 0; n < 100; n++) {
31 if (await window.webContents.executeJavaScript('document.getElementById("licenseText").textContent.length > 10000')) break;
32 await wait(30);
33 }
34 assert.equal(await window.webContents.executeJavaScript('document.getElementById("licenseText").textContent'), acceptance.text);
35 assert.equal(await window.webContents.executeJavaScript('document.getElementById("licenseText").hidden'), true);
36 assert.equal(await window.webContents.executeJavaScript('document.getElementById("guidanceText").hidden'), false);
37 assert.equal(await window.webContents.executeJavaScript('document.getElementById("accept").disabled'), true);
38 assert.equal(await window.webContents.executeJavaScript('document.getElementById("consent").checked'), false);
39 assert.equal(await window.webContents.executeJavaScript('typeof window.require'), "undefined");
40 assert.equal(await window.webContents.executeJavaScript('typeof window.chj'), "undefined");
41 const preferences = window.webContents.getLastWebPreferences();
42 assert.equal(preferences.sandbox, true); assert.equal(preferences.contextIsolation, true); assert.equal(preferences.nodeIntegration, false);
43 app.emit("activate");
44 assert.equal(BrowserWindow.getAllWindows().length, 1);
45 const beforeGuidance = { accepted: true, sha256: acceptance.identity.sha256, guidanceSha256: acceptance.identity.guidanceSha256 };
46 assert.equal(await window.webContents.executeJavaScript(`window.licenseApi.accept(${JSON.stringify(beforeGuidance)}).then(() => false, () => true)`), true);
47 for (const [language, label] of [["cs", "Přijmout a pokračovat"], ["de", "Akzeptieren und fortfahren"], ["en", "Accept and continue"]]) {
48 await window.webContents.executeJavaScript(`document.getElementById("language").value = '${language}'; document.getElementById("language").dispatchEvent(new Event("change"));`);
49 assert.equal(await window.webContents.executeJavaScript('document.getElementById("accept").textContent'), label);
50 assert.equal(await window.webContents.executeJavaScript('document.getElementById("guidanceText").textContent'), acceptance.guidance[language]);
51 }
52 assert.equal(await window.webContents.executeJavaScript('window.licenseApi.accept({accepted:false}).then(() => false, () => true)'), true);
53 assert.equal(acceptance.isAccepted(), false);
54 checked = true;
55 const artifacts = process.env.CHJ_LICENSE_SMOKE_ARTIFACT_DIR;
56 if (artifacts) { fs.mkdirSync(artifacts, { recursive: true }); fs.writeFileSync(path.join(artifacts, "license.png"), (await window.webContents.capturePage()).toPNG()); }
57 if (mode === "close") window.close();
58 else if (mode === "decline") await window.webContents.executeJavaScript('document.getElementById("decline").click()');
59 else {
60 await window.webContents.executeJavaScript('document.getElementById("continue").click()');
61 for (let n = 0; n < 100; n++) {
62 if (await window.webContents.executeJavaScript('!document.getElementById("licenseText").hidden')) break;
63 await wait(30);
64 }
65 assert.equal(await window.webContents.executeJavaScript('document.getElementById("guidanceText").hidden'), true);
66 assert.equal(await window.webContents.executeJavaScript('document.getElementById("consentRow").hidden'), false);
67 await window.webContents.executeJavaScript('document.getElementById("consent").click(); document.getElementById("accept").click()');
68 }
70app.on("will-quit", () => {
71 try {
72 assert.equal(failure, null); assert.equal(sawLicense, true); assert.equal(checked, true);
73 const shouldAccept = !["close", "decline"].includes(mode);
74 assert.equal(sawMain, shouldAccept); assert.equal(acceptance.isAccepted(), shouldAccept);
75 console.log(`CHJ_LICENSE_UI_OK: ${mode}, guidance before license, full CS/DE/EN text, actual bootstrap, explicit consent, sandbox, activate guard`);
76 } catch (error) { console.error(error); app.exit(1); }
77 fs.rmSync(root, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
78});
79setTimeout(() => { console.error("License UI smoke timed out"); app.exit(1); }, 20000).unref();
80require("../src/main/index");

SHA-256: 434365b12c7954070e866f1098af867d307c7b3df6fb6e13b8aa8e1289126261

SHA-256 archivu: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0