fix(webui): make listener exposure explicit
Use a local-only default while preserving saved operator choices and keeping broader network access available from the settings panel. Treat enabled encrypted transport as a startup requirement and present a dismissible notice when remote browser access is not protected.
This commit is contained in:
12 files changed
+193
-36
No files matched your search
@@ -111,7 +111,7 @@ describe('prepareRestorePlan — strict semantic preflight', () => {
|
||||
expect(JSON.parse(prepared.restore[0].data.toString('utf8'))).toEqual({
|
||||
webuiPort: 5099,
|
||||
hookAutoLoad: false,
|
||||
webuiHost: '0.0.0.0',
|
||||
webuiHost: '127.0.0.1',
|
||||
webuiTls: { enabled: false },
|
||||
trustProxy: '',
|
||||
logMaxTotalMb: 1024,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import { validateTlsPair, resolveTlsContext } from '../src/webui/tls';
|
||||
import { requireTlsContext, validateTlsPair, resolveTlsContext } from '../src/webui/tls';
|
||||
|
||||
// A throwaway self-signed pair (openssl, CN=snowluma-test). createSecureContext
|
||||
// only parses — expiry is irrelevant — so this stays valid for the test forever.
|
||||
@@ -99,4 +99,21 @@ describe('resolveTlsContext', () => {
|
||||
expect(r.ok).toBe(false);
|
||||
expect(r.reason).toBeTruthy();
|
||||
});
|
||||
|
||||
it('refuses to start an enabled TLS listener with an unusable certificate pair', () => {
|
||||
expect(() => requireTlsContext(dir)).toThrow(/TLS.*missing/i);
|
||||
|
||||
fs.writeFileSync(path.join(dir, 'cert.pem'), 'garbage');
|
||||
fs.writeFileSync(path.join(dir, 'key.pem'), 'garbage');
|
||||
expect(() => requireTlsContext(dir)).toThrow(/TLS.*invalid/i);
|
||||
});
|
||||
|
||||
it('returns a validated certificate pair for an enabled TLS listener', () => {
|
||||
fs.writeFileSync(path.join(dir, 'cert.pem'), CERT);
|
||||
fs.writeFileSync(path.join(dir, 'key.pem'), KEY);
|
||||
|
||||
const tls = requireTlsContext(dir);
|
||||
expect(tls.cert.toString()).toContain('BEGIN CERTIFICATE');
|
||||
expect(tls.key.toString()).toContain('PRIVATE KEY');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user