The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(configPersistence): add tests for gateway id storage
Steven Enamakel00399552c7b2
diff --git a/app/src/utils/__tests__/configPersistence.test.ts b/app/src/utils/__tests__/configPersistence.test.tsindex e93ef8480b..f3e8a29c5f 100644--- a/app/src/utils/__tests__/configPersistence.test.ts+++ b/app/src/utils/__tests__/configPersistence.test.ts@@ -16,16 +16,19 @@ import {isLocalOrPrivateNetworkHost,isValidRpcUrl,normalizeRpcUrl,+ peekStoredGatewayId,peekStoredRpcUrl,redactRpcUrlForLog,storeCoreMode,storeCoreToken,+ storeGatewayId,storeRpcUrl,} from '../configPersistence';const STORAGE_KEY = 'openhuman_core_rpc_url';const TOKEN_STORAGE_KEY = 'openhuman_core_rpc_token';const MODE_STORAGE_KEY = 'openhuman_core_mode';+const GATEWAY_ID_STORAGE_KEY = 'openhuman_core_gateway_id';describe('configPersistence', () => {beforeEach(() => {@@ -33,6 +36,7 @@ describe('configPersistence', () => {localStorage.removeItem(STORAGE_KEY);localStorage.removeItem(TOKEN_STORAGE_KEY);localStorage.removeItem(MODE_STORAGE_KEY);+ localStorage.removeItem(GATEWAY_ID_STORAGE_KEY);});afterEach(() => {@@ -40,6 +44,7 @@ describe('configPersistence', () => {localStorage.removeItem(STORAGE_KEY);localStorage.removeItem(TOKEN_STORAGE_KEY);localStorage.removeItem(MODE_STORAGE_KEY);+ localStorage.removeItem(GATEWAY_ID_STORAGE_KEY);});describe('getStoredRpcUrl', () => {@@ -491,3 +496,50 @@ describe('configPersistence', () => {});});});++describe('gateway id storage', () => {+ beforeEach(() => {+ localStorage.removeItem(GATEWAY_ID_STORAGE_KEY);+ localStorage.removeItem(MODE_STORAGE_KEY);+ });++ it('round-trips the id the gateway mode refers to', () => {+ storeGatewayId('builder');++ expect(peekStoredGatewayId()).toBe('builder');+ expect(localStorage.getItem(GATEWAY_ID_STORAGE_KEY)).toBe('builder');+ });++ it('reports nothing stored rather than an empty string', () => {+ // `coreModeSlice` falls through to the picker on null; an empty string+ // would be an id that resolves to no gateway.+ expect(peekStoredGatewayId()).toBeNull();+ });++ it('treats a blank stored value as nothing stored', () => {+ localStorage.setItem(GATEWAY_ID_STORAGE_KEY, ' ');++ expect(peekStoredGatewayId()).toBeNull();+ });++ it('trims surrounding whitespace off a stored id', () => {+ localStorage.setItem(GATEWAY_ID_STORAGE_KEY, ' builder ');++ expect(peekStoredGatewayId()).toBe('builder');+ });++ it('stores no credential beside the id', () => {+ // The gateway's URL, bearer, SSH destination and identity path stay in the+ // Tauri shell's own store; a renderer XSS can read anything kept here.+ storeGatewayId('builder');++ const everything = Object.keys(localStorage).map(k => localStorage.getItem(k) ?? '');+ expect(everything.join(' ')).not.toMatch(/ssh|bearer|@/i);+ });++ it('accepts "gateway" as a core mode marker', () => {+ storeCoreMode('gateway');++ expect(getStoredCoreMode()).toBe('gateway');+ });+});