Files
3x-ui/frontend/src/test/outbound-protocol-case.test.ts
T
BlindMaster24 c0c2dd274c fix(panel): read outbound protocol ids case-insensitively everywhere (#6523)
Six more readers compared an outbound's protocol id exactly while the core
lowercases it, so an outbound spelled "Blackhole" passed every
excludeBlackhole filter (offered as an mtproto egress, a dialerProxy
target and the geodata download egress, all of which then drop the
traffic) and one spelled "Freedom" was queued by Test All Outbounds. They
now share isOutboundProtocol.
2026-09-14 15:02:58 +02:00

29 lines
995 B
TypeScript

import { describe, expect, it } from 'vitest';
import { isOutboundProtocol } from '@/schemas/primitives';
// xray-core lowercases a protocol id in LoadWithID before it resolves the
// handler, so every panel reader has to accept the spellings it accepts.
describe('isOutboundProtocol', () => {
it.each([
['canonical', { protocol: 'freedom' }],
['capitalised', { protocol: 'Freedom' }],
['upper', { protocol: 'FREEDOM' }],
['mixed', { protocol: 'fReEdOm' }],
])('matches a %s id', (_name, outbound) => {
expect(isOutboundProtocol(outbound, 'freedom')).toBe(true);
});
it.each([
['another protocol', { protocol: 'blackhole' }],
['another spelling of another protocol', { protocol: 'Blackhole' }],
['missing', {}],
['empty', { protocol: '' }],
['not a string', { protocol: 42 }],
['null', null],
['undefined', undefined],
])('rejects %s', (_name, outbound) => {
expect(isOutboundProtocol(outbound, 'freedom')).toBe(false);
});
});