mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-07-26 11:49:16 +00:00
8e7a567f69
* feat: pilot agent outbound-mode for remote nodes Adds a second mode for managing remote nodes: the agent dials an outbound WebSocket tunnel to the primary, so the remote host no longer needs an inbound port, a reachable URL, or its own TLS certificate. Works behind NAT, residential routers, and corporate firewalls. The primary multiplexes HTTP and WebSocket requests over a single tunnel via a hybrid JSON + binary frame protocol, bridged through a per-tunnel loopback server so existing proxy and upgrade handlers route pilot-mode nodes identically to proxy-mode ones. Enrollment uses a single-use 15-minute pilot_enroll JWT exchanged for a long-lived pilot_tunnel credential on first connect. Proxy mode continues to work unchanged and both modes are supported side-by-side. * test(e2e): switch to proxy mode before asserting api_url field Remote nodes default to Pilot Agent mode, which hides the api_url input. The SSRF-validation tests need proxy mode, so the helper now selects Distributed API Proxy after picking Remote type before asserting the field is visible. * fix(e2e): wire Combobox id prop so node-mode selector resolves The Combobox trigger button had no id, leaving its Label orphaned and making getByRole name-based lookups fail. Adding id to the primitive, passing id="node-mode" from NodeManager, and updating the E2E helper to use #node-mode fixes both the a11y regression and the CI timeout.
67 lines
3.0 KiB
TypeScript
67 lines
3.0 KiB
TypeScript
/**
|
|
* Node management E2E tests.
|
|
* Tests the SSRF validation we added (C2 fix) is surfaced in the UI.
|
|
*/
|
|
import { test, expect } from '@playwright/test';
|
|
import { loginAs } from './helpers';
|
|
|
|
test.describe('Node management', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
await loginAs(page);
|
|
// Settings is inside the User Profile Dropdown - open it first
|
|
await page.getByRole('button', { name: /profile/i }).click();
|
|
await page.getByRole('button', { name: /settings/i }).click();
|
|
await page.getByRole('button', { name: /^nodes$/i }).click();
|
|
});
|
|
|
|
/**
|
|
* Open the Add Node dialog and switch the type to Remote so the API URL
|
|
* field becomes visible. Returns false (and skips) if the button isn't found.
|
|
*/
|
|
async function openAddNodeAsRemote(page: import('@playwright/test').Page): Promise<boolean> {
|
|
const addBtn = page.getByRole('button', { name: /add node/i }).first();
|
|
if (!await addBtn.isVisible()) {
|
|
test.skip();
|
|
return false;
|
|
}
|
|
await addBtn.click();
|
|
// Wait for the dialog form to be ready
|
|
await expect(page.locator('#node-name')).toBeVisible({ timeout: 5_000 });
|
|
// The API URL field only renders when type === 'remote'.
|
|
// #node-type is a Radix UI combobox - click to open, then pick the option.
|
|
await page.locator('#node-type').click();
|
|
await page.getByRole('option', { name: /remote/i }).click();
|
|
// Remote nodes default to Pilot Agent mode; switch to Proxy so the api_url field renders.
|
|
await page.locator('#node-mode').click();
|
|
await page.getByRole('button', { name: /distributed api proxy/i }).click();
|
|
// Confirm the API URL field is now visible before proceeding
|
|
await expect(page.locator('#node-api-url')).toBeVisible({ timeout: 3_000 });
|
|
return true;
|
|
}
|
|
|
|
test('adding a node with localhost api_url shows a validation error', async ({ page }) => {
|
|
if (!await openAddNodeAsRemote(page)) return;
|
|
|
|
await page.locator('#node-name').fill('bad-node');
|
|
await page.locator('#node-api-url').fill('http://localhost:6379');
|
|
// api_token is required to enable the submit button; use a dummy value since we're testing URL validation
|
|
await page.locator('#node-api-token').fill('dummy-token');
|
|
// Use .last() to target the dialog submit button, not the trigger
|
|
await page.getByRole('button', { name: /add node/i }).last().click();
|
|
|
|
await expect(page.getByText(/loopback|localhost/i)).toBeVisible({ timeout: 5_000 });
|
|
});
|
|
|
|
test('adding a node with an invalid URL shows an error', async ({ page }) => {
|
|
if (!await openAddNodeAsRemote(page)) return;
|
|
|
|
await page.locator('#node-name').fill('bad-url-node');
|
|
await page.locator('#node-api-url').fill('not-a-url-at-all');
|
|
// api_token is required to enable the submit button; use a dummy value since we're testing URL validation
|
|
await page.locator('#node-api-token').fill('dummy-token');
|
|
await page.getByRole('button', { name: /add node/i }).last().click();
|
|
|
|
await expect(page.getByText(/valid url|invalid url/i)).toBeVisible({ timeout: 5_000 });
|
|
});
|
|
});
|