diff --git a/tests/services/_api/player-api/identify.test.ts b/tests/services/_api/player-api/identify.test.ts index 5cfa5714..f72aeda5 100644 --- a/tests/services/_api/player-api/identify.test.ts +++ b/tests/services/_api/player-api/identify.test.ts @@ -125,6 +125,24 @@ describe('Player API service - identify', () => { expect(res.body).toStrictEqual({ message: 'Player not found: Talo aliases must be created using the /v1/players/auth API' }) }) + it('should require the service to be set', async () => { + const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS]) + const player = await new PlayerFactory([apiKey.game]).one() + await (global.em).persistAndFlush(player) + + const res = await request(global.app) + .get('/v1/players/identify') + .query({ identifier: player.aliases[0].identifier }) + .auth(token, { type: 'bearer' }) + .expect(400) + + expect(res.body).toStrictEqual({ + errors: { + service: ['service is missing from the request query'] + } + }) + }) + it('should require the service to be a non-empty string', async () => { const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS]) const player = await new PlayerFactory([apiKey.game]).one() @@ -143,6 +161,24 @@ describe('Player API service - identify', () => { }) }) + it('should require the identifier to be set', async () => { + const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS]) + const player = await new PlayerFactory([apiKey.game]).one() + await (global.em).persistAndFlush(player) + + const res = await request(global.app) + .get('/v1/players/identify') + .query({ service: player.aliases[0].service }) + .auth(token, { type: 'bearer' }) + .expect(400) + + expect(res.body).toStrictEqual({ + errors: { + identifier: ['identifier is missing from the request query'] + } + }) + }) + it('should require the identifier to be a non-empty string', async () => { const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS]) const player = await new PlayerFactory([apiKey.game]).one()