Files
BetterDesk/web-nodejs/tests/agentBundleConnection.test.js
T
UNITRONIX d07da4951a Implement support agent staging and enhance connection handling
- Added a new function to stage the Go support-agent source for Generator builds, ensuring proper setup without a full git checkout.
- Refactored connection handling to improve TLS configuration, allowing for insecure connections based on environment variables.
- Updated UI elements for better user experience, including resizing and wrapping labels for status messages.
- Enhanced the enrollment process with improved error handling and status updates.
- Introduced new environment variables and command-line options for running the agent without a GUI, catering to environments like VMs or RDP.
- Updated README and build scripts to reflect new features and requirements.
2026-06-04 03:08:17 +02:00

33 lines
1.3 KiB
JavaScript

'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const conn = require('../services/agentBundleConnection');
test('normalizeServerHost strips scheme and port', () => {
const r = conn.normalizeServerHost('https://desk.example.com:8443/path');
assert.equal(r.valid, true);
assert.equal(r.host, 'desk.example.com');
});
test('buildServerUrls omits default https port', () => {
const urls = conn.buildServerUrls('desk.example.com', true, '443');
assert.equal(urls.address, 'https://desk.example.com');
assert.equal(urls.api_url, 'https://desk.example.com/api');
});
test('buildServerUrls bakes CDAP and console endpoints', () => {
const urls = conn.buildServerUrls('desk.example.com', false, '21114');
assert.equal(urls.address, 'http://desk.example.com:21114');
assert.equal(urls.cdap_url, 'ws://desk.example.com:21122/cdap');
assert.equal(urls.console_url, 'http://desk.example.com:5000');
assert.equal(urls.cdap_port, 21122);
assert.equal(urls.console_port, 5000);
});
test('connectionFingerprint compares host and TLS only', () => {
const a = { server_host: 'a.example.com', use_https: true };
const b = { server: { address: 'https://a.example.com:21114' }, use_https: true };
assert.equal(conn.connectionFingerprint(a), conn.connectionFingerprint(b));
});