Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
test: cover exact public API path refusals (#11995)
Adam Eivyaec8dad4e156
diff --git a/server/lib/apiAccessPolicy.test.js b/server/lib/apiAccessPolicy.test.jsindex 29ba694229..6ed19e026c 100644--- a/server/lib/apiAccessPolicy.test.js+++ b/server/lib/apiAccessPolicy.test.js@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';import { readdirSync, readFileSync } from 'node:fs';import { fileURLToPath } from 'node:url';import { dirname, join } from 'node:path';-import { isAlwaysPublicApiPath, isPeerApiRequestAllowed, isPeerBasicBootstrapRequest } from './apiAccessPolicy.js';+import { ALWAYS_PUBLIC_API_PATHS, isAlwaysPublicApiPath, isPeerApiRequestAllowed, isPeerBasicBootstrapRequest } from './apiAccessPolicy.js';const SERVER_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');@@ -36,6 +36,22 @@ const reachable = (path) => ['GET', 'POST'].some((method) => isAlwaysPublicApiPa|| isPeerApiRequestAllowed(method, `${path}${path.endsWith('/') ? '' : '/'}x`));describe('peer API surface (#8387)', () => {+ it('matches only the exact always-public API paths', () => {+ for (const path of ALWAYS_PUBLIC_API_PATHS) {+ expect(isAlwaysPublicApiPath(path), path).toBe(true);+ }++ for (const path of [+ '/api/auth/status-extra',+ '/api/auth/status/',+ '/api/system/health/details',+ '/api/system/health/warnings/x/dismiss',+ '/api/eidoverse/travel/guest/x',+ ]) {+ expect(isAlwaysPublicApiPath(path), path).toBe(false);+ }+ });+it('admits every endpoint this version of PortOS calls on a peer', () => {const sites = peerCallSitePaths();// Guard against a scanner that silently stops finding call sites.diff --git a/server/services/authGate.test.js b/server/services/authGate.test.jsindex c8e2ec506c..f9a13a3019 100644--- a/server/services/authGate.test.js+++ b/server/services/authGate.test.js@@ -76,6 +76,24 @@ const runGate = async (gate, req) => new Promise((resolve) => {});describe('authGate middleware', () => {+ it('keeps health details password-gated while public health remains reachable', async () => {+ const auth = await import('./auth.js');+ await auth.setPassword({ newPassword: 'correct-horse' });+ const { authGate } = await import('./authGate.js');++ const health = await runGate(authGate, { method: 'GET', path: '/api/system/health', headers: {} });+ expect(health.called).toBe(true);++ const details = await runGate(authGate, { method: 'GET', path: '/api/system/health/details', headers: {} });+ expect(details.called).toBe(false);+ expect(details.res.statusCode).toBe(401);+ expect(details.res.body).toEqual({+ error: 'Authentication required',+ code: 'AUTH_REQUIRED',+ timestamp: expect.any(Number),+ });+ });+it('is a no-op when auth is disabled', async () => {const { authGate } = await import('./authGate.js');const req = { path: '/api/cos', headers: {} };