Files
dawnline/tests/ucode/live.test.uc
T
Aemeath fd9543ce68
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Dawnline 0.7.0
- Balanced, a new disguise for AmneziaWG 2.0 apps (AmneziaVPN 4.8.12 and
  newer): junk packets, padded cookie and data packets and DNS-shaped
  signature packets, for networks that learned to spot 1.0-style junk;
  offered when both the tools and the kernel module are 2.0 or newer
- The junk count and sizes in a device's configuration are the device's own
  (shifted a little, deterministically), so two phones of one family do not
  share one profile; they never require importing again
- Components remembers which AmneziaWG build was installed on which kernel;
  after a firmware upgrade Health says the build was for the old one and
  offers the build for the new firmware. A SNAPSHOT firmware is told there are
  no builds for it
- Location lookups moved off the agent's 1-second watcher to its minute tick,
  a few per minute within a time budget; the cache lives in tmpfs and goes to
  flash hourly, and addresses still shown on the map are never pushed out of
  it (and looked up again)
- The map library from the CDN is checked against its expected hash before it
  runs inside the LuCI page
- The activity log is copied to flash only when something was logged; the
  person page and the device drawer fetch only that person's events
- Admin UI: live updates survive the theme's in-page navigation, pollers stop
  with their page and sleep while the tab is hidden, the map is freed when
  leaving the Overview, a router that stops answering is said once (and when
  it is back), and an update of Dawnline under an open page asks for a reload
- Watchdog: no repairs while an update runs; a target that keeps failing keeps
  its back-off (repairs are forgotten after ten good minutes, not one); the
  LuCI link is reloaded or restarted three times at most, not every hour for
  good; the one-click "ifup" fix accepts only Dawnline's own tunnels
- Health warns when the router's flash is nearly full (settings would stop
  saving); the portal runs two processes instead of four on routers with
  little memory
- "Remove their devices" at an end date is never done on a clock that has not
  been set yet
2026-10-18 16:04:58 +03:00

51 lines
2.7 KiB
Ucode

// dawnline.live: event categories and the retention policy, from a settings
// object and from the fixture config (real libuci).
import * as live from 'dawnline.live';
test('category_of', () => {
eq(live.category_of('connect'), 'connections', 'connect');
eq(live.category_of('roam'), 'connections', 'roam');
eq(live.category_of('device_added'), 'people', 'device events are people events');
eq(live.category_of('person_changed'), 'people', 'person');
eq(live.category_of('server_down'), 'problems', 'server');
eq(live.category_of('something_new'), 'problems', 'unknown types are problems');
});
test('policy defaults', () => {
eq(live.policy({}), { keep_days: 30, max: 2000, categories: [ 'connections', 'people', 'problems' ],
persist: 'hourly', usage_days: 62, usage_months: 24 }, 'empty settings');
});
test('policy categories', () => {
eq(live.policy({ log_connections: '0' }).categories, [ 'people', 'problems' ], 'old switch');
eq(live.policy({ log_category: 'devices, problems' }).categories, [ 'people', 'problems' ], 'string list, devices renamed');
eq(live.policy({ log_category: [ 'connections', 'bogus', 'connections' ] }).categories, [ 'connections' ], 'list, unknown and repeats dropped');
eq(live.policy({ log_category: [], log_connections: '0' }).categories, [], 'explicit empty list wins');
});
// Ranges come from dawnline.schema: a stored value outside them (an older
// version, a hand edit) reads as the default, as settings_update would have refused it.
test('policy ranges', () => {
eq(live.policy({ log_max: '50' }).max, 2000, 'max below the floor: default');
eq(live.policy({ log_max: '99999' }).max, 2000, 'max above the ceiling: default');
eq(live.policy({ log_max: '150' }).max, 150, 'max in range');
eq(live.policy({ log_max: 'abc' }).max, 2000, 'bad max');
eq(live.policy({ log_keep_days: '0' }).keep_days, 0, 'keep forever');
eq(live.policy({ log_keep_days: '-3' }).keep_days, 30, 'negative days');
eq(live.policy({ log_persist: '10min' }).persist, '10min', 'persist');
eq(live.policy({ log_persist: 'daily' }).persist, 'hourly', 'bad persist');
eq(live.policy({ usage_keep_days: '1' }).usage_days, 62, 'usage days below the floor: default');
eq(live.policy({ usage_keep_months: '500' }).usage_months, 24, 'usage months above the ceiling: default');
});
test('policy from the config', () => {
eq(live.policy(null).categories, [ 'people', 'problems' ], 'fixture turns connections off');
eq(live.policy(null).max, 2000, 'default where the fixture says nothing');
});
test('endpoint_ip', () => {
eq(live.endpoint_ip('203.0.113.7:41821'), '203.0.113.7', 'v4');
eq(live.endpoint_ip('[2001:db8::1]:41821'), '2001:db8::1', 'v6');
eq(live.endpoint_ip(''), '', 'none');
});