Platform v2 step 1.10 (APPS_PLATFORM D-16, section 6.5).
- POST /api/auth/support/challenge (public): an 8-character challenge, stored 15 min
(support_challenges, revision 0009; at most 5 open). POST /api/auth/support/verify
{challenge, code}: code = base32(HMAC(SUPPORT_SECRET, site_id + challenge))[:10];
single use, 5 wrong codes burn the challenge. Opens a 4 h support session
(client=support, synthetic superadmin) with a hard end: sessions.expires_at.
- core/support_codes.py (stdlib only) is the derivation; tools/support_code.py
(--init, --site-secret <SITE_ID>, <SITE_ID> <CHALLENGE>) uses it on the builder's
machine with the master key in %USERPROFILE%/.xenia/support_master_key.txt.
- MASTER_USERNAME/MASTER_PASSWORD removed (config, login, docker-compose.yml,
.env.example); SUPPORT_SECRET added; install.sh asks for it.
- e2e: backends get SUPPORT_SECRET from a test master key and log in with challenge
codes (lib/support.mjs, license_e2e.py); install.mjs expects the new prompt.
- Pack rule CS-15.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.7 KiB
JavaScript
70 lines
2.7 KiB
JavaScript
// Shared settings for the end-to-end suites. Everything is derived from the repo
|
|
// layout or the environment — no machine-specific paths or IPs are hard-coded.
|
|
import { mkdirSync } from 'node:fs'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
export const E2E = path.resolve(here, '..') // client-services/tests/e2e
|
|
export const CS = path.resolve(E2E, '..', '..') // client-services
|
|
export const REPO = path.resolve(CS, '..') // xenia-pos (parent)
|
|
export const BACKEND = path.join(CS, 'local_backend')
|
|
export const WAITER = path.join(CS, 'waiter_pwa')
|
|
export const CLOUD = process.env.CLOUD_DIR || path.join(REPO, 'cloud-service', 'cloud_backend')
|
|
export const OUT = path.join(E2E, 'out') // screenshots, logs, temp data (gitignored)
|
|
mkdirSync(OUT, { recursive: true })
|
|
|
|
export const PYTHON = process.env.PYTHON || (process.platform === 'win32' ? 'python' : 'python3')
|
|
// Playwright browser: system Edge by default; BROWSER_CHANNEL= (empty) uses Playwright's own Chromium
|
|
export const BROWSER_CHANNEL = process.env.BROWSER_CHANNEL ?? 'msedge'
|
|
// The Android emulator reaches the host machine at this address
|
|
export const EMULATOR_HOST = '10.0.2.2'
|
|
|
|
/**
|
|
* This machine's LAN IPv4 — for "plain HTTP by LAN IP" browser tests.
|
|
* LAN_IP wins; otherwise the first address on a non-virtual, non-VPN adapter.
|
|
*/
|
|
export function lanIp() {
|
|
if (process.env.LAN_IP) return process.env.LAN_IP
|
|
const skip = /vEthernet|WSL|docker|br-|veth|virtual|vmware|vbox|hyper-v|wireguard|wg\d|tailscale|zerotier|vpn|loopback/i
|
|
for (const [name, addrs] of Object.entries(os.networkInterfaces())) {
|
|
if (skip.test(name)) continue
|
|
const a = (addrs || []).find(x => x.family === 'IPv4' && !x.internal && !x.address.startsWith('169.254.'))
|
|
if (a) return a.address
|
|
}
|
|
throw new Error('Could not detect this machine\'s LAN IP — set LAN_IP=<ip>')
|
|
}
|
|
|
|
/** Tiny PASS/FAIL reporter shared by the suites. */
|
|
export function reporter(suite) {
|
|
let failures = 0
|
|
console.log(`\n── ${suite}`)
|
|
return {
|
|
check(name, ok, extra = '') {
|
|
if (!ok) failures++
|
|
console.log(`${ok ? 'PASS' : 'FAIL'} ${name}${extra ? ' ' + extra : ''}`)
|
|
},
|
|
done() {
|
|
console.log(failures ? `✗ ${suite}: ${failures} failure(s)` : `✓ ${suite}: all passed`)
|
|
return failures
|
|
},
|
|
}
|
|
}
|
|
|
|
export const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
|
|
export async function waitFor(fn, timeoutMs, stepMs = 1000) {
|
|
const t0 = Date.now()
|
|
while (Date.now() - t0 < timeoutMs) {
|
|
try {
|
|
const r = await fn()
|
|
if (r) return r
|
|
} catch {
|
|
// not yet
|
|
}
|
|
await sleep(stepMs)
|
|
}
|
|
return null
|
|
}
|