3D 리플레이 무기 스킨: 뽑아 둔 스킨이면 3인칭 손의 총 · 1인칭 총을 그 모델로 (없거나 못 받으면 기본 총), 없는 스킨은 POST /site/maps3d/skins/want 로 요청 (기본 스킨 · 실패한 것 제외) · 서버 GET /site/maps3d/skins · want.json (형식 검사 · 중복 제거 · 다른 사이트 요청 막음 · 최대 2000) · 목 서버 · 테스트
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,7 @@ async function stack() {
|
||||
const cb = await fetch(`${base}/auth/discord/callback?code=c&state=${state}`, { headers: { cookie: start.headers.getSetCookie()[0]!.split(';')[0]! }, redirect: 'manual' });
|
||||
return cb.headers.getSetCookie().find((c) => c.startsWith('gvr_sid='))!.split(';')[0]!;
|
||||
};
|
||||
return { base, store, login, close: async () => (await app.close(), dc.close()) };
|
||||
return { base, store, login, dataDir: cfg.dataDir, close: async () => (await app.close(), dc.close()) };
|
||||
}
|
||||
|
||||
test('맵 3D: 로그인 안 하면 목록 · 파일 모두 401', async () => {
|
||||
@@ -91,3 +91,39 @@ test('맵 3D: 로그인하면 목록과 glb 를 받는다 (gzip), 이상한 경
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('무기 스킨: 목록 · 파일은 로그인한 사람만, 요청은 없는 것만 want.json 에 쌓인다', async () => {
|
||||
const s = await stack();
|
||||
try {
|
||||
const sk = path.join(s.dataDir, 'maps3d', 'skins');
|
||||
fs.mkdirSync(sk, { recursive: true });
|
||||
const have = '/Game/Equippables/Guns/Rifles/AK/HypeBeast/AssaultRifle_AK_HypeBeast_PrimaryAsset||';
|
||||
const bad = '/Game/Equippables/Melee/Broken/Melee_Broken_PrimaryAsset||';
|
||||
fs.writeFileSync(path.join(sk, 'index.json'), JSON.stringify({ skins: { [have]: { weapon: 'Vandal', sig: 'abc' } }, looks: { abc: { w3p: 'skin3p_abc.glb' } }, failed: { [bad]: '메시 없음' } }));
|
||||
fs.writeFileSync(path.join(sk, 'skin3p_abc.glb.gz'), zlib.gzipSync(Buffer.from('skin')));
|
||||
assert.equal((await fetch(s.base + '/site/maps3d/skins')).status, 401);
|
||||
assert.equal((await fetch(s.base + '/site/maps3d/skins/want', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{"keys":[]}' })).status, 401);
|
||||
const cookie = await s.login();
|
||||
const idx = (await (await fetch(s.base + '/site/maps3d/skins', { headers: { cookie } })).json()) as any;
|
||||
assert.equal(idx.skins[have].sig, 'abc');
|
||||
const f = await fetch(s.base + '/site/maps3d/skins/skin3p_abc.glb', { headers: { cookie, 'accept-encoding': 'gzip' } });
|
||||
assert.equal(f.status, 200);
|
||||
assert.equal(await f.text(), 'skin');
|
||||
|
||||
const want = (keys: unknown[], origin?: string) =>
|
||||
fetch(s.base + '/site/maps3d/skins/want', { method: 'POST', headers: { cookie, 'content-type': 'application/json', ...(origin ? { origin } : {}) }, body: JSON.stringify({ keys }) });
|
||||
const k1 = '/Game/Equippables/Guns/Rifles/Carbine/SpecOps/Carbine_SpecOps_PrimaryAsset|/Game/Equippables/Guns/Rifles/Carbine/SpecOps/Levels/Carbine_SpecOps_Lv2_PrimaryAsset|';
|
||||
// 이미 있는 것 · 실패한 것 · 형식이 틀린 것은 넣지 않는다
|
||||
const r = await want([k1, have, bad, '../../etc/passwd||', 7, k1]);
|
||||
assert.equal(r.status, 200);
|
||||
assert.deepEqual(await r.json(), { queued: 1 });
|
||||
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(sk, 'want.json'), 'utf8')), [k1]);
|
||||
// 같은 것을 다시 요청하면 그대로
|
||||
assert.deepEqual(await (await want([k1])).json(), { queued: 0 });
|
||||
// 다른 사이트에서 온 요청은 막는다
|
||||
assert.equal((await want([k1.replace('Lv2', 'Lv3')], 'https://evil.example')).status, 403);
|
||||
assert.deepEqual(JSON.parse(fs.readFileSync(path.join(sk, 'want.json'), 'utf8')), [k1]);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user