mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-22 04:19:40 +00:00
test(authz): let the guard's bypass list decide whether Resilience is reported as blocked (KEA-9357)
The reported-paths test pinned /api/resilience/connections and /api/skills/executions as always blocked for a remote session. Whether they are is the route guard's decision (a GET exemption or the manage-scope bypass list), and resolveDashboardLocalAccess already asks the guard. The test now names only paths no configuration opens, and a new case sets the bypass list both ways and checks the path is reported only while the list leaves it out.
This commit is contained in:
@@ -8,6 +8,10 @@
|
||||
import test, { afterEach, describe } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
applyRuntimeSettings,
|
||||
resetRuntimeSettingsStateForTests,
|
||||
} from "../../src/lib/config/runtimeSettings.ts";
|
||||
import { resolveDashboardLocalAccess } from "../../src/lib/security/dashboardLocalAccess.ts";
|
||||
import { isLocalOnlyPath } from "../../src/server/authz/routeGuard.ts";
|
||||
import { AUTHZ_HEADER_PEER_LOCALITY } from "../../src/server/authz/headers.ts";
|
||||
@@ -30,6 +34,7 @@ afterEach(() => {
|
||||
else process.env[key] = savedEnv[key];
|
||||
}
|
||||
__resetLocalOnlyRejectionsForTests();
|
||||
resetRuntimeSettingsStateForTests();
|
||||
});
|
||||
|
||||
/** The page request as a server component sees it: the pipeline already stamped the verdict. */
|
||||
@@ -59,9 +64,11 @@ describe("resolveDashboardLocalAccess (server)", () => {
|
||||
const access = resolveDashboardLocalAccess(pageHeaders("remote"));
|
||||
|
||||
assert.equal(access.locality, "remote");
|
||||
// Paths no configuration opens to a remote session. The two plain reads
|
||||
// (/api/resilience/connections, /api/skills/executions) are left out on purpose: whether
|
||||
// a remote session may run them is the guard's decision (a GET exemption or the
|
||||
// manage-scope bypass), covered by the two tests below.
|
||||
for (const path of [
|
||||
"/api/resilience/connections",
|
||||
"/api/skills/executions",
|
||||
"/api/db/health",
|
||||
"/api/plugins",
|
||||
"/api/tools/traffic-inspector/capture-modes",
|
||||
@@ -81,6 +88,27 @@ describe("resolveDashboardLocalAccess (server)", () => {
|
||||
assert.equal(access.remoteBlockedPaths.includes("/api/services/cliproxy/status"), false);
|
||||
});
|
||||
|
||||
test("a path stops being reported when the manage-scope bypass opens it", async () => {
|
||||
process.env.OMNIROUTE_PEER_STAMP_TOKEN = "stamp-token";
|
||||
delete process.env.OMNIROUTE_TRUST_PROXY;
|
||||
const path = "/api/resilience/connections";
|
||||
const reported = () =>
|
||||
resolveDashboardLocalAccess(pageHeaders("remote")).remoteBlockedPaths.includes(path);
|
||||
const setBypassPrefixes = (prefixes: string[]) =>
|
||||
applyRuntimeSettings(
|
||||
{ localOnlyManageScopeBypassEnabled: true, localOnlyManageScopeBypassPrefixes: prefixes },
|
||||
{ force: true }
|
||||
);
|
||||
|
||||
// The answer must follow the guard's configuration, whatever the default list is: a
|
||||
// notice over a page whose request would succeed hides a working feature.
|
||||
await setBypassPrefixes(["/api/mcp/"]);
|
||||
assert.equal(reported(), true, `${path} is local-only while the bypass does not list it`);
|
||||
|
||||
await setBypassPrefixes(["/api/mcp/", path]);
|
||||
assert.equal(reported(), false, `${path} must not be reported once the bypass lists it`);
|
||||
});
|
||||
|
||||
test("loopback and private-LAN sessions are local", () => {
|
||||
process.env.OMNIROUTE_PEER_STAMP_TOKEN = "stamp-token";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user