refactor: whitelist public match responses
This commit is contained in:
1 parent
874d785381
commit
28e9ac1529
4 files changed
+248
-40
No files matched your search
@@ -0,0 +1,96 @@
|
||||
import { Types } from 'mongoose';
|
||||
import { presentPublicMatch } from './match-public.presenter';
|
||||
|
||||
describe('presentPublicMatch', () => {
|
||||
it('whitelists recruiting fields and excludes result/code internals', () => {
|
||||
const response = presentPublicMatch({
|
||||
_id: oid('1'),
|
||||
communityId: oid('2'),
|
||||
competitionId: oid('3'),
|
||||
shortCode: '33NW',
|
||||
title: '내전',
|
||||
description: '설명',
|
||||
mapId: 11,
|
||||
status: 'in-progress',
|
||||
scheduledAt: new Date('2026-07-12T10:00:00.000Z'),
|
||||
maxParticipants: 20,
|
||||
gameCount: 3,
|
||||
gameMode: 'double-elimination',
|
||||
roundRobinMaxRounds: undefined,
|
||||
hostUserId: oid('4'),
|
||||
participants: [
|
||||
{
|
||||
userId: oid('5'),
|
||||
puuid: 'public-roster-snapshot',
|
||||
gameName: '선수',
|
||||
tagLine: 'KR1',
|
||||
profileIconId: 1,
|
||||
preferredPositions: [
|
||||
{ position: 'MID', priority: 1 },
|
||||
{ position: 'SUP', priority: 2 },
|
||||
],
|
||||
joinedAt: new Date('2026-07-01T00:00:00.000Z'),
|
||||
excluded: false,
|
||||
},
|
||||
],
|
||||
teams: [
|
||||
{
|
||||
teamIndex: 8,
|
||||
name: '똥칼라파워',
|
||||
captainUserId: oid('5'),
|
||||
members: [{ userId: oid('5'), assignedPosition: 'MID', cost: 42 }],
|
||||
},
|
||||
],
|
||||
prizes: ['상품'],
|
||||
notices: ['안내'],
|
||||
schedule: [{ time: '20:00', label: '시작' }],
|
||||
createdAt: new Date('2026-07-01T00:00:00.000Z'),
|
||||
updatedAt: new Date('2026-07-12T00:00:00.000Z'),
|
||||
tournamentCodeIds: [oid('6')],
|
||||
tournamentCodes: [{ code: 'SECRET' }],
|
||||
result: { winnerTeamIndex: 3, games: [], seriesResults: [] },
|
||||
doubleElimination: { bracketMatches: [{ winnerTeamIndex: 3 }] },
|
||||
resultPollState: { state: 'polling' },
|
||||
legacyImportSource: { triggeringPuuid: 'secret' },
|
||||
});
|
||||
|
||||
expect(response).toMatchObject({
|
||||
_id: oid('1').toString(),
|
||||
communityId: oid('2').toString(),
|
||||
competitionId: oid('3').toString(),
|
||||
title: '내전',
|
||||
scheduledAt: '2026-07-12T10:00:00.000Z',
|
||||
participants: [
|
||||
expect.objectContaining({
|
||||
userId: oid('5').toString(),
|
||||
joinedAt: '2026-07-01T00:00:00.000Z',
|
||||
}),
|
||||
],
|
||||
teams: [
|
||||
{
|
||||
teamIndex: 8,
|
||||
name: '똥칼라파워',
|
||||
captainUserId: oid('5').toString(),
|
||||
members: [
|
||||
{
|
||||
userId: oid('5').toString(),
|
||||
assignedPosition: 'MID',
|
||||
cost: 42,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(response).not.toHaveProperty('tournamentCodeIds');
|
||||
expect(response).not.toHaveProperty('tournamentCodes');
|
||||
expect(response).not.toHaveProperty('result');
|
||||
expect(response).not.toHaveProperty('doubleElimination');
|
||||
expect(response).not.toHaveProperty('resultPollState');
|
||||
expect(response).not.toHaveProperty('legacyImportSource');
|
||||
expect(response.participants[0]).not.toHaveProperty('puuid');
|
||||
});
|
||||
});
|
||||
|
||||
function oid(suffix: string) {
|
||||
return new Types.ObjectId(suffix.padStart(24, '0'));
|
||||
}
|
||||
Reference in new issue
Block a user