fix(config): harden remote and identity validation
This commit is contained in:
@@ -90,6 +90,49 @@ test('native-settings:不完整最终身份显式拒绝,不拿 build identit
|
||||
);
|
||||
});
|
||||
|
||||
test('uAgent_3:所有允许 number 的身份字段都拒绝 NaN 和无穷值', async () => {
|
||||
const cases = [
|
||||
{ key: 'app_agent', value: Number.NaN, field: 'agentid' },
|
||||
{ key: 'app_channel', value: Number.POSITIVE_INFINITY, field: 'channelid' },
|
||||
{ key: 'app_market', value: Number.NEGATIVE_INFINITY, field: 'marketid' },
|
||||
] as const;
|
||||
for (const sample of cases) {
|
||||
const win = {
|
||||
app_agent: 'A', app_channel: 'C', app_market: 4, app_gameconfig: '',
|
||||
[sample.key]: sample.value,
|
||||
};
|
||||
await assert.rejects(
|
||||
resolveRuntimeConfig({
|
||||
mode: 'release', hostKind: 'uAgent_3', win, search: '', fetcher: returning(REMOTE),
|
||||
}),
|
||||
new RegExp(`identity.*${sample.field}.*finite`, 'i'),
|
||||
);
|
||||
}
|
||||
await assert.rejects(
|
||||
resolveRuntimeConfig({
|
||||
mode: 'release',
|
||||
hostKind: 'h5',
|
||||
win: {},
|
||||
search: '?agentid=A&channelid=C&version=NaN',
|
||||
fetcher: returning(REMOTE),
|
||||
}),
|
||||
/identity.*version.*finite/i,
|
||||
);
|
||||
});
|
||||
|
||||
test('uAgent_3:拒绝宿主提供的非法身份字段类型', async () => {
|
||||
await assert.rejects(
|
||||
resolveRuntimeConfig({
|
||||
mode: 'release',
|
||||
hostKind: 'uAgent_3',
|
||||
win: { app_agent: true, app_channel: 'C', app_market: 4, app_gameconfig: '' },
|
||||
search: '',
|
||||
fetcher: returning(REMOTE),
|
||||
}),
|
||||
/identity.*agentid.*type/i,
|
||||
);
|
||||
});
|
||||
|
||||
test('显式 local debug:direct 字段不靠 null 推断,完整服务器来自 profile', async () => {
|
||||
const fetcher = returning(REMOTE);
|
||||
const result = await resolveRuntimeConfig({
|
||||
|
||||
Reference in New Issue
Block a user