Files
3x-ui/frontend/src/test/client-form-modal.test.tsx
T
MHSanaei b04039c2bd feat(xray): add the MASQUE protocol and transport
xray-core v26.10.10 serves MASQUE: CONNECT-IP over HTTP/3 or HTTP/2,
always behind TLS, as an inbound and an outbound protocol riding a
dedicated "masque" transport. The panel could not create either.

Inbound: MASQUE is a multi-user protocol whose users log in with their
email and password over Basic auth. The panel keeps the client's
"password" like trojan and GenXrayInboundConfig hands it to the core as
"pass", so the full-config path, the live AddInbound path and node
pushes all emit what the core reads; one user with an empty pass makes
the core refuse the whole inbound. Live user adds build a masque.Account
from either key, client-only changes diff per user so a new client does
not drop every connected tunnel, and client creation, copy, validation
and edits key on the password. The address pool and MTU get form
fields, TLS is mandatory, and the port check follows the core's
listener choice: HTTP/2 on TCP when the ALPN offers h2, HTTP/3 on UDP
when it offers h3 or not h2. Nodes may host MASQUE from v3.9.1, the
first panel release that knows to rename the password.

MASQUE has no share-link format, so links and Clash skip it; the JSON
subscription builds the client's masque outbound with its email and
password, and the subscription allowlist now lets a subId see MASQUE
inbounds at all. The IP-limit job, client pages and traffic tracking
list the protocol.

Outbound: the form edits the server, remote DNS, and the transport's
host, path, Basic credentials, headers and WARP block (enrolled key,
endpoint public key, tunnel addresses), which xray-core refuses next to
user/pass. The outbound test probes it through the core, since its
default HTTP/3 dial is UDP.
2026-10-11 10:28:49 +02:00

74 lines
2.5 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { fireEvent, waitFor } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import ClientFormModal from '@/pages/clients/ClientFormModal';
import { renderWithProviders } from './test-utils';
// ClientFormModal reads server state via react-query (useFail2banStatusQuery),
// so it needs a QueryClientProvider on top of the shared ThemeProvider wrapper.
function renderModal() {
const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
renderWithProviders(
<QueryClientProvider client={queryClient}>
<ClientFormModal
open
mode="add"
client={null}
inbounds={[]}
save={vi.fn().mockResolvedValue(null)}
onOpenChange={() => {}}
/>
</QueryClientProvider>,
);
}
function openCredentialsTab() {
const tab = Array.from(document.querySelectorAll('.ant-tabs-tab')).find(
(t) => (t.textContent ?? '').trim() === 'Credentials',
);
if (!tab) throw new Error('Credentials tab not found');
fireEvent.click(tab);
}
function tooltipIconForLabel(label: string): HTMLElement {
const labelEl = Array.from(document.querySelectorAll('.ant-form-item-label label')).find(
(l) => (l.textContent ?? '').trim() === label,
);
const item = labelEl?.closest('.ant-form-item') as HTMLElement | null;
if (!item) throw new Error(`Form item not found for label: ${label}`);
const tip = item.querySelector('.ant-form-item-tooltip') as HTMLElement | null;
if (!tip) throw new Error(`No tooltip on form item: ${label}`);
return tip;
}
describe('ClientFormModal credential tooltips', () => {
it('explains which protocols consume the Password field', async () => {
renderModal();
openCredentialsTab();
const tip = tooltipIconForLabel('Password');
fireEvent.mouseEnter(tip);
await waitFor(() => {
expect(document.body.textContent).toContain(
'Used by Trojan, Shadowsocks, TUIC, and MASQUE clients; ignored for VLESS, VMess, Hysteria, and WireGuard.',
);
});
});
it('explains that Hysteria Auth is the credential Hysteria actually uses', async () => {
renderModal();
openCredentialsTab();
const tip = tooltipIconForLabel('Hysteria Auth');
fireEvent.mouseEnter(tip);
await waitFor(() => {
expect(document.body.textContent).toContain(
'Credential used only by Hysteria clients. Trojan and Shadowsocks use the Password field instead.',
);
});
});
});