mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-02 07:24:48 +03:00
1d85ef138e
* fix(sub): prevent default profile page URL disclosure Add explicit none, builtin, and custom profile page modes. Preserve existing custom URLs and warn before exposing the built-in page. Cover mode selection, legacy settings, and subscription response headers. * fix(subscription): add profile page link options and upgrade notes
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { AllSetting } from '@/models/setting';
|
|
import { AllSettingSchema } from '@/schemas/setting';
|
|
|
|
describe('subscription profile mode', () => {
|
|
it.each([undefined, {}, { subProfileUrl: '' }, { subProfileUrl: ' ' }])(
|
|
'defaults to no link without a legacy URL: %j',
|
|
(data) => {
|
|
expect(new AllSetting(data).subProfileMode).toBe('none');
|
|
},
|
|
);
|
|
|
|
it('preserves a legacy custom URL when its mode is missing', () => {
|
|
const setting = new AllSetting({ subProfileUrl: 'https://example.com/profile' });
|
|
expect(setting.subProfileMode).toBe('custom');
|
|
expect(setting.subProfileUrl).toBe('https://example.com/profile');
|
|
});
|
|
|
|
it.each(['none', 'builtin', 'custom'])(
|
|
'honors the explicit %s mode with a stored URL',
|
|
(mode) => {
|
|
const result = AllSettingSchema.safeParse({
|
|
subProfileMode: mode,
|
|
subProfileUrl: 'https://example.com/profile',
|
|
});
|
|
expect(result.success).toBe(true);
|
|
if (!result.success) return;
|
|
expect(new AllSetting(result.data).subProfileMode).toBe(mode);
|
|
},
|
|
);
|
|
|
|
it.each(['auto', '', null, true])('rejects an invalid mode: %j', (mode) => {
|
|
expect(AllSettingSchema.safeParse({ subProfileMode: mode }).success).toBe(false);
|
|
});
|
|
});
|