Files
openclaw/packages/gateway-client/src/gateway-origin-scope.test.ts
Peter Steinberger 47fd629c8d feat(gateway): persist per-origin device auth (#120533)
* feat(gateway): add per-origin device auth

* fix(ui): remove unused gateway scope alias

* test(tui): split gateway chat coverage

* test(tui): update connection test routing

* fix(auth): preserve legacy device auth migration guard
2026-08-08 13:53:31 -07:00

28 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { gatewayCredentialScope, gatewayOriginScope } from "./gateway-origin-scope.js";
describe("gateway origin scope", () => {
it.each([
["wss://Gateway.Example:443/", "wss://gateway.example"],
["ws://gateway.example:80/rpc///", "ws://gateway.example/rpc"],
["wss://gateway.example/rpc/?token=secret#fragment", "wss://gateway.example/rpc"],
])("normalizes token scope %s", (input, expected) => {
expect(gatewayOriginScope(input)).toBe(expected);
});
it("retains search parameters only for browser credential scopes", () => {
const input = "wss://gateway.example:443/rpc/?account=work#fragment";
expect(gatewayCredentialScope(input)).toBe("wss://gateway.example/rpc?account=work");
expect(gatewayOriginScope(input)).toBe("wss://gateway.example/rpc");
});
it.each([
["", "default"],
[" wss://gateway.example/base/ ", "wss://gateway.example/base"],
["not a url", "not a url"],
])("preserves fallback semantics for %j", (input, expected) => {
expect(gatewayOriginScope(input)).toBe(expected);
});
});