Files
BetterDesk/web-nodejs/tests/linuxSystemdUnitPrivileged.test.js
UNITRONIX b787ad9996 fix: rdclient file transfer JS getters and Linux systemd unit updates
Replace invalid prototype getter syntax in local-files.js and mesh-files.js
so the file transfer modal loads in browsers. Panel updates patch
betterdesk-server.service via a passwordless-sudo helper instead of
interactive sudo tee.

Refs #217
2026-06-24 20:19:02 +02:00

33 lines
1.4 KiB
JavaScript

'use strict';
const {
isAllowedSystemdUnitPath,
normalizeUnitPath,
resolveSystemdUnitScriptPath,
privilegedSystemdUnitHint,
} = require('../lib/linuxSystemdUnitPrivileged');
describe('linuxSystemdUnitPrivileged', () => {
test('allows BetterDesk systemd unit paths only', () => {
expect(isAllowedSystemdUnitPath('/etc/systemd/system/betterdesk-server.service')).toBe(true);
expect(isAllowedSystemdUnitPath('/etc/systemd/system/betterdesk-console.service')).toBe(true);
expect(isAllowedSystemdUnitPath('/etc/systemd/system/sshd.service')).toBe(false);
expect(isAllowedSystemdUnitPath('/tmp/betterdesk-server.service')).toBe(false);
});
test('normalizeUnitPath resolves absolute paths', () => {
expect(normalizeUnitPath('/etc/systemd/system/betterdesk-server.service'))
.toBe('/etc/systemd/system/betterdesk-server.service');
expect(normalizeUnitPath('relative/path')).toBeNull();
});
test('resolveSystemdUnitScriptPath points at helper script', () => {
const script = resolveSystemdUnitScriptPath('/opt/betterdesk/web-nodejs');
expect(script).toContain('linux-write-systemd-unit.js');
});
test('privilegedSystemdUnitHint mentions linux-ensure-console-user.js', () => {
expect(privilegedSystemdUnitHint()).toContain('linux-ensure-console-user.js');
});
});