Release 3X-UI for Docker / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
|
|
import { vlessEncryptionAuthKind } from '@/lib/xray/vless-encryption';
|
|
|
|
const x25519Key = 'kO9pIKKPtoUCzo3ZWfWfp0lQoWCyJC1TqL8oz1hpsFM';
|
|
const mlkem768Key = 'A'.repeat(1590);
|
|
|
|
describe('vlessEncryptionAuthKind', () => {
|
|
const cases: {
|
|
name: string;
|
|
encryption: string;
|
|
want: ReturnType<typeof vlessEncryptionAuthKind>;
|
|
}[] = [
|
|
{ name: 'empty string', encryption: '', want: null },
|
|
{ name: 'none', encryption: 'none', want: null },
|
|
{ name: 'only dots', encryption: '...', want: null },
|
|
{
|
|
name: 'x25519 native',
|
|
encryption: `mlkem768x25519plus.native.600s.${x25519Key}`,
|
|
want: 'x25519',
|
|
},
|
|
{
|
|
name: 'x25519 xorpub',
|
|
encryption: `mlkem768x25519plus.xorpub.600s.${x25519Key}`,
|
|
want: 'x25519_xorpub',
|
|
},
|
|
{
|
|
name: 'x25519 random',
|
|
encryption: `mlkem768x25519plus.random.600s.${x25519Key}`,
|
|
want: 'x25519_random',
|
|
},
|
|
{
|
|
name: 'mlkem768 native',
|
|
encryption: `mlkem768x25519plus.native.600s.${mlkem768Key}`,
|
|
want: 'mlkem768',
|
|
},
|
|
{
|
|
name: 'mlkem768 xorpub',
|
|
encryption: `mlkem768x25519plus.xorpub.600s.${mlkem768Key}`,
|
|
want: 'mlkem768_xorpub',
|
|
},
|
|
{
|
|
name: 'mlkem768 random',
|
|
encryption: `mlkem768x25519plus.random.600s.${mlkem768Key}`,
|
|
want: 'mlkem768_random',
|
|
},
|
|
{
|
|
name: 'two-segment value treated as native',
|
|
encryption: `mlkem768x25519plus.${x25519Key}`,
|
|
want: 'x25519',
|
|
},
|
|
];
|
|
|
|
for (const c of cases) {
|
|
it(c.name, () => {
|
|
expect(vlessEncryptionAuthKind(c.encryption)).toBe(c.want);
|
|
});
|
|
}
|
|
});
|