검토 반영: 실시간 연결 권한 회수 · 맵 자동 갱신 재시도/누락 방지
- 사이트 /ws: 세션 삭제(서버 탈퇴 재확인) · 로그아웃이면 이미 열린 연결도 4401 로 끊는다 (30초마다 확인, 로그아웃은 바로) - update.sh: 모든 단계 공통 실패 처리(ERR trap) · 같은 조합은 30분→6시간 간격으로 재시도 · 첫 실패/성공 알림 · 지금 사이트에 있는 맵이 새 결과에 하나라도 없으면 올리지 않음 (--force 로만) - gvr-map-extract: 맵 찾기 중 레벨 읽기 실패도 실패로 (빠진 맵으로 덮어쓰지 않게) - 테스트: security.test.ts 연결 끊기 1개, scripts/test-update.sh 10개 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,7 +26,7 @@ async function fakeDiscord() {
|
||||
return { url: `http://127.0.0.1:${(srv.address() as any).port}`, close: () => srv.close() };
|
||||
}
|
||||
|
||||
async function stack(dataDir = tmp()) {
|
||||
async function stack(dataDir = tmp(), opts: { browserRecheckMs?: number } = {}) {
|
||||
const dc = await fakeDiscord();
|
||||
const cfg: Config = {
|
||||
port: 0, host: '127.0.0.1', publicUrl: 'https://gvr.example', clientId: 'cid', clientSecret: 's', botToken: 'bot',
|
||||
@@ -34,7 +34,7 @@ async function stack(dataDir = tmp()) {
|
||||
version: 'test', discordApi: dc.url, assetUpstream: {},
|
||||
};
|
||||
const lines: string[] = [];
|
||||
const { app, store } = await buildServer(cfg);
|
||||
const { app, store } = await buildServer(cfg, opts);
|
||||
// 서버 로그를 모아 둔다 (비밀값이 남는지 본다)
|
||||
const orig = process.stdout.write.bind(process.stdout);
|
||||
(process.stdout as any).write = (chunk: any, ...rest: any[]) => (lines.push(String(chunk)), orig(chunk, ...rest));
|
||||
@@ -89,6 +89,28 @@ test('실시간 WebSocket: 다른 사이트에서 로그인 쿠키로 붙으면
|
||||
}
|
||||
});
|
||||
|
||||
test('실시간 WebSocket: 세션이 지워지거나(서버 탈퇴 등) 로그아웃하면 이미 열린 연결도 끊는다', async () => {
|
||||
const s = await stack(tmp(), { browserRecheckMs: 50 });
|
||||
try {
|
||||
const connect = async (sid: string) => {
|
||||
const ws = new WebSocket(s.base.replace('http', 'ws') + '/ws', { headers: { cookie: sid, origin: 'https://gvr.example' } });
|
||||
await new Promise((r) => ws.on('open', r));
|
||||
return { ws, closed: new Promise<number>((r) => ws.on('close', (code) => r(code))) };
|
||||
};
|
||||
// 1) 세션 삭제 (getSession 의 서버 멤버 재확인이 실패하면 이렇게 지운다) → 다음 확인 때 끊김
|
||||
const a = await connect(await s.login());
|
||||
for (const x of [...(s.store as any).d.sessions]) s.store.deleteSession(x.id);
|
||||
assert.equal(await a.closed, 4401);
|
||||
// 2) 로그아웃 → 바로 끊김
|
||||
const sid = await s.login();
|
||||
const b = await connect(sid);
|
||||
await fetch(s.base + '/auth/logout', { method: 'POST', headers: { cookie: sid } });
|
||||
assert.equal(await b.closed, 4401);
|
||||
} finally {
|
||||
await s.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('세션: 서버 파일에는 세션 토큰 대신 해시만 남고, 예전 파일의 세션도 그대로 이어진다', async () => {
|
||||
const s = await stack();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user